💾 Chapter 3 :- Relational Database Management System (RDBMS)

📘 Introduction to RDBMS



📘 What is RDBMS?

RDBMS is a software package used to store and retrieve data that is organized in the form of tables (rows and columns).

It conducts searches using values in specific columns.

A Relational Database Model uses a collection of tables to represent both data and the relationships among them. Each table has multiple columns, and each column has a unique name.

🔑 Properties of RDBMS

Property Description
🗃️ Table Format Stores data in tables (relations)
⚙️ Logical Focus User doesn't need to understand physical implementation
📑 System Table Provides info about content & structure
❓ NULL Support Supports NULL values (missing/unknown data)

🧠 RDBMS Terminologies

📋 Relation

A relation is a two-dimensional table used to represent data and relationships.

Relational databases are built using multiple such tables.

Each relation consists of 3 components:

Term Explanation Example
Name The title or identifier of the table Employee Service Relation
Degree Number of columns 3
Cardinality Number of rows 4

👨‍💼 Employee Service Relation Example

Employee Name Designation Year of Experience
Anuj Manager 5
Pramit Supervisor 3
Ritnesh DBA 2.5
Varun Tester 2

Degree: 3 (columns)

Cardinality: 4 (rows)

🧩 Relational Data Integrity

🔐 Integrity Rule 1: Entity Integrity

If an attribute of a table is a prime attribute (unique identifier), it cannot accept null values. In other words, no part of a primary key may be null.

Entity Integrity ensures that each instance of an entity is uniquely identifiable.

🔗 Integrity Rule 2: Referential Integrity

This ensures that a value that appears in one relation (table) for a set of attributes also appears in another relation for a specific set of attributes.

This rule is based on the concept of foreign keys, where the foreign key in one table must match the primary key in another table.

It maintains data consistency across relationships between tables.


📏 Codd’s 12 Rules of RDBMS

These rules were proposed by E.F. Codd in 1970 to define what a true RDBMS should be.

  1. Information Representation: All data must be stored in table format.
  2. Guaranteed Access: Every data item must be addressable using a table name, primary key, and column name.
  3. Systematic Treatment of Null Values: Nulls must be supported for missing or inapplicable data only.
  4. Database Description Rule: The metadata (data dictionary) must also be stored in table form and queryable using SQL.
  5. Comprehensive Data Sub-language Rule: A relational system must support one language for data definition, manipulation, and access control (typically SQL).
  6. View Updating Rule: Views that can theoretically be updated must be updatable in practice.
  7. High-Level Insert, Update, and Delete: Set-level operations must be supported—not just row-by-row operations.
  8. Physical Data Independence: Changes in storage methods should not affect the database structure or applications.
  9. Logical Data Independence: Changes to logical schema (tables) shouldn't affect user views or applications.
  10. The Distribution Rule: The system should work the same way even if the database is distributed across multiple locations.
  11. Non-Subversion Rule: Low-level access should not allow users to bypass integrity constraints.
  12. Integrity Rule: Integrity constraints must be definable and stored in the catalog, not hardcoded in applications.

🔑 KEYS in RDBMS

A key is a data item that exclusively identifies a record in a table.

1. Super Key

A super key is a set of one or more attributes that, combined, uniquely identify an entity in the entity set.

Example: For an Employees entity, the set emp_name + address can be a super key (assuming no two employees share the same name and address).

2. Primary Key

A primary key is a special candidate key that uniquely identifies each record in a table. It must be unique and cannot have null values.

Example: Emp_code can be a primary key for the Employees table.

3. Candidate Key

A candidate key is an attribute or a set of attributes that can uniquely identify a record. Every table may have one or more candidate keys.

4. Composite Key

A composite key (also called a concatenated key) uses more than one attribute to uniquely identify a record in a table.

Example: In situations where no single field is unique, you combine multiple fields to form the primary key.

5. Secondary Key

A secondary key is an attribute or a combination of attributes that are not candidate keys but are used to classify or retrieve data based on specific criteria.

6. Foreign Key

A foreign key is a field in one table that uniquely identifies a row of another table. It creates a relationship between two tables.

In a relational database, the foreign key of a relation may be the primary key of another relation.

Example Tables:

Product Table

Prod_code Prod_name Sup_code
P101 Mouse S001
P102 Keyboard S002

Supplier Table

Sup_code Sup_name
S001 Tech Traders
S002 Smart Supplies

Concept: Sup_code in the Product table is a foreign key referring to Sup_code in the Supplier table, which is a primary key.

Post a Comment

0 Comments