1. Introduction to Relational Database
A Relational Database is a type of database that stores data in a structured format using tables (relations). It follows the Relational Model, which organizes data into rows and columns, making it easy to access and manipulate using Structured Query Language (SQL).
🔹 Introduced by: Dr. E.F. Codd (1970)
🔹 Used in: MySQL, PostgreSQL, Oracle, SQL Server
🔹 Key Concept: Data is stored in tables (relations) with rows (tuples) and columns (attributes).
2. Key Components of a Relational Database
1️⃣ Table (Relation)
A table represents a relation in a relational database.
- It consists of rows (tuples) and columns (attributes).
- Each table stores data about a specific entity.
🔹 Example Table: Student
Student_ID (PK) | Name | Age | Course |
---|---|---|---|
101 | Alice | 22 | Computer Science |
102 | Bob | 21 | Mathematics |
103 | Charlie | 23 | Physics |
2️⃣ Row (Tuple)
- A row represents a single record in a table.
- Example:
(101, Alice, 22, Computer Science)
is one tuple in the Student table.
3️⃣ Column (Attribute)
- A column represents a property or characteristic of an entity.
- Example:
Student_ID
,Name
,Age
, andCourse
are attributes of theStudent
entity.
4️⃣ Primary Key (PK)
- A Primary Key is a unique identifier for each record in a table.
- It ensures no duplicate values in that column.
- Example:
Student_ID
is the Primary Key in theStudent
table.
5️⃣ Foreign Key (FK)
- A Foreign Key is an attribute that establishes a relationship between two tables.
- It refers to the Primary Key in another table.
🔹 Example: Course Table (Related to Student Table)
Course_ID (PK) | Course_Name |
---|---|
CSE101 | Computer Science |
MTH102 | Mathematics |
Here, in the Student table, Course
is a Foreign Key referring to Course_ID
in the Course
table.
3. Features of Relational Databases
✅ Data is stored in tables (relations).
✅ Uses Primary & Foreign Keys for relationships.
✅ Supports SQL for querying and manipulation.
✅ Ensures Data Integrity & Consistency using constraints.
✅ Reduces Data Redundancy by normalizing tables.
4. Relationships in a Relational Database
There are three types of relationships in a relational database:
1️⃣ One-to-One (1:1)
- Each record in Table A is linked to one record in Table B.
- Example:
Student
has oneID_Card
.
2️⃣ One-to-Many (1:M)
- A record in Table A can be linked to multiple records in Table B.
- Example: One
Teacher
can teach multipleStudents
.
3️⃣ Many-to-Many (M:N)
- Many records in Table A can be linked to many records in Table B.
- Example: Students can enroll in multiple Courses, and Courses have multiple Students.
🔹 Solution: We create a junction table (Enrollment) to manage the relationship.
Student_ID (FK) | Course_ID (FK) |
---|---|
101 | CSE101 |
101 | MTH102 |
5. Advantages of Relational Databases
✅ Easy to Use → Tables and SQL make it simple.
✅ Data Integrity & Accuracy → Constraints ensure valid data.
✅ Flexibility → Data can be easily modified and queried.
✅ Security → Supports user authentication and access control.
✅ Scalability → Can handle large amounts of data efficiently.
6. Disadvantages of Relational Databases
❌ Performance Issues → Complex joins slow down large queries.
❌ Complex Structure → Requires proper design for efficiency.
❌ Hardware Cost → Requires good storage and computing power.
7. Real-World Applications of Relational Databases
📌 Banking Systems → Accounts, Transactions, Loans
📌 E-commerce Platforms → Users, Orders, Products
📌 University Database → Students, Courses, Enrollment
📌 Social Media Platforms → Users, Posts, Comments
📌 Healthcare Systems → Patients, Doctors, Appointments
8. Conclusion
A Relational Database is the most widely used database model today due to its structured format, efficiency, and reliability. It provides powerful querying capabilities using SQL, making it the preferred choice for business, finance, education, and more.