-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Referencial integrity or normal schema for 1:N relation?
PostPosted: Thu Oct 19, 2006 10:54 am 
Newbie

Joined: Thu Jun 29, 2006 11:49 am
Posts: 13
Hello.

I have a very simple problem about sorting.

I have an entity called ActionList (properties: int id, string name, table ACTIONLISTS). And I have an entity Action (properties: int id, string description, table ACTIONS).

What's the most correct strategy here if I want the ActionList to contain 1 to N actions but keeping the actions with a specific order?

a) Have a foreign key in ACTIONS which goes to the id of the ACTIONLISTS, and an int attribute called "order", and let the application worry about not putting duplicate entries in the same order inside a list (no referencial integrity). This is the most easier to implement with NHibernate.

b) Have an external table, called ACTIONS_ACTIONLISTS, which contains the ID of the ACTION, the ID of the ACTIONLIST, and the sort order, in which the primary key is the LISTACTIONID+SORT_ORDER, so as to keep the most perfect referential integrity. How can I deal with this working with NHibernate?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 2:21 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
You can use <list>, which has a integer indexing which keep the positions of the items.
Be aware that this means that you can't have "holes" in the indexes...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.