MCQ Sets

  • Mock Ups
    • Computer Operator
      • 73-01
      • 73-02
      • 73-03
      • 73-04
      • 73-05
      • 73-06
    • Assistant Computer Operator
  • Quiz
    • Computer Fundamentals
    • Operating Systems
    • MS Word
    • MS Excel
    • MS PowerPoint
    • MS Access
    • HTML
  • Sets
    • Computer Fundamentals
    • Operating System
    • Microsoft Word
    • MS Excel
    • MS PowerPoint
    • MS Access
    • HTML & Web Page Designing
    • C++
    • Data Structures & Algorithms
  • Read
    • Tips & Articles
    • Fundamentals
    • MS Word
    • DBMS
    • Operating Systems
    • HTML & Web Page Design
  • Videos
  • Ask
    • Ask MCQ Sets
    • Discussion Forum
  • Downloads
  • Old Question Papers

Define relationship between tables in database

January 31, 2016 by Suresh Khanal 2 Comments

Relationship is the most crucial concept in relational database management system (RDBMS). The whole existence of RDBMS is due to the Normalization process and normalization is founded on defining and maintaining relationship between different entities.

First of all, let's think about normalization in brief.​

Speaking very bluntly, normalization is the process of breaking table into smaller ones so as to:

  • Eliminate data redundancy​
  • Enforce data integrity

A normalized database is free from unnecessary copies of same data which helps to improve the data consistency and integrity.

Read first: What is Data Redundancy in Database?

Relashionship

Let's start the discussion with the same table (as we saw in above link) to understand how breaking tables helps to reduce redundancy and improve data consistency. Here is the inventory record of a store.

ID Supplier SupplierAddress Product Quantity Purchased Amt
1001 Mittal Products 308 Milan Street, Corner Stone Alley, Pokhara, Kaski District, Gandaki Zone AR Drone 305 35 45000
1002 Kaveri Traders Jeevan Marga – 01, Kalanki, Kathmandu PK Kaplan 20 200 8000
1003 Mittal Products 308 Milan Street, Corner Stone Alley, Pokhara, Kaski District, Gandaki Zone PK Kaplan 20 200 7500
1004 Nanda Pvt. Ltd. Sundar Galli, Kuleshwor, Kathmandu AR Drone 305 25 3800
1005 Mittal Products 308 Milan Street, Corner Stone Alley, Pokhara, Kaski District, Gandaki Zone Nanda DK S28 10 2000

In above table you are can reduce data repetition if you break this table into two - Stock and Supplier. Following is the table description:

Supplier: supplier_ID, supplier_Name, supplier_Address
Stock: stock_ID, supplier_ID, Product, Quantity, PurchasedAmt

(Underlined fields are primary keys)

Breaking inventory_record table into two tables (supplier & stock) will produce the following result:

Supplier Table

supplier_ID supplier_Name supplier_Address
S001 Mittal Products 308 Milan Street, Corner Stone Alley, Pokhara, Kaski District, Gandaki Zone
S002 Kaveri Traders Jeevan Marga – 01, Kalanki, Kathmandu
S003 Nanda Pvt. Ltd. Sundar Galli, Kuleshwor, Kathmandu

Product Table

ID supplier_ID Product Quantity PurchasedAmt
1001 S001 AR Drone 305 35 45000
1002 S002 PK Kaplan 20 200 8000
1003 S001 PK Kaplan 20 200 7500
1004 S003 AR Drone 305 25 3800
1005 S001 Nanda DK S28 10 2000

You saw how only one entry of that long supplier name and supplier address is sufficient to keep record of every purchase of inventory.

Now because the data about a transaction is distributed between two tables, there should be some mechanism to link these two and retrieve the required supplier when its ID is supplied. Such mechanism in RDBMS is the relationship. To make these two tables work for our future searches and retrieval, we need to create relationship between Supplier table and Produtct table.

What is the relationship between tables in relational databases?

A relationship, in databases, is a situation that exists between two tables that define how records in one table is related to the records in other tables. Practically, we may need to reflect three different kind of relationship, namely:

  • One to one relationship
  • One to many relationship
  • Many to many relationship

One to one relationship

A one-to-one relationship exists between two table if one record in a table can be related to only one or zero records in another table. An example can be a relationship between Employee table and Employee_Fund table if they have fields like below:

Employee: emp_ID, emp_Name, emp_Address, emp_DOB, emp_DOJ
Employee_Fund: epf_ID, epf_Office, epf_totalAmount

It is assumed that emp_ID and epf_ID contain same data. The relationship created between these tables is through emp_ID and epf_ID field which is primary key field in their respective tables.

One to many relationships

One-to-many relationship between two tables is most common type of relationship which exists when one record in first table is related to many or zero records in second table. The relationship between the Supplier and Product table (in our example above) is of one-to-many type because one record in supplier table can be related to many records in Product table. Talking it in more general, we can say one supplier may supply many products and thus one-to-many relationship.

One to many relationship is always created when you link the primary key of a table with non-primary key of another table. Often the relation between a primary key and foreign key results into one-to-many relationship.

Many to many relationship

This type of relationship is very common in real world situation such as one doctor may check many patients and one patient may be attended by many doctors. Similarly, one teacher many students at the same time one student may be taught by many teachers.

Though this is found in many real world situations, creating many-to-many relationship between two database tables is not possible. To reflect many-to-many situation in databases, we create a third table called junction table.

(many) firstTable -> (one) junctionTable -> (many) secondTable

Related: Relationship Types in MS Access Database
Related: Which is not a valid relationship in MS Access?

Filed Under: DBMS Tagged With: combine two tables in access, data integrity, data redundancy, define relationship between tables, link tables in excel 2010, many to many relationship, one to many relationship, one to one relationship, pivot table relationships, relationship between tables, relationship theory tables, table relationship in database, table relationships access

← Database and MS Access Questions

Comments

  1. Chandra Tamang says

    February 6, 2014 at 8:06 am

    What is Normalization? Is it important content for computer operator?

    Reply
    • Suresh Khanal says

      February 1, 2016 at 5:12 am

      Normalization is the process of breaking large tables into multiple so as to reduce data redundancy and maintain data integrity. Candidates of Computer Operators need to have working knowledge of normalization.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

User manuals http://manymanuals.com

Published MCQs for:

  • Computer Fundamentals
  • Operating Systems (Basics)
  • Word Processing (MS Word)
  • Spread Sheet (MS Excel)
  • Presentation (MS PowerPoint)
  • DBMS (MS Access)
  • Webpage Designing (HTML)
  • C++ Programming Language
  • Data Structures & Algorithms

Reading Materials for:

Fundamentals of Computers
► Syllabus of Computer Fundamentals
► Introduction to Computer Fundamentals
► History of Computers
► Computer Generations
► Classification of Computers
► Computer System
► Computer Hardware Concept
► Computer Software Concept
► Computer Networking
► Number System

Recent Posts

  • Computer Networks MCQ Questions and Answers with PDF Download
  • Online Quiz MS PowerPoint
  • Solved Question Paper of PSC for NARC 2074-2-18
  • Computer Basics – Solved Question Paper of MPA 2017 (Spring) – Purbanchal University (PU)
  • A simple protocol used for fetching email from a mail box is

MCQ Sets

  • Home
  • About Us
  • Contact Us
  • Privacy Policy
  • User Testimonials
  • Help MCQ Sets Grow More!
  • RSS Feeds
  • Sitemap

Recent Comments

  • Ajay Rauniyar on Ask MCQ Sets
  • MCQ Questions for MS PowerPoint – Another 100 MCQs » MCQ Sets on Microsoft PowerPoint MCQ Questions – The next 100 MCQs
  • MCQ Questions for MS PowerPoint – Another 100 MCQs » MCQ Sets on MS Office MCQ Questions with Answers [ PowerPoint ] – The first 100 MCQs
  • Suresh Khanal on Solved Question Paper of Computer Operator – Nepal Khadya Sansthan
  • Suresh Khanal on Ask MCQ Sets