Skip to content

Instantly share code, notes, and snippets.

@metacritical
Last active August 10, 2021 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metacritical/94174bddc3bee4dd50b48bf8eff78308 to your computer and use it in GitHub Desktop.
Save metacritical/94174bddc3bee4dd50b48bf8eff78308 to your computer and use it in GitHub Desktop.
Tagging Service

Tag Service

The simplest video tag service should have atleast four tables, a videos table, a tag lists table, a user table and a tags join table. We would prevent tag collisions through code.

Constraints:

User has many Editable tags, one user can see others tags. genreally this shouldnt be a problem but if one wants to search videos based on tags then redundaant tags would cause problems with indexing.

  • Assumption is that the tag service uses Sql Database, a no Sql Document design would defer form this design.

Considerations:

  • Should tags be approved, to prevent users from creating abusive tags?
  • Searching videos based on tags?
  • Redundant tags cause host of issues including indexing issues.

Endpoint:

List all tags for the current user.

/tags

List all tags starting with 'ra'

/search/tags?q="ra"

  • User Table
id username
. .

CONSTRAINT PRIMARY KEY(id)

CONSTRAINT UNIQUE KEY(username)

  • Videos Table
id name user_id tag_id
. . . .

CONSTRAINT PRIMARY KEY(id)

CONSTRAINT UNIQUE KEY(id)

  • Tags Table
id user_id tag_name
. . .

CONSTRAINT UNIQUE KEY(video_id, id, tag_name)

  • Tags join Table
user_id tag_id
. .
  • User has many videos.
  • User has many tags.
  • Video has many tags through tags join table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment