Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please can anyone explain with a simple example?

please please please
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes - there is no syntactical difference in SQL whether there is a constraint or not.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your previous reply Sir
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your clarification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic