wood burning stoves 2.0*
The moose likes JDBC and the fly likes can we join 2 diffrent tables in SQL. which does not have a foriegn key? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "can we join 2 diffrent tables in SQL. which does not have a foriegn key?" Watch "can we join 2 diffrent tables in SQL. which does not have a foriegn key?" New topic
Author

can we join 2 diffrent tables in SQL. which does not have a foriegn key?

J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121
please can anyone explain with a simple example?

please please please
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes - there is no syntactical difference in SQL whether there is a constraint or not.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121
then when desigining of tables instead of keeping foreign key and making the design complex

can we give each table a unique primary key and then link it instead of creating several foreign keys when there are large number of tables.

Which design is good?

second doubt :
suppose we have ID column as a primary key in one table and foreign key in another table. Is it mandatory that we have to name it ID in another table?

Regards,
Radolf
J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121
Thanks for your previous reply Sir
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


then when desigining of tables instead of keeping foreign key and making the design complex

can we give each table a unique primary key and then link it instead of creating several foreign keys when there are large number of tables


Using constraints is a good thing, it is after all one of the main reasons you would use a relational database to store your data (the clue is in the name). Does it make your data model complex? Not really. And doing otherwise means your data is open to corruption; your other idea is very bad design.


suppose we have ID column as a primary key in one table and foreign key in another table. Is it mandatory that we have to name it ID in another table?

No.
J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121
Thank you so much for your clarification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we join 2 diffrent tables in SQL. which does not have a foriegn key?