db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <Fisc...@seitenbau.net>
Subject Re: Saving associated objects
Date Wed, 08 Dec 2004 17:38:29 GMT


Saravana Krishnan <saravkrish@uky.edu> schrieb am 08.12.2004 17:33:13:

> Hi,
> ...
> My other doubt is, if it's a 1:1 relation between 2 tables, why not
> simply merge them? What's the point in having 2 tables with 1:1
> relations.
> Isn't having 2 1:1 related tables like having one table for name and one
> table for address, both having, say SSN, as the primary key? We would
> never do the above example, then why have 2 tables with 1:1 relations?

I also have created some DB models where 1:1 relations exist. They appear
because I try to put things which are an "entity" in one table. So in few
cases, one might have two entities (describing different things) that
nevertheless have a 1:1 relation.

As an example, one might have an entity "person" and an entity "address",
and each person has exactly one address and vice versa. But  they are two
different things, therefore one might want to put them into two different
tables. Also, in such a case, I would model this as a 1:n relation with the
special case n=1, and not simply use the same primary key in both tables
(which would be indeed pointless as you already pointed out).

I made good experiences with such separations, because as programs evolve,
things tend to get complicated, and at later time one might be compelled to
release the tight 1:1 coupling between the two entities (e.g. one wants to
store different home and office addresses for a person in the above
example). This is much more complicated if they are in one table. Also, in
my personal opinion, the data model is also easier to understand if
different things are stored in different tables.

> Thanks,
> Sarav


To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message