So I currently have two tables (Made using the Django Models), In Short.. One that provides the parameters for a lookup, and the other that provides a history for the lookup. The second table currently references the primary key of the first table in order for it to be linked. This is all well and good until i try to input a new history lookup into the second table (as Im unsure as to what the primary key of the first is).
My question then, is there a way to relate the second tables foreign key to another column in the first table (e.g. "name").
First Table
id(pk) - name - data1 - data2 - data3
1 bill 3 6 9
2 sam 6 3 5
3 ken 1 2 3
Second Table (current):
id(pk) - id_id(fk) - result1 - result2 - result3
1 2 12 12 14
2 2 67 32 34
3 1 34 34 23
Second Table (proposed):
id(pk) - name_id(fk) - result1 - result2 -result3
1 sam 12 12 14
2 sam 67 32 34
3 bill 34 34 23
So pretty much the primary key of the first table gets replaced with the name of the first table.
All the names are unique. Thanks for any guidance.
Aucun commentaire:
Enregistrer un commentaire