Jump to content
Larry Ullman's Book Forums

Chapter 3 : Foreign Key In "orders" Table


Recommended Posts

Hello group,

 

I have query in "orders" table. Here "id" is "primary key" & in foreign key CONSTRAINT the same "id" has been made "foreign key"

 

CONSTRAINT `fk_orders_user1` FOREIGN KEY(`id`)

REFERENCES `users`(`id`)

 

 

I feel its a typo, but the query executes smoothly & doesn't produce any error .

 

In 'orders' table if the 'users_id' is foreign key then the FK constraint clause should have been as follows.

 

CONSTRAINT `fk_orders_user1` FOREIGN KEY(`users_id`)

REFERENCES `users`(`id`) 

 

 

Am i right?

 

regards

Sachin Raut

 

 

Link to comment
Share on other sites

  • 3 weeks later...
 Share

×
×
  • Create New...