2

so i'm still in the design phase of this database. Anyways, every person, whose PK is their name, has a FK to a contact table then I'm very confused as to what's next as every contact table contains a reference to the address table. Person -> Contact -> address Tables contain as follows:

Person:
PK | name
contact info references contact table (?)

contact: 
PK | address(?)
email

Address:
PK | street name (?)

First Question: What would be the PK for my contact table? Second question: What would be the PK for my address table? Would it even have a PK or is it just referenced?

Essentially one person would have one entry into the contact table, then in the contact table it references the address table and I'm just trying to figure out the best way to do that.

0

1 Answer 1

2

Name - can't be considered a good candidate for primary key. Since, it can be duplicate/modified later. In your case, I don't see any natural key which can be used as primary key. Better, you can add/use a surrogate key(Serial No. -autoincrement) as primary key.

For address table: If you are also storing email address. You can create separate columns for email and postal address and make email address as primary key.

To reference Contact Info from Person table - you can use email address as foreign key into person table.

So, schema can be like below:

    Person: 
    S.N. : (Auto Increment) - Primary Key
    name :
    email : Foreign key


    Contact:
    email : Primary key
    Postal address 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.