aspose file tools*
The moose likes JDBC and the fly likes SQL problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL problem" Watch "SQL problem" New topic
Author

SQL problem

Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 133

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)


Are you better than me? Then please show me my mistakes..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

This would be more suitable on the JDBC forum. Moving...


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

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

Joined: Oct 26, 2012
Posts: 133

Martin Vajsar wrote:I'd say it is incorrect.


Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL problem