Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relevance Of Unique Attribute In Many-To-One relationship

 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • 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
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic