Day 55 – Relational Databases: Tables and Relationships
Class 11 Computer Science – Chapter 6
What is a Relational Database? (Relational Database क्या है?)
A relational database organizes data into tables (called relations) consisting of rows and columns. It uses keys to establish relationships between different tables.
Relational Database डेटा को टेबल्स (जिन्हें रिलेशन कहते हैं) में संगठित करता है जिसमें पंक्तियाँ और स्तंभ होते हैं। यह विभिन्न टेबल्स के बीच संबंध स्थापित करने के लिए कीज का उपयोग करता है।
Key Concepts of Relational Databases (Relational Database के मुख्य सिद्धांत)
- Table: A collection of rows and columns to store data.
टेबल: डेटा को संग्रहीत करने के लिए पंक्तियों और स्तंभों का संग्रह। - Row (Tuple): A single record in a table.
पंक्ति (टपल): टेबल में एकल रिकॉर्ड। - Column (Attribute): A field representing a specific property of the data.
स्तंभ (एट्रिब्यूट): डेटा के किसी विशेष गुण का प्रतिनिधित्व करने वाला फ़ील्ड। - Primary Key: A unique identifier for a row in a table.
प्राइमरी की: टेबल में एक पंक्ति के लिए एक अद्वितीय पहचानकर्ता। - Foreign Key: A column that creates a relationship between two tables.
फॉरेन की: एक कॉलम जो दो टेबल्स के बीच संबंध बनाता है।
Relationships in Relational Databases (Relational Database में संबंध)
There are three main types of relationships:
- One-to-One: A record in one table is related to a single record in another table.
वन-टू-वन: एक टेबल में एक रिकॉर्ड दूसरे टेबल में एकल रिकॉर्ड से संबंधित है। - One-to-Many: A record in one table is related to multiple records in another table.
वन-टू-मैनी: एक टेबल में एक रिकॉर्ड दूसरे टेबल में कई रिकॉर्ड से संबंधित है। - Many-to-Many: Multiple records in one table are related to multiple records in another table.
मैनी-टू-मैनी: एक टेबल में कई रिकॉर्ड दूसरे टेबल में कई रिकॉर्ड से संबंधित हैं।
Examples of Relational Databases (Relational Database के उदाहरण)
Example 1: Employee Table
| EmployeeID | Name | Department | |------------|------------|------------| | 1 | Alice | HR | | 2 | Bob | IT | | 3 | Charlie | Finance |
Example 2: Department Table
| DepartmentID | Department | |--------------|------------| | 101 | HR | | 102 | IT | | 103 | Finance |
One-to-Many Relationship:
The DepartmentID in the Employee Table links to the DepartmentID in the Department Table.
Advantages of Relational Databases (Relational Database के लाभ)
- Organizes data efficiently into structured tables.
डेटा को संरचित टेबल्स में प्रभावी ढंग से व्यवस्थित करता है। - Ensures data integrity and consistency.
डेटा अखंडता और स्थिरता सुनिश्चित करता है। - Supports complex queries and relationships.
जटिल क्वेरीज और संबंधों का समर्थन करता है। - Provides data security and access control.
डेटा सुरक्षा और पहुंच नियंत्रण प्रदान करता है।
Practice Questions
Multiple Choice Questions (MCQs)
- What is a row in a relational database called?
(a) Attribute | (b) Tuple | (c) Column | (d) Key - Which key uniquely identifies a row in a table?
(a) Foreign Key | (b) Primary Key | (c) Candidate Key | (d) None - What is the relationship between two tables called?
(a) Mapping | (b) Relation | (c) Schema | (d) None - Which type of relationship links one record to multiple records in another table?
(a) One-to-One | (b) One-to-Many | (c) Many-to-Many | (d) None - What is the purpose of a foreign key?
(a) To uniquely identify a row | (b) To link two tables | (c) To store data | (d) None - Which of the following is not a type of relationship in a relational database?
(a) One-to-One | (b) One-to-Many | (c) Many-to-Many | (d) None-to-Many - What is a primary key?
(a) A unique identifier | (b) A non-unique identifier | (c) A duplicate row | (d) None - Which SQL command is used to define relationships?
(a) CREATE TABLE | (b) ALTER TABLE | (c) INSERT | (d) None - What is the main purpose of relationships in a database?
(a) To link tables | (b) To delete data | (c) To encrypt data | (d) None - What does a column represent in a table?
(a) A row | (b) An attribute | (c) A tuple | (d) None
Answers to MCQs:
1: (b), 2: (b), 3: (b), 4: (b), 5: (b), 6: (d), 7: (a), 8: (b), 9: (a), 10: (b)
Short Answer Questions
- What is a relational database?
Answer: A database that organizes data into structured tables with rows and columns. - What is the difference between a primary key and a foreign key?
Answer: A primary key uniquely identifies a row, while a foreign key links two tables. - What are the types of relationships in relational databases?
Answer: One-to-One, One-to-Many, Many-to-Many. - Write an example of a one-to-many relationship.
Answer: An employee table linked to a department table. - What is the purpose of relational databases in real-world applications?
Answer: To store, organize, and retrieve data efficiently.
Long Answer Questions
- Explain the concept of relational databases with examples.
- Discuss the types of relationships in relational databases and their uses.
- Write the advantages and disadvantages of relational databases.
Post a Comment