primary key as foreign key
i have this design
table: users
------------开发者_开发问答-
PK id_users
users
table: single_users
--------------------
PK FK users_id_users
something
table: workers
---------------
PK FK single_users_users_id_users
something
there is any problem to make a PK as foreign key? like the example above?
thanks
I think that's just fine as long as you have the one to many relationship between users to workers, and users to single_users.
Note: you will have to have a multiple valued PK though. Eg
users
1 Al
2 Eve
3 Bob
user_workers
1 something_1
1 something_2
So, you would have to have the id and something as a composite primary key. Its often easier to give the workers an id field that is a primary key.
So:
user_workers
id | user_id | something
1 1 something_1
2 1 something_2
精彩评论