Relational Database क्या है? RDBMS और SQL पूरी जानकारी हिंदी में
A Relational Data Model stores data in the form of tables (relations). Each table consists of rows (tuples) and columns (attributes).
Definition
Relational Data Model एक ऐसा Database Model है जिसमें Data को Table (Relation) के रूप में Store किया जाता है।
हर Table में:
- Rows (Records/Tuples) होते हैं।
- Columns (Attributes) होते हैं।
Real-Life Example
Imagine a School Database.
Instead of storing all information in one large file, we organize it into tables.
Student Table
| StudentID | Name | Age | Department |
|---|---|---|---|
| 101 | Rahul | 20 | CSE |
| 102 | Aman | 21 | IT |
| 103 | Priya | 20 | ECE |
Course Table
| CourseID | CourseName |
|---|---|
| C101 | DBMS |
| C102 | Operating System |
| C103 | Computer Networks |
Enrollment Table
| StudentID | CourseID |
|---|---|
| 101 | C101 |
| 101 | C102 |
| 102 | C101 |
Notice that we don't repeat the student's full information in every row. Instead, we use StudentID and CourseID to create relationships.
Why Use the Relational Model?
Without a relational model:
❌ Duplicate data
❌ Difficult searching
❌ Hard maintenance
❌ Data inconsistency
With a relational model:
✔ Organized data
✔ Easy SQL queries
✔ Less redundancy
✔ Better security
✔ Data integrity
✔ Easy relationships
Main Components of the Relational Model
Relational Model
│
┌───────────┼────────────┐
│ │ │
Relation Attribute Tuple
│ │ │
Domain Keys Constraints
Relation (Table)
A Relation is a table in a relational database.
Each relation has:
- Table Name
- Columns
- Rows
Example
Student
| StudentID | Name | Age |
|---|---|---|
| 101 | Rahul | 20 |
| 102 | Aman | 21 |
| 103 | Priya | 19 |
Here:
- Relation = Student Table
Properties of a Relation
A relation follows these rules:
1. Unique Table Name
Every table must have a unique name.
✔ Student
✔ Employee
2. Unique Column Names
No duplicate attribute names.
✔ Name
✔ Age
❌ Age, Age
3. No Duplicate Rows
Every record must be unique.
4. Order Doesn't Matter
Changing row order doesn't change the table.
Original:
| StudentID | Name |
|---|---|
| 101 | Rahul |
| 102 | Aman |
Reordered:
| StudentID | Name |
|---|---|
| 102 | Aman |
| 101 | Rahul |
Both represent the same relation.
5. Atomic Values
Each cell contains only one value.
✔ Phone = 9876543210
❌ Phone = 9876543210, 9988776655
Multiple values should be stored in a separate related table.
Tuple (Row / Record)
A Tuple is a single row in a relation.
Example
| StudentID | Name | Age |
|---|---|---|
| 101 | Rahul | 20 |
This entire row is one Tuple.
Attribute (Column)
An Attribute is a column in a table.
Example
|StudentID|Name|Age|
Attributes are:
- StudentID
- Name
- Age
Domain
A Domain is the set of valid values that an attribute can contain.
Example
Attribute: Age
Valid Domain:
18–60
If someone enters:
Age = 250
❌ Invalid (outside the defined domain)
Another example:
Gender
Allowed values:
Male
Female
Other
The domain restricts invalid data.
Degree of a Relation
The Degree is the number of attributes (columns) in a table.
Example
|StudentID|Name|Age|Department|
Number of columns = 4
Degree = 4
Cardinality of a Relation
The Cardinality is the number of tuples (rows) in a table.
Example
| StudentID | Name |
|---|---|
| 101 | Rahul |
| 102 | Aman |
| 103 | Priya |
| 104 | Neha |
Rows = 4
Cardinality = 4
Degree vs Cardinality
| Degree | Cardinality |
|---|---|
| Number of Columns | Number of Rows |
| Usually fixed | Changes as records are inserted or deleted |
Schema
A Schema is the logical structure or design of a database.
It describes:
- Table names
- Columns
- Data types
- Relationships
- Constraints
Example
Student(
StudentID INT,
Name VARCHAR(50),
Age INT,
Department VARCHAR(20)
)
This is the Schema.
Database Schema
College Database
│
├── Student
├── Teacher
├── Course
└── Enrollment
This overall design is the database schema.
Instance
An Instance is the actual data stored in the database at a specific time.
Schema vs Instance
Schema:
Student(
StudentID,
Name,
Age
)
Instance:
| StudentID | Name | Age |
|---|---|---|
| 101 | Rahul | 20 |
| 102 | Aman | 21 |
The schema remains mostly unchanged, while the instance changes as data is added, updated, or deleted.
Schema vs Instance
| Schema | Instance |
|---|---|
| Structure | Actual Data |
| Changes rarely | Changes frequently |
| Blueprint | Current content |
Null Value
A NULL means that the value is unknown, unavailable, or not applicable.
Example
| StudentID | Name | Phone |
|---|---|---|
| 101 | Rahul | 9876543210 |
| 102 | Aman | NULL |
NULL does not mean:
- Zero (0)
- Empty string ("")
- False
It simply means the value is missing or unknown.
Relational Constraints
Constraints ensure that data remains accurate and consistent.
There are four main constraints.
1. Domain Constraint
Ensures values belong to the defined domain.
Example:
Age must be between 18 and 60.
2. Key Constraint
Primary Key values must be unique.
Example:
| StudentID | Name |
|---|---|
| 101 | Rahul |
| 101 | Aman |
3. Entity Integrity Constraint
A Primary Key:
- Cannot be NULL
- Must be unique
Example:
| StudentID | Name |
|---|---|
| NULL | Rahul |
4. Referential Integrity Constraint
A Foreign Key value must exist in the referenced table.
Student
| StudentID | Name |
|---|---|
| 101 | Rahul |
Enrollment
| StudentID | CourseID |
|---|---|
| 101 | C101 |
| 999 | C101 |
Advantages of the Relational Model
-
Easy to understand.
- Table-based structure.
- Supports SQL.
- Reduces redundancy.
- Strong data integrity.
- Better security.
- Easy maintenance.
- Flexible design.
Disadvantages
- Large joins can affect performance.
- Not ideal for some highly complex or graph-like relationships.
- Proper normalization is required for good design.
Example
Employee Table
| EmpID | Name | Department | Salary |
|---|---|---|---|
| E101 | Rahul | IT | 50000 |
| E102 | Aman | HR | 45000 |
| E103 | Neha | Finance | 60000 |
Analysis:
- Relation → Employee
- Attributes → EmpID, Name, Department, Salary
- Tuple → Any single row
- Degree → 4
- Cardinality → 3
- Domain → Salary must be a valid number
- Primary Key → EmpID
💬 Leave a Comment & Rating