designtrooper — 2013-03-04T12:21:26-05:00 — #1
I have 3 tables. 2 child and 1 parent.
The child tables have foreign keys that reference the parent.
I assume(and tell me if I am wrong) that the foreign keys in the child tables(which also serve as Primary keys in these table) should not be set to auto-increment
since their values will be taken from the parent table.
Am I right?
r937 — 2013-03-04T12:25:01-05:00 — #2
you are right, they should not
but why are the FKs also PKs in their table? this means the 2 child tables are each in a one-to-zero-or-one relationship with the parent -- perhaps you should think about merging them all into one table
designtrooper — 2013-03-04T13:01:51-05:00 — #3
Well...here is the rational.
This site will have 2 kind of users, business users and end_users.
Each of these will be in separate tables(the foreign keys will be there)
And the foreign keys from the above 2 will reference a table named credentials where the passwords and e-mails will be kept of the above 2.
So, for organisational purposes I have these 3 tables, I think it is better that a big monolithic table where business user and end users get mixed up.
What do you think?
r937 — 2013-03-04T13:27:21-05:00 — #4
sounds like a supertype / subtype arrangement
could be quite acceptable, depending on how you define "better than a big monolithic table"
abazovic — 2013-07-30T04:14:52-04:00 — #5
If You are talking about
"I think it is better that a big monolithic table where business user and end users get mixed up."
"Each of these will be in separate tables"
You are talking about
Single Table Inheritance - table per concrete class
Use that best suits for problem
Of course for some cases You can't use auto increment or sequence
Best way is that ID is generated by object itself for example GUID
oddz — 2013-07-31T18:24:18-04:00 — #6
I assume business users and end users have *very different data/column requirements?