mysql - Are these too many foreign keys? -
i'm using mysql , have been planning out database structure system i'm building out. i've been going along, started wonder if acceptable have particular foreign key constraint in many different tables. understand, fine, makes sense. i'd double check.
for example, have users table, , use user_id foreign key many tables, multiple times in 1 table. example, have one-to-one
relationship user_settings
table, of course stores user_id
. , have companies table, alone has few references user_id
key. in case, have column keeps track of user created company in system (created_by
), column main contact (main_contact
, user of system), , there might reference. alone, has user_id
key being used foreign key constraint 3-4 times.
just add bit of info, have tasks table , of course needs reference user_id
keep track of it's assigned to, , have column keeps track of user created task. assigned_to
, created_by
, respectively.
there more tables though reference key. might 8 references already. believe i've designed far, based on i've mentioned, sound fine?
your foreign key usage seems fine me - after all, representing logical relationships between tables.
a user within system interacts data in many ways, , define these relationships approach correct one.
the key point think under lot circumstances, won't want (or need) make joins represent relationships - ones need in context.
Comments
Post a Comment