Print Page | Close Window

Working with Tightly Coupled (1-to-1) Entities

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=22
Printed Date: 12-Mar-2025 at 8:37pm


Topic: Working with Tightly Coupled (1-to-1) Entities
Posted By: Customer
Subject: Working with Tightly Coupled (1-to-1) Entities
Date Posted: 30-May-2007 at 4:50pm
Question:

Is there any built-in DevForce support for managing one-to-one relationships?

I have a main (TableA) and a related table (TableB) which contains additional information that logically does not belong in TableA.

The business rules are:
•     There should always be exactly one TableB object.
•     When a TableA entity is created, a related TableB record should automatically be created. Same when TableA entity is deleted, TableB entity is also deleted. TableB entity cannot be deleted directly.
•     TableA should not expose a TableBs collection. Instead, it should expose a single TableB object that returns the single TableB object.



Replies:
Posted By: IdeaBlade
Date Posted: 30-May-2007 at 4:57pm

When examining table relations in a database, DevForce can’t tell the difference between a 1-to-Many relation and a 1-to-1 relation, so it generates relations as 1-to-Many.  You can override this assigned cardinality in the Object Mapper to make the relation 1-to-1; doing so will change the nature of the relation properties that are generated into the two entity classes.  Instead of a relation property representing a collection, it will represent a single related object.

You might want to look at the Instructional Unit on Generalization Hierarchies.  There you will find a discussion (in the PowerPoint slides) and examples of different ways to approach your development in the  case where two business objects have this tight coupling.




Print Page | Close Window