Share Pastebin
Guest
Public paste!

Untitled

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