A
A
Alexey2017-02-11 00:53:33
MySQL
Alexey, 2017-02-11 00:53:33

How to create relationships for entities?

Hello. I have a question. Maybe someone will give an answer. For example, I have several entities: banners, videos, texts. I want to fasten tags for these entities to make a filter. How reasonable is it to make tags generic for everyone? That is, one "TAG" entity for 3 (banners, videos, texts). If, for example, I want to somehow separate tags into categories: format, language. That is, I will enter the type field in the tags entity. Here is an example:
0f908a4bd167485d849a6d800739ada3.png
Or is it still better to enter separate tables like languages, formats and filter by them. And tags will be common without types. Example:
16518ac878b24797bf6bb8809f0fff5c.png
If there are few languages ​​5-10. In general, then is it worth entering a table?) Something I can’t normally build links. Are there any good building guidelines? There is also an option to separately enter your own "TAG" for each entity

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Leonovich, 2017-02-13
@atlantech

A new entity is usually introduced if it potentially contains a primary key. In your case, the entity suggests itself Languagebecause the language name will be unique (most likely you will not have two entries in the languages ​​table with the name ru or eng). By creating the lanugages table , you will get rid of the duplication of the banner_languages ​​and video_languages ​​tables and will be able to associate it with any other entities.
The same with tags - it makes no sense to produce identical entities. Make one entity Tagand add links to others.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question