Untitled
By: a guest | Mar 16th, 2010 | Syntax:
PHP | Size: 0.67 KB | Hits: 43 | Expires: Never
<AJKhan> I'm needing to add the foriegn key constraints
<AJKhan> but i don't get how to propery name the constraints
<AJKhan> Foreign keys should be named using the 'modelname_id' (e.g. user_id)
<AJKhan> and in the auth example, the mysql scheme contains example such as
<AJKhan> ADD CONSTRAINT roles_users_idfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
<AJKhan> so I have table company with column id
<AJKhan> and my users table has a column called fk_company_id
<AJKhan> so what should I make it here?
<AJKhan> please advise
<AJKhan> alter table users add constrainst user_idfk_1 foreign key (fk_company_id) references companies (id) on delete cascade ?