Sebastian 506563
Sebastian 506563

Reputation: 7228

Dynamically created tables or one table with relations

i dont know what is better. I have something like:

Table1:
Name
ID
Structure

and Structure is table type data like:

Structure:
ID
Name

So one element of table 1 can have mulutiple elements of Structure.

what is better: 1)Create subtables with Table1.name as name 2)Make one Structure table with:

table1_reference
ID
Name

Everything will be used by C++/C# code. I just dont know what is better.

Upvotes: 0

Views: 65

Answers (1)

Filipe Silva
Filipe Silva

Reputation: 21657

That looks like you should remove the structure column from table1 and create a cross reference table with foreign keys from table1 (ID) and structure (ID) and you insert there the occurrences of the relationship of both tables.

When you want to have information from them, you simply join them by the IDs.

Don't simply add a column for table1_reference in table structures, because you would have the column name with a lot of duplicate information.

It should be:

Table1:
ID
Name

Structure:
ID
Name

table1_structure:
ID
TABLE1_ID
STRUCTURE_ID

Upvotes: 2

Related Questions