Re: Redefining an existing Table Schema for Foreign Key Constraint - Question - Mailing list pgsql-general

From Harald Fuchs
Subject Re: Redefining an existing Table Schema for Foreign Key Constraint - Question
Date
Msg-id pumygbmqb6.fsf@srv.protecting.net
Whole thread Raw
In response to Redefining an existing Table Schema for Foreign Key Constraint - Question  (Brian714 <bndang@uci.edu>)
List pgsql-general
In article <20081106213736.GB25016@tamay-dogan.net>,
Michelle Konzack <linux4michelle@tamay-dogan.net> writes:

> Hallo Harald,
> Am 2008-11-03 13:41:52, schrieb Harald Fuchs:
>> In article <20294223.post@talk.nabble.com>,
>> Brian714 <bndang@uci.edu> writes:
>> > 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)
>> 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?

> This could be a problem for the above table...

>> 2. Are there credit cards owned by more than one customer?

> CreditCards are personaly and sometimes (in France) I need an ID card to
> prove, that I am the holder...

> So how can one credit card can have more then one owner?

That's exactly why I told you "I think you got it backwards".
You need a cust_id column in your CreditCards table, not a cc_id
column in your Customers table.

pgsql-general by date:

Previous
From: Sam Mason
Date:
Subject: Re: Importing text file into a TEXT field
Next
From: "Scott Marlowe"
Date:
Subject: Re: How to design a "customer" TABLE which hold credit card infos and other payments?