Bushra Khan
Bushra Khan

Reputation: 31

relationships one to one

I hope you can help me with this. I am trying to develop an online admission system in php/mysql. I have so far created two tables:

1- Member (memberid (auto increment), username, email, password, activation) 2- personal_details (Nationality, Religion, Passport No, Place of Birth, Date of Birth)

I split the data into two tables to reduce the load on tables. Can you please tell me how do we define one-one relationship in such cases. Thanks

Upvotes: 0

Views: 34

Answers (1)

Dave Markle
Dave Markle

Reputation: 97841

You would put a memberid column on each table with a regular foreign key relationship. The only difference is that you should put a UNIQUE constraint or PRIMARY KEY constraint on both tables.

It's that uniqueness constraint that changes the relationship from a 1:N to a 1:1 relationship.

Upvotes: 2

Related Questions