d3v4 — 2012-02-15T14:23:28-05:00 — #1
What is the best way to connect an entry in a database table with multiple entries in the same table?
I was thinking about creating a table to store this information, but is there a better way to do it?
r937 — 2012-02-15T14:28:05-05:00 — #2
please give something more specific for us to think about, like descriptions of your actual table and columns
as your question stands now, the answer is "foreign keys"
d3v4 — 2012-02-15T14:35:54-05:00 — #3
Imagine having a Users table, where you want to keep track of which users are part of the same family, for example.
As for the actual names of columns, I don't know because I was just thinking about this problem in general terms
r937 — 2012-02-15T14:37:08-05:00 — #4
for sure you'd need a family table
d3v4 — 2012-02-15T14:45:08-05:00 — #5
I thought so.
I don't remember this very well, but can foreign keys be used to connect one entry to multiple entries?
r937 — 2012-02-15T16:44:51-05:00 — #6
no, but they can be used to connect multiple entries to one entry
FKs always go in the child (many) table, referencing the parent (one) table's PK