0
Good afternoon colleagues, I would like a help to model a comic, the doubt is as follows:
Is it possible to have more than one FK ID on a tuple? EX:
tabela teste1
|id_teste1|id_teste2|teste|teste01|
| 1 |1,2,3 |tes | les |
tabela teste2
|id_teste2|registro1|registro2|
|1 |lalala |lelele |
|2 |bababa |bebebe |
|3 |cacaca |cecece |
At the time of performing the query, I could visualize the data ta table teste2?
more or less this way
Any suggestions as to how I could have such a result? more or less this way:
|id_teste1|registro1|registro2|teste|teste01|
| 1 |lalala |lelele |tes | les |
| 1 |bababa |bebebe |tes | les |
| 1 |cacaca |cecece |tes | les |
So as not to get out of context I’ll explain what I’m trying to do, is a tool to read a spreadsheet and write the data into a BD, only that the lines of some areas may vary, my idea was to make a separate table, and each row of the spreadsheet would be a record, and all these records would be referenced in the record of the "top" table, as if the table "spreadsheet" had a column where I can have the registry ids as pk, as in the example above "id_teste2" where we have 3 references.
I have limited experience in sql and would like the suggestion of colleagues ;D
Thanks for your help.
*ps: I searched a bucado and had no results D:
Edit:
The relation is: N resgistros ta table teste2
for each(1) table record teste1
; D
The relationship between the table
teste2
and the tableteste1
is 1-n? If yes, the ideal would be to have a tuple for each record of the referenced table, in this case, 3 items in theteste1
– Ronaldo Araújo Alves
@Ronaldoaraújoalves, the relation would be contrary I believe, varios registros na
teste2
for a record ofteste1
, thanks for the reply Ronaldo ; D– Augusto Cesar
In a properly normalized database this is not possible because a non-atomic attribute violates the normalization rules. Now there are DBMS that allow implementing such a solution type, but it will be a particular implementation and outside the SQL standard.
– anonimo
It is @anonimo, I checked the normalization rules and I saw that I was running away from the standard, if I told you how the first model was, the DBA on duty already killed me kkk, by the way, thank you very much for the answer ;D
– Augusto Cesar