Re: Modeling bill/ship addresses

From: johnf <jfabiani(at)yolo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Modeling bill/ship addresses
Date: 2007-08-06 13:33:30
Message-ID: 200708060633.30901.jfabiani@yolo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 05 August 2007 21:43, snacktime wrote:
> I've been going back and forth on the best way to model this.
>
> A user can have one to many bill and ship addresses.
> An order can have one bill address and one to many ship addresses
>
> Let's assume I have a single address table, with an address_type
> column that is a foreign key to the address_types table.
>
> Now to create the relationships between addresses and users/orders. I
> could create a join table for holding the addresses that belong to
> orders. For example table order_addresses that has order_id and
> address_id columns that are foreign keys on addresses and orders.
>
> But what about just having two foreign keys in addresses? order_id
> and user_id? Or is there a rule against having a null foreign key?
>
> Also, is there a good database independent way to make the address
> immutable once it's created? I don't mind doing it at the application
> level actually, as I'm using a MVC framework that makes it easy to
> define that logic once in the model instead of spread out all over the
> codebase.
>
> Chris
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
Use a third table. The table would contain
the order pk
the address pk
the line item pk
--
John Fabiani

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Charlie Clark 2007-08-06 14:35:41 Backup & Restore
Previous Message M S 2007-08-06 13:25:27 Re: Postgres service startup