From: | Jorge Godoy <jgodoy(at)gmail(dot)com> |
---|---|
To: | Rick Schumeyer <rschumeyer(at)ieee(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: one-to-one schema design question and ORM |
Date: | 2007-03-09 15:41:28 |
Message-ID: | 87bqj2ifvb.fsf@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Rick Schumeyer <rschumeyer(at)ieee(dot)org> writes:
> I can think of two ways to do this:
>
> 1) a 1-1 relationship where the user table contains a FK to the employee
> table. Since not all users will be employees, the FK will sometimes be null.
> In rails, the user class would "belong_to employee" while employee "has_one
> user".
>
> 2) Create a link table that has FKs to both the user and employee table. This
> make sense because I'm not sure that the concept of "there might be a linked
> employee" belongs in the user table. This moves it to a separate table
> designed for that purpose. But then again, it may just be a needless extra
> table.
>
> Would you prefer one solution over the other?
It all depends on what you'll be doing and how often. Remember that ORMs
usually "select *", so you might end up using more memory / resources than
you'd be willing to.
If the RoR mapper can do lazy loadings, then this might not be too bad...
Anyway, you might also add the extra table to make it a place to gather more
information that will be relevant to your system only.
--
Jorge Godoy <jgodoy(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Sorin Schwimmer | 2007-03-09 15:53:40 | Re: query ... returned 4 columns |
Previous Message | Bruno Wolff III | 2007-03-09 15:36:51 | Re: Setting week starting day |