SQL Power Business Intelligence Productivity Tools

SQL Power Software Forum

SQL Power Software Forum

  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page  [Register] Register /  [Login] Login 
1 to 1 Relationship?  XML
Forum Index » SQL Power Architect Discussion
Author Message
mickd


Joined: 2008-07-23 20:22:14
Messages: 2
Offline

Hi I just downloaded and am trying out Power Architect. So far it looks awesome! Thanks for your hard work.

I have a question about relationships. I have two tables that are actually a one to zero or one relationship. It appears that this is not possible to model, am I correct?

Thanks!

Mick
Jonathan
SQL Power Developer

Joined: 2007-01-08 15:10:32
Messages: 873
Offline

Hi Mick!

The answer is, you can model it. However, there's no particular enforcement of 1-to-1 when you forward engineer to the database. So it comes out in your database just like the default 1-to-many relationship: as a foreign key constraint.

I'm not aware of any portable way to represent a one-to-one constraint (as opposed to one-to-many) in SQL. If you have any suggestions along these lines, we're definitely listening!

I've attached a picture of a one-to-one relationship along with the associated relationship properties dialog.

-Jonathan
[Thumb - architect_1_to_1.png]
 Filename architect_1_to_1.png [Disk] Download
 Description Screenshot of a 1-to-1 relationship
 Filesize 71 Kbytes
 Downloaded:  2383 time(s)

Jonathan
SQL Power Developer

Joined: 2007-01-08 15:10:32
Messages: 873
Offline

Ok, I don't know what I was smoking just now.

The screenshot I just posted will forward engineer as an enforced one-to-zero-or-one constraint. You can't have duplicate a_id records in Table_B, because a_id is the primary key.

There's nothing special about the foreign key created by the relationship; it's the fact that the child table's primary key is the same as the parent's.

Come to think of it, we should recognise this pattern when reverse engineering, and set the relationship cardinality accordingly.

-Jonathan
mickd


Joined: 2008-07-23 20:22:14
Messages: 2
Offline

Thanks Jonathan! I saw that after I posted and that's what I ended up using. We have a legacy system that I am trying to model that actually has 1 to 1. Zero is not an option, but it's enforced by code...

Mick
 
Forum Index » SQL Power Architect Discussion
Go to:   
Powered by JForum 2.1.8 © JForum Team