MySQL + SQL · Lesson 5
DBMS Tutorial
DBMS क्या है?
DBMS (Database Management System) एक software system है जो users को database define, create, maintain और control करने की सुविधा देता है। यह user/application और disk पर stored data के बीच interface का काम करता है।
DBMS के बिना data flat files में होता है — कोई structure नहीं, कोई security नहीं, कोई sharing नहीं।
Popular DBMS: MySQL, Oracle, Microsoft SQL Server, PostgreSQL, SQLite, MongoDB.
Real analogy: DBMS एक librarian की तरह है। Library (database) में हज़ारों books (data) हैं। Librarian (DBMS) जानता है हर book कहाँ है, कौन ले सकता है, issued books track करता है।
DBMS के Components
| Component | Role |
|---|---|
| Hardware | Physical devices — server, hard disk, RAM |
| Software | DBMS software (MySQL) + OS + application programs |
| Data | Actual data + metadata (structure की information) |
| Procedures | Database use करने के rules और instructions |
| Users | DBA, End Users, Application Programmers |
| Query Language | SQL — database से interact करने के लिए |
DBMS के Functions
- Data Definition: Tables, columns, constraints बनाना और modify करना (DDL: CREATE, ALTER, DROP)।
- Data Manipulation: Data insert, update, delete और retrieve करना (DML: INSERT, UPDATE, DELETE, SELECT)।
- Data Security: GRANT और REVOKE से control — कौन क्या access कर सकता है।
- Data Integrity: PRIMARY KEY, FOREIGN KEY, CHECK constraints से data सही रखना।
- Concurrency Control: Multiple users को एक साथ काम करने देना — locks और transactions से।
- Transaction Management: ACID properties ensure करना।
DBMS के Types
| Type | Structure | Example |
|---|---|---|
| Hierarchical | Tree structure (parent-child)। Fast लेकिन rigid। | IBM IMS — पुराने banking systems |
| Network | Graph structure — pointers से records linked। | IDMS |
| Relational (RDBMS) | Tables (rows और columns)। Keys से linked। SQL use। | MySQL, Oracle, PostgreSQL |
| Object-Oriented | Data objects के रूप में store। | db4o, ObjectDB |
| NoSQL | Non-relational। Documents, key-value, graph। | MongoDB, Redis, Cassandra |
Class 12 और college के लिए: RDBMS पर focus करें — MySQL standard example है।
RDBMS क्या है?
RDBMS (Relational DBMS) में data tables (relations) में organize होता है। Tables primary keys और foreign keys से linked होती हैं। सभी operations SQL से होते हैं।
| Feature | DBMS | RDBMS |
|---|---|---|
| Data Storage | Files या tables (related नहीं ज़रूरी) | हमेशा related tables |
| Relationships | Mandatory नहीं | Central concept — foreign key |
| Query Language | Vary कर सकती है | हमेशा SQL |
| Examples | MS Access (basic) | MySQL, Oracle, PostgreSQL |
SQL Demo
-- DDL: Structure बनाना
CREATE DATABASE school_db;
CREATE TABLE students (roll_no INT PRIMARY KEY, name VARCHAR(80) NOT NULL);
-- DML: Data add/update करना
INSERT INTO students VALUES (1, 'Aarav Sharma');
UPDATE students SET name = 'Aarav Kumar' WHERE roll_no = 1;
SELECT * FROM students;
-- DCL: Security
GRANT SELECT ON school_db.students TO 'teacher'@'localhost';
-- TCL: Transaction
START TRANSACTION;
INSERT INTO students VALUES (2, 'Priya Verma');
COMMIT; -- permanent save
Common Mistakes
- Database और DBMS confuse करना: MySQL = DBMS (software); school_db = Database (data)।
- सभी DBMS को RDBMS मानना: MongoDB DBMS है लेकिन RDBMS नहीं।
- DBMS features को ignore करना: Transactions, constraints, user privileges use न करना DBMS का पूरा फायदा नहीं लेना।
Practice Tasks
- DBMS components का diagram बनाएं — arrows से interactions दिखाएं।
- SQL demo से school_db बनाएं। Teacher user को SELECT-only access दें। INSERT try करें — error note करें।
- Library database के लिए DDL, DML, DCL, TCL के examples लिखें।
- Viva: "DBMS और RDBMS में 4 अंतर।"
Summary
- DBMS = database create, manage, control और access करने का software।
- Components: Hardware, Software, Data, Procedures, Users, Query Language।
- Functions: Data Definition, Manipulation, Security, Integrity, Concurrency, Backup, Transactions।
- Types: Hierarchical, Network, Relational, Object-Oriented, NoSQL।
- RDBMS सबसे important — MySQL, Oracle tables + SQL + keys use करते हैं।
💻 लाइव कोड एडिटर
इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.