How is a multivalued attribute represented?

0

I need to do a Google Play modeling as a university job, one of the requirements of the job is to represent a multivalued one. how would that be represented? Was it a guy? ex:

Nome     Tipo
Genero   Set

Is Set a Multivalued? If you can use some example that involves google play it will help.

    
asked by anonymous 19.04.2018 / 17:36

2 answers

1

In multivalued database attributes can be specific types such as array, set, json etc. In most cases it is using a varchar (which usually indicates a problem in the modeling) such as in post system where table of posts has a field of categoria that has as value the ids of categories separated by comma or any other delimiter.

Example:

id|titulo|categoria|data
1 |teste |1,2,49   |2018-04-19
2 |teste2|5        |2018-04-01
3 |teste3|22,6,78,3|2018-04-05

Related:

What is database normalization?

    
19.04.2018 / 17:43
1

Being your work related to the Play Store, I assume that the Género are "store categories" and these values are already stored in the database.

If the answer is yes, there is a problem of "many to many" and not just "1 to many."

For a database comply with the 1st Normal Form all table column values must be atomic, with the aim of avoiding redundancy of data.

As such, the solution used for this problem involves creating an intermediate table to store the relationship between the two entities which assuming that the Categorias are pre-defined would look something like this:

+---------+         +---------------------+        +-----------+
| EXEMPLO |         | EXEMPLO_CATEGORIA   |        | CATEGORIA |
+---------+ 1     * +---------------------+      1 +-----------+
|- ID [PK]|---------|- Exemplo [PK, FK]   |    +---|- ID [PK]  |
|- TITULO |         |- Categoria [PK, FK] |----+   |- Nome     |
|         |         |                     | *      |           |
|         |         |                     |        |           |
+---------+         +---------------------+        +-----------+

Either way I recommend reading the question What is database normalization? to get an idea of what the normal forms of a relational database are and the good practices related to them.

    
19.04.2018 / 18:09