• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relevance Of Unique Attribute In Many-To-One relationship

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was implementing a many-To-One relationship between 2 entities say A and B where A is on Many-Side i.e



So,that means many A can refer to the same B , so the rows of table A will have many similar values of 'id' on which it is joined with table B . But since we are refering the id column as unique that can't be possible , so this seems to be a contradictory to me or am i missing something ?

Please help.


Thanks
Tanu
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally while you have a many-to-one relation, the entity which is on the one side will be allowed to have many instances of the other entity which is on the many side.


If 'A' is on the many side and 'B' is on the one side, B is allowed to have many instances of 'A' whereas 'A' can have at the max only one instance of 'B'.



Not aware of how should it be configured in the xml syntax you had given.

HtH.
 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Raghavan for an early reply.

Thats what I was thinking , but here in my case the table A is joined with the primary key 'id' of table B and not vice-versa, so that is the only relationship defined and hence the table B can't have multiple instances of A.

So,if I am right if that is the case this many-to-one relationship is turned out to be one-to-one relationship.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


but here in my case the table A is joined with the primary key 'id' of table B



In this case, table A may have many instances of table B right, provided there is a foreign key relation between table A and B on the id column of table B.

It holds good that table B is on the many side and table A is on the one side. Your xml syntax seems to be correct for what you require.

Just read a bit on Foreign Keys and you may get a clear picture!
[ May 25, 2007: Message edited by: Raghavan Muthu ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic