Computer Science

Relational Data Model Class 12 CBSE (083): Relation, Attribute, Tuple, Domain, Degree, Cardinality & Keys

Class 12 · Computer Science

Relational Data Model (CBSE Class 12 Computer Science - 083)

The Relational Data Model is one of the most widely used models for organizing and managing data in a database. Proposed by Dr. E. F. Codd in 1970, this model stores data in the form of tables (called relations). Each table consists of rows and columns that represent records and attributes respectively.

Learning Objectives

  • Understand the Relational Data Model.
  • Learn the concepts of Relation, Attribute, Tuple, Domain, Degree, and Cardinality.
  • Understand different types of keys used in relational databases.
  • Differentiate between Candidate Key, Primary Key, Alternate Key, and Foreign Key.
  • Interpret database tables using relational terminology.

What is a Relational Data Model?

The Relational Data Model organizes data into one or more tables called relations. Each table stores information about a particular entity, and relationships between tables are established using keys.

Definition: The Relational Data Model is a database model in which data is organized into tables (relations) consisting of rows and columns.

Example of a Relation

StudentID Name Class Marks
101 Riya XII-A 95
102 Aman XII-A 89
103 Priya XII-B 92

The above table will be used to understand all relational database concepts.


1. Relation

A Relation is a table in a relational database. It consists of rows and columns that store related information.

Example: The Student table shown above is a relation.


2. Attribute

An Attribute is a column in a relation. It describes a property or characteristic of an entity.

Attributes in the Student Relation

  • StudentID
  • Name
  • Class
  • Marks
Remember: Attribute = Column

3. Tuple

A Tuple is a row or record in a relation. Each tuple represents a single entity.

Example

101 Riya XII-A 95

The above row is one tuple representing one student.

Remember: Tuple = Row = Record

4. Domain

A Domain is the set of all possible valid values that an attribute can have.

Examples

Attribute Possible Domain
StudentID Positive Integers
Name Alphabetic Characters
Marks 0 to 100
Class XII-A, XII-B, XII-C ...

5. Degree

The Degree of a relation is the total number of attributes (columns) present in the table.

Example

The Student table has the following attributes:

  • StudentID
  • Name
  • Class
  • Marks

Degree = 4


6. Cardinality

The Cardinality of a relation is the total number of tuples (rows or records) present in the table.

Example

The Student table contains three records.

Cardinality = 3


Difference Between Degree and Cardinality

Degree Cardinality
Number of columns. Number of rows.
Represents attributes. Represents records.
Usually changes rarely. Changes whenever records are added or deleted.

Keys in a Relational Database

A Key is an attribute or a combination of attributes used to uniquely identify records in a table and establish relationships between tables.


1. Candidate Key

A Candidate Key is an attribute or a set of attributes that can uniquely identify each record in a table.

Characteristics

  • Must contain unique values.
  • Cannot contain NULL values.
  • There can be multiple candidate keys in a table.

Example

StudentID AdmissionNo Name
101 A001 Riya

Both StudentID and AdmissionNo can uniquely identify a student, so both are Candidate Keys.


2. Primary Key

A Primary Key is the Candidate Key selected to uniquely identify each record in a table.

Characteristics

  • Unique for every record.
  • Cannot contain NULL values.
  • Only one Primary Key can exist in a table.

Example

If StudentID is selected from the Candidate Keys, then it becomes the Primary Key.


3. Alternate Key

An Alternate Key is a Candidate Key that is not selected as the Primary Key.

Example

If StudentID is chosen as the Primary Key, then AdmissionNo becomes the Alternate Key.


4. Foreign Key

A Foreign Key is an attribute in one table that refers to the Primary Key of another table. It establishes a relationship between two tables.

Example

Student Table
StudentID (PK) Name
101 Riya
102 Aman

Fee Table
ReceiptNo StudentID (FK) Amount
5001 101 15000
5002 102 15000

Here, StudentID in the Fee table is a Foreign Key because it refers to the Primary Key of the Student table.


Comparison of Different Keys

Key Purpose
Candidate Key Can uniquely identify each record.
Primary Key Selected Candidate Key used to uniquely identify records.
Alternate Key Candidate Key not selected as the Primary Key.
Foreign Key Creates relationships between tables.

Common Theory Mistakes

  • Confusing a Relation with a Tuple.
  • Confusing Degree with Cardinality.
  • Thinking every Candidate Key is a Primary Key.
  • Assuming a Foreign Key must always contain unique values.
  • Confusing Attributes (columns) with Tuples (rows).

Exam Tips

  • Remember: Relation = Table.
  • Attribute = Column.
  • Tuple = Row (Record).
  • Degree = Number of Columns.
  • Cardinality = Number of Rows.
  • A table can have multiple Candidate Keys but only one Primary Key.
  • A Foreign Key refers to the Primary Key of another table.

Frequently Asked Questions (FAQs)

1. What is a Relation?

A Relation is a table in a relational database that stores related data in rows and columns.

2. What is the difference between Degree and Cardinality?

Degree is the number of attributes (columns), whereas Cardinality is the number of tuples (rows) in a relation.

3. What is a Candidate Key?

A Candidate Key is an attribute or set of attributes that can uniquely identify each record in a table.

4. What is a Primary Key?

A Primary Key is the Candidate Key selected to uniquely identify each record in a table. It cannot contain duplicate or NULL values.

5. What is a Foreign Key?

A Foreign Key is an attribute in one table that refers to the Primary Key of another table and establishes a relationship between the two tables.


Summary

  • The Relational Data Model organizes data into tables called relations.
  • A Relation consists of Attributes (columns) and Tuples (rows).
  • A Domain specifies the valid values for an attribute.
  • Degree represents the number of columns, while Cardinality represents the number of rows.
  • Keys uniquely identify records and establish relationships between tables.
  • Candidate Keys uniquely identify records, one of which is selected as the Primary Key.
  • Alternate Keys are Candidate Keys not chosen as the Primary Key.
  • Foreign Keys connect related tables by referring to the Primary Key of another table.