You are currently viewing A Good Database Relationship ? | Primary Key vs Foreign Key
Microsoft Access Training Courses

A Good Database Relationship ? | Primary Key vs Foreign Key

Database relationship associated between two or more tables the table are created with join statement to retrieve the data two are more table which are relates with primary key and foreign key.  Each primary key have one or more record in child table.

To create a good Database Management System (DBMS) you understand first  database relationship between tables and also be aware about primary key and foreign key. Without creating entity  you can’t create a good  database .

Key Features :

  • save the time of developer when he make the one to many relation and many to many relation.
  • Developer can make a singly query to delete the primary key record its will also affected to the foreign key table record.
  • Developer can easy make select query use the both table.
  • User can’t insert data without save record in primary.
  • Delete the multiple table at once.
  • The system show prompt when if user forgot to insert record in secondary table. 
  • A primary key table can’t accept null value.

Types of Database Relationships:

  • One to one relationship: In one to one relationship both table have one record in save data table. And the record not related to any other table. Its mean the primary table have not any childern.
  • One to many : In one to many relationship primary key table have one unique record and in other child table have on or many record with foreign key.This relation is similarly like your family have one month and your mother have many children. 
  • Mayan to many : In many to many database relationship each record have one record or no record. In this primary table are linked in third table.
Database Relationship

Primary Key VS  Foreign Key How It Works?

Primary Key:

Primary key is that key in database table relationship which is a unique record in you can insert only one unique value and its can’t be null. You can choose the primary key with auto number or auto increment. when You assign the primary key in any database table column then this key can’t be created duplicated record with the same number or text value. In the above picture diagram in student-profile table the primary key is studentid assign with key sign in left side.

Foreign Key (FK):

Foreign Key is that key when you have many record with same primary key in secondary table . The two table are relates each other primary table and other table . The primary key table have one record with assign a unique value and FK table have many record against primary table key value.


Database Relationship

Database Documents Structure:

Following are the Database Relationship structure example which show of One to Many relationship.


tbl_calss has a primary key table which have following three column or fields.

  • ClassID -> Primary Key
  • Class Name 
  • DateModify


tbl_student_profile has a FK key table which have following column or fields.

  • StudentID   -> Primary Key
  • Fist_Name
  • Last_Name
  • DOB
  • Enrolment Date
  • Class    -> FK


In Database Relationship you can make one or more primary key in a single data table .i.e number or name.

Database Relationship

In the above diagram we choose the two primary key one is studentid and second is fisrst_name and these two field will never be duplicate in the primary key table.


Useful Link:

Data Type Tutorial DBMS

How to create a table in MS Access


This Post Has One Comment

  1. m razaq

    what is fk and pk?

Comments are closed.