Relational Database Basics
The fundamental terms used to describe how a relational database is organised.
Relational Database Basics
A Relational Database एक database है जिसमें data को related tables के रूप में व्यवस्थित और store किया जाता है। प्रत्येक table में data rows और columns के रूप में रखा जाता है। Relational database में अलग-अलग tables के बीच relationships स्थापित किए जा सकते हैं।
Relational Database Model को Edgar F. Codd ने 1970 में प्रस्तुत किया था। आज relational databases का उपयोग schools, banks, hospitals, businesses और government systems में बड़े स्तर पर किया जाता है।
What is a Database?
Database related data का एक organized collection है, जिसे आसानी से store, access, manage और update किया जा सकता है।
उदाहरण के लिए किसी school database में students, teachers, classes और marks से संबंधित information store की जा सकती है।
Student Name, Roll Number, Class, Subject और Marks जैसे data को एक database में व्यवस्थित रूप से store किया जा सकता है।
What is a Relational Database?
Relational database में data को tables में store किया जाता है। प्रत्येक table किसी particular entity या विषय से संबंधित information रखती है। Tables के बीच common fields की सहायता से relationship बनाया जा सकता है।
उदाहरण के लिए school database में Student और Marks नाम की दो tables हो सकती हैं। दोनों tables में RollNo field common हो सकती है।
Table, Row and Column
Relational database में table data को rows और columns के रूप में organize करती है।
| RollNo | Name | Class | Marks |
|---|---|---|---|
| 101 | Rahul | 12 | 85 |
| 102 | Priya | 12 | 91 |
| 103 | Aman | 12 | 78 |
ऊपर दिए गए table में:
- Table: Student information का पूरा structure।
- Column: एक particular attribute, जैसे Name या Marks।
- Row: एक complete record, जैसे Rahul की पूरी information।
- Field: Table का एक individual data item।
Important Terms in Relational Database
| Term | Meaning |
|---|---|
| Relation | Relational model में table को relation कहा जाता है। |
| Tuple | Table की एक row को tuple कहा जाता है। |
| Attribute | Table के column को attribute कहा जाता है। |
| Domain | किसी attribute के लिए allowed values का set। |
| Primary Key | ऐसा attribute जो प्रत्येक record को uniquely identify करता है। |
| Foreign Key | एक table का field जो दूसरी table की primary key को refer करता है। |
Relation
Relational database में Relation का अर्थ table से है। इसमें rows और columns के रूप में data store होता है।
Tuple
Table की प्रत्येक row को relational model में Tuple कहा जाता है। एक tuple किसी एक record को represent करता है।
उदाहरण:
यह पूरी row एक tuple है।
Attribute
Table के प्रत्येक column को relational database में Attribute कहा जाता है। Attribute किसी entity की particular property को represent करता है।
उदाहरण के लिए Student table में RollNo, Name, Class और Marks attributes हैं।
Domain
Domain किसी attribute के लिए allowed values का set होता है। उदाहरण के लिए Age attribute का domain positive integer values हो सकता है।
Gender का domain → {Male, Female, Other}
Marks का domain → 0 से 100
Primary Key
Primary Key वह attribute या attributes का combination है जो table के प्रत्येक record को uniquely identify करता है। Primary key की value duplicate नहीं हो सकती और सामान्यतः NULL नहीं होती।
उदाहरण:
| RollNo | Name | Class |
|---|---|---|
| 101 | Rahul | 12 |
| 102 | Priya | 12 |
| 103 | Aman | 12 |
इस table में RollNo primary key हो सकता है क्योंकि प्रत्येक student का RollNo unique है।
Properties of Primary Key
- Primary key प्रत्येक record को uniquely identify करती है।
- इसकी values duplicate नहीं होनी चाहिए।
- Primary key NULL नहीं होनी चाहिए।
- एक table में केवल एक primary key constraint हो सकता है।
- Primary key एक single column या multiple columns से मिलकर बन सकती है।
Foreign Key
Foreign Key एक table का ऐसा attribute है जो दूसरी table की primary key को refer करता है। इसका उपयोग tables के बीच relationship बनाने के लिए किया जाता है।
उदाहरण:
| Student Table | |
|---|---|
| RollNo (Primary Key) | Name |
| 101 | Rahul |
| 102 | Priya |
| Marks Table | ||
|---|---|---|
| MarkID | RollNo (Foreign Key) | Marks |
| 1 | 101 | 85 |
| 2 | 102 | 91 |
यहाँ Marks table का RollNo, Student table के RollNo को reference करता है।
Relationship Between Tables
Relational database की महत्वपूर्ण विशेषता है कि multiple tables के बीच relationships बनाए जा सकते हैं। Common field या key की सहायता से tables को जोड़ा जा सकता है।
उदाहरण:
इस relationship की सहायता से किसी student की personal information और उसके marks को एक साथ retrieve किया जा सकता है।
Types of Relationships
Relational databases में मुख्यतः निम्न प्रकार के relationships पाए जाते हैं:
| Relationship | Meaning | Example |
|---|---|---|
| One-to-One (1:1) | एक record दूसरे table के केवल एक record से related होता है। | Person और Passport |
| One-to-Many (1:N) | एक record दूसरे table के कई records से related हो सकता है। | Teacher और Students |
| Many-to-Many (M:N) | कई records दूसरे table के कई records से related हो सकते हैं। | Students और Subjects |
Relational Database Management System
RDBMS (Relational Database Management System) एक software system है जो relational databases को create, manage, update और query करने की सुविधा देता है।
Common RDBMS के examples हैं:
- MySQL
- Oracle Database
- Microsoft SQL Server
- PostgreSQL
- SQLite
SQL and Relational Database
SQL (Structured Query Language) का उपयोग relational databases के साथ data को create, retrieve, update और delete करने के लिए किया जाता है।
उदाहरण के लिए किसी Student table से सभी records प्राप्त करने के लिए:
SELECT * FROM Student;
101 | Rahul | 12 | 85
102 | Priya | 12 | 91
103 | Aman | 12 | 78
Creating a Simple Table
SQL की सहायता से relational database में table create किया जा सकता है।
CREATE TABLE Student
(
RollNo INT PRIMARY KEY,
Name VARCHAR(50),
Class INT,
Marks INT
);
Table Student created successfully.
Inserting Data into a Table
INSERT statement का उपयोग table में नया record add करने के लिए किया जाता है।
INSERT INTO Student
VALUES (101, 'Rahul', 12, 85);
1 row inserted successfully.
Retrieving Data
SELECT statement का उपयोग database से data प्राप्त करने के लिए किया जाता है।
SELECT Name, Marks
FROM Student;
Rahul | 85
Priya | 91
Aman | 78
Updating Data
UPDATE statement का उपयोग existing record को modify करने के लिए किया जाता है।
UPDATE Student
SET Marks = 90
WHERE RollNo = 101;
1 row updated successfully.
Deleting Data
DELETE statement का उपयोग table से records हटाने के लिए किया जाता है।
DELETE FROM Student
WHERE RollNo = 101;
1 row deleted successfully.
Advantages of Relational Database
- Data को tables के रूप में व्यवस्थित करना आसान होता है।
- Tables के बीच relationships बनाए जा सकते हैं।
- Data duplication को कम किया जा सकता है।
- SQL की सहायता से data को आसानी से query किया जा सकता है।
- Data integrity को maintain किया जा सकता है।
- Large amounts of structured data को manage किया जा सकता है।
- Security और access control की सुविधाएँ उपलब्ध होती हैं।
- Data को insert, update और delete करना आसान होता है।
Limitations of Relational Database
- बहुत बड़े और highly unstructured data के लिए relational model हमेशा सबसे उपयुक्त नहीं होता।
- Complex relationships के कारण database design कठिन हो सकता है।
- Large-scale systems में database structure को maintain करने के लिए अधिक planning की आवश्यकता होती है।
- Tables के बीच complex joins queries को computationally expensive बना सकते हैं।
Relational Database vs Traditional File System
| Feature | File System | Relational Database |
|---|---|---|
| Data Organization | Files में | Tables में |
| Relationships | सीमित | आसानी से establish किए जा सकते हैं |
| Querying | सीमित | SQL द्वारा आसान |
| Data Integrity | कम control | Constraints द्वारा बेहतर control |
| Redundancy | अधिक हो सकती है | Design के द्वारा कम की जा सकती है |
Important Concepts
- Database: Organized collection of related data.
- Relational Database: Tables में related data store करने वाला database.
- Relation: Table.
- Tuple: Row या record.
- Attribute: Column.
- Domain: Attribute की allowed values का set.
- Primary Key: Record को uniquely identify करने वाली key.
- Foreign Key: दूसरी table की primary key को reference करने वाली key.
- RDBMS: Relational database को manage करने वाला software.
- SQL: Relational database के साथ काम करने की standard language.
Board Focus
Relation → Table
Tuple → Row
Attribute → Column
Domain → Allowed Set of Values
Primary Key → Uniquely identifies a record
Foreign Key → References another table's primary key
RDBMS → Relational Database Management System
SQL → Structured Query Language
1:1 → One-to-One
1:N → One-to-Many
M:N → Many-to-Many
Board Important Questions
Very Short Answer Questions
Q1. Relational database क्या है?
Answer: ऐसा database जिसमें data को related tables के रूप में store किया जाता है, relational database कहलाता है।
Q2. Relational database model किसने प्रस्तुत किया था?
Answer: Edgar F. Codd ने।
Q3. Relation क्या है?
Answer: Relational model में table को relation कहा जाता है।
Q4. Tuple क्या है?
Answer: Table की एक row को tuple कहा जाता है।
Q5. Attribute क्या है?
Answer: Table के column को attribute कहा जाता है।
Q6. Primary Key क्या है?
Answer: वह key जो table के प्रत्येक record को uniquely identify करती है, primary key कहलाती है।
Q7. Foreign Key क्या है?
Answer: वह field जो दूसरी table की primary key को reference करती है, foreign key कहलाती है।
Q8. SQL का full form क्या है?
Answer: Structured Query Language.
Q9. RDBMS का full form क्या है?
Answer: Relational Database Management System.
Q10. किसी एक RDBMS का नाम लिखिए।
Answer: MySQL.
Short Answer Questions
Q11. Primary Key और Foreign Key में अंतर बताइए।
Answer: Primary Key table के प्रत्येक record को uniquely identify करती है। Foreign Key एक table में दूसरी table की primary key को reference करती है और tables के बीच relationship स्थापित करने में मदद करती है।
Q12. Tuple और Attribute में अंतर बताइए।
Answer: Tuple table की एक row या record होता है, जबकि Attribute table का एक column होता है।
Q13. Relational database में table का क्या महत्व है?
Answer: Table relational database में data को rows और columns के रूप में व्यवस्थित करके store करती है।
Q14. Foreign Key का उपयोग क्यों किया जाता है?
Answer: Foreign Key का उपयोग tables के बीच relationship establish करने और related records को connect करने के लिए किया जाता है।
Q15. RDBMS क्या है?
Answer: RDBMS ऐसा software है जो relational databases को create, manage, update और query करने की सुविधा देता है।
Long Answer Questions
Q16. Relational database के मुख्य components को समझाइए।
Answer: Relational database में data tables में store किया जाता है। Table की row को tuple और column को attribute कहा जाता है। प्रत्येक attribute का एक domain होता है। Primary Key records को uniquely identify करती है और Foreign Key tables के बीच relationships establish करती है।
Q17. Primary Key और Foreign Key को उदाहरण सहित समझाइए।
Answer: Primary Key table के प्रत्येक record की unique पहचान करती है। उदाहरण के लिए Student table में RollNo primary key हो सकता है। Foreign Key दूसरी table में किसी related table की primary key को reference करती है। उदाहरण के लिए Marks table में RollNo, Student table के RollNo को foreign key के रूप में reference कर सकता है।
Q18. Relational database के advantages लिखिए।
Answer: Relational database data को structured tables में store करता है, tables के बीच relationships बनाने देता है, SQL द्वारा आसान querying प्रदान करता है, data integrity maintain करता है और data redundancy को कम करने में सहायता करता है।
Q19. Relational database में SQL का क्या महत्व है?
Answer: SQL का उपयोग relational database में tables create करने, data insert करने, records retrieve करने, existing data update करने और records delete करने के लिए किया जाता है।
Practice Questions
- Database और Relational Database में अंतर बताइए।
- Relational Database Model किसने प्रस्तुत किया?
- Relation, Tuple और Attribute को समझाइए।
- Domain क्या है? उदाहरण दीजिए।
- Primary Key क्या है? इसकी विशेषताएँ लिखिए।
- Foreign Key क्या है? इसका उपयोग क्यों किया जाता है?
- Primary Key और Foreign Key में अंतर लिखिए।
- Relational database में tables के बीच relationship कैसे establish किया जाता है?
- One-to-One, One-to-Many और Many-to-Many relationships को उदाहरण सहित समझाइए।
- RDBMS क्या है? इसके कोई चार examples लिखिए।
- SQL का full form लिखिए और इसके उपयोग बताइए।
- Student नाम की table create करने के लिए SQL statement लिखिए।
- Table में record insert करने के लिए SQL statement लिखिए।
- SELECT statement का उपयोग उदाहरण सहित समझाइए।
- UPDATE और DELETE statements का उपयोग समझाइए।
- Relational database के advantages और limitations लिखिए।
- Relational Database और File System में अंतर लिखिए।
Quick Revision
- Relational Database: Related tables में data store करता है।
- Relation: Table
- Tuple: Row / Record
- Attribute: Column
- Domain: Allowed values का set
- Primary Key: Unique identification
- Foreign Key: दूसरी table की primary key को reference करती है
- RDBMS: Relational Database Management System
- SQL: Structured Query Language
- 1:1: One-to-One
- 1:N: One-to-Many
- M:N: Many-to-Many