• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL problem

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!,
I've created a table with 2 attributes as a primary key.
another table has a foreign key references 1 attribute of previous table.

Is it incorrect? (MySQL is ok with it)
 
Maneesh Godbole
Saloon Keeper
Posts: 11061
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would be more suitable on the JDBC forum. Moving...
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say it is incorrect.

Primary key ensures uniqueness. But individual columns of a primary key are (in general) not unique. Foreign constraints are required by SQL standard to refer to a unique key. I'm surprised that MySQL even allows his situation.
 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:I'd say it is incorrect.


Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic