From: | Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Redefining an existing Table Schema for Foreign Key Constraint - Question |
Date: | 2008-11-03 12:41:52 |
Message-ID: | puy701oub3.fsf@srv.protecting.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
In article <20294223(dot)post(at)talk(dot)nabble(dot)com>,
Brian714 <bndang(at)uci(dot)edu> writes:
> Currently, the database contains thousands of records in the Customers and
> Creditcards tables. I would like to re-define the Customers table to follow
> the following schema:
> Customers Table
> id:integer -- primary key
> first_name:varchar(50)
> last_name:varchar(50)
> cc_id:integer references Creditcards.id
> address:varchar(200)
> email:varchar(50)
> password:varchar(20)
> As you can see, I would like to convert the column that used to be
> "credit_card_number" from the Customers table and turn it into a "cc_id"
> which is an integer that references the column "id" from the table
> Creditcards.
This is the usual 1:n relationship, but I think you got it backwards.
There are two questions to ask:
1. Are there customers with more than one credit card?
2. Are there credit cards owned by more than one customer?
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Butler | 2008-11-03 13:37:06 | Re: Connections getting stuck sending data to client (FIXED) |
Previous Message | Rainer Pruy | 2008-11-03 12:10:48 | Re: Advantage of more than 1 tablespace on 1 disk? |