File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL problem

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 135
Android Java PHP
  • 0
  • 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: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would be more suitable on the JDBC forum. Moving...
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 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
  • 0
  • 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