How to Model Tables to Store Tag

Asked

Viewed 129 times

0

I have an SQL Server database where I have a table of videos linked to various tag s.

How is done here in the forum where each post is linked to various tags.

Best practice for modeling the database?

At first I thought of something like this, but I don’t know if it’s the best approach!

inserir a descrição da imagem aqui

  • 1

    A video is for various tags, so with a tag is linked in several videos, many for many (N:M) ... I believe is the best way by the information of the question

  • 1

    Jota does not need that Videotag id, can put idVideo and idTag as the primary key

  • @Virgilio Novic Normally I do not create composite key to facilitate access using Linq. The system that will maintain the base is Asp.Net MVC 4.6.

  • if it is Entity Framework 6 you don’t need to create ... if it is Entity Framework Core so far it needs to be this way ... then it really depends on you, in my opinion it is already correct your diagram ...

  • It depends... A video will have a single tag or can it have more than one tag? // If the relation is N:M, I suggest you remove the column id of VideoTag and who puts the pair (idTag, idVideo), in that order, as the primary key. If not, search by tag in the table VideoTag will stay a wagon.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.