Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Architecture> Foreign key may refer to different classes
 

Pages: 1
Architecture
Foreign key may refer to different classes
Page:1/1 

  Print all messages in this thread  
Poster Message
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 02-Apr-2007 02:00:24.  
Any recommendations on the preferred way to handle this scenario:

I have a class Folder that is a collection of objects that derive from a "Document" base. In the old architecture, the FolderItem table had columns to store both a class ID and an identity for the Document that comprised that item. So when the Folder was instantiated, the collection would read each FolderItem and then, based on the class ID, go get the right object, which could be one of several different classes, each stored in a different table. Thus in the database the FolderItem's "DocumentID" column isn't a foreign key to a single table.

What's the best practice for implementing this in LLBLGen? Reproduce the same logic in the generated classes, or add a column to the FolderItem table for each kind of document it could store? For example, instead of DocumentClassID and DocumentID columns, FolderItem would have DocumentKind1ID, DocumentKind2ID, DocumentKind3ID, etc., with only one of them populated, based on what kind of document was being held.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14480 posts
# Posted on: 02-Apr-2007 09:35:51.  
If you have different kinds of Documents, then maybe you need to consider Inheritance.
refer to LLBLGen Pro manual: "Concepts -> Entity inheritance and relational models"

So you FolderItem would reference the MainDocument table (with FK-PK relation), this table should have common fields of different Documents Types.
Then each Document Type should have 1:1 relation with MainDocument.


  Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 02-Apr-2007 22:43:24.  
Thanks--I missed that in the new version.
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.