छोटो उत्तर — Quick answer
Database भनेको सम्बन्धित डेटाको व्यवस्थित सङ्ग्रह हो, र DBMS (Database Management System) भनेको त्यो डेटाबेस बनाउन, डेटा राख्न, खोज्न, बदल्न र सुरक्षित राख्न प्रयोग हुने सफ्टवेयर हो। MySQL, Oracle, MS Access र PostgreSQL सबै DBMS हुन् — डेटाबेस होइनन्।
Exam line: A database is an organised collection of logically related data, and a DBMS is the software that allows users to create, store, retrieve, update and control access to that database.
यो पाना NEB कक्षा १२ कम्प्युटर विज्ञान (Com. 428) को Unit 1: Database Management System को पूरा नोट हो — नेपाली र अंग्रेजी दुवैमा। हरेक अवधारणा पहिले नेपालीमा बुझाइएको छ, त्यसपछि परीक्षामा लेख्नुपर्ने ठ्याक्कै अंग्रेजी वाक्य दिइएको छ।
Unit 1 का तथ्यहरू — key facts
| कुरा | विवरण |
|---|---|
| विषय | Computer Science, Grade 12 |
| विषय संकेत (subject code) | Com. 428 (कक्षा ११ को Com. 427; हालका NEB प्रश्नपत्रमा 4281 छापिन्छ) |
| Unit | Unit 1 — Database Management System |
| शिक्षण घण्टा (teaching hours) | 12 घण्टा, जम्मा 80 घण्टाको पाठ्यक्रममा |
| सबैभन्दा ठूलो unit | Unit 2 (Data Communication & Networking) — 15 घण्टा |
| लिखित बोर्ड परीक्षा | 50 पूर्णाङ्क (75 होइन) |
| बाह्य मूल्याङ्कन | 75 = लिखित 50 + प्रयोगात्मक 25 |
| आन्तरिक मूल्याङ्कन | 25 (कक्षा सहभागिता 3, त्रैमासिक परीक्षा 6, project work 16) |
| क्रेडिट घण्टा / कार्य घण्टा | 5 / 160 |
यति घण्टा र अंकको अर्थ के? Unit 1 लाई 80 मध्ये 12 घण्टा दिइएको छ — अर्थात् पाठ्यक्रमको करिब 15%। लिखित पेपर 50 को हुने हुनाले Unit 1 बाट सामान्यतया 6–8 अंक आउँछ: एउटा छोटो उत्तर र केही वस्तुगत प्रश्न, वा एउटा लामो प्रश्न।
यो नोट कसरी पढ्ने
हरेक शीर्षकमा तीन कुरा छन्:
- नेपालीमा व्याख्या — अवधारणा साँच्चै बुझ्नका लागि।
- Exam line — परीक्षामा जस्ताको तस्तै लेख्न मिल्ने अंग्रेजी परिभाषा।
- उदाहरण वा तालिका — किनभने NEB मा उदाहरण दिए अंक बढ्छ।
सुझाव: उत्तरपुस्तिकामा अंग्रेजीमै लेख्नु। नेपाली यहाँ बुझ्नका लागि मात्र हो। Diagram माग्ने प्रश्नमा diagram नकोरी पूरा अंक आउँदैन — ER diagram र normalization का उदाहरण अभ्यास गर्नु।
यस पानामा के-के छ — Contents
तल NEB पाठ्यक्रमकै क्रममा सबै शीर्षक छन्। परीक्षा नजिक छ भने सीधै नमुना उत्तर, शब्दावली र बारम्बार सोधिने प्रश्न मा जानुहोस्।
- डेटा र सूचना — Data and Information
- फाइल प्रणाली र यसका समस्या — The file-based system
- डेटाबेस, DBMS र डेटाबेस प्रणाली
- डेटाबेसका आधारभूत शब्दहरू — basic terms
- Keys — कुञ्जीहरू
- डेटाबेस मोडेलहरू — Database models
- E-R Diagram — Entity Relationship Diagram
- Normalization — सामान्यीकरण
- केन्द्रीकृत र वितरित डेटाबेस — Centralized vs Distributed
- डेटाबेस प्रशासक — Database Administrator (DBA)
- Data dictionary र Data security
- SQL — Structured Query Language
- NEB परीक्षाका सम्भावित प्रश्न र नमुना उत्तर
- शब्दावली — Nepali–English glossary
- Frequently asked questions
- Related reading on CSSNepal
डेटा र सूचना — Data and Information
डेटा (Data) के हो?
नेपालीमा: डेटा भनेको कच्चा तथ्य र अंक हो — जसको आफैँमा कुनै अर्थ लाग्दैन। जस्तै 85, राम, पोखरा — यी छुट्टाछुट्टै हेर्दा केही भन्दैनन्।
Exam line: Data are raw, unprocessed facts and figures that have no meaning on their own.
सूचना (Information) के हो?
नेपालीमा: डेटालाई प्रशोधन (process) गरेपछि जुन अर्थपूर्ण नतिजा आउँछ, त्यही सूचना हो। राम को कम्प्युटरमा 85 अंक आयो — अब यसले अर्थ दियो।
Exam line: Information is processed data that has been organised and given context so that it becomes meaningful and useful for decision making.
डेटा र सूचना बीचको भिन्नता
| आधार | Data (डेटा) | Information (सूचना) |
|---|---|---|
| अर्थ | कच्चा तथ्य, अर्थ छैन | प्रशोधित, अर्थपूर्ण |
| निर्भरता | सूचनामा निर्भर छैन | डेटामा निर्भर छ |
| निर्णय | सिधै निर्णय लिन मिल्दैन | निर्णय लिन प्रयोग हुन्छ |
| रूप | संख्या, अक्षर, चिन्ह | तालिका, रिपोर्ट, ग्राफ |
| उदाहरण | 85, 72, 91 | “कक्षाको औसत अंक 82.67” |
डेटाका प्रकार
| प्रकार | नेपालीमा | उदाहरण |
|---|---|---|
| Primary data | आफैँले नयाँ सङ्कलन गरेको | सर्वेक्षण, प्रश्नावली, प्रत्यक्ष अवलोकन |
| Secondary data | अरूले पहिले नै सङ्कलन गरिसकेको | वित्तीय विवरण, जनगणना रिपोर्ट, पुस्तक |
डेटा प्रशोधन चक्र — Data Processing Cycle
INPUT PROCESSING OUTPUT
(डेटा हाल्ने) → (छाँट्ने, जोड्ने, → (अर्थपूर्ण सूचना)
क्रमबद्ध गर्ने,
गणना गर्ने)
↓
STORAGE
(भण्डारण — पछि
फेरि प्रयोगका लागि)Exam line: Data processing is the sequence of operations — input, processing, output and storage — by which raw data is converted into meaningful information.
फाइल प्रणाली र यसका समस्या — The file-based system
DBMS किन चाहियो भन्ने बुझ्न, पहिले यो आउनुअघि के थियो भन्ने बुझ्नुपर्छ।
नेपालीमा: पहिले हरेक विभागले आफ्नै छुट्टाछुट्टै फाइल राख्थ्यो। भर्ना विभागको आफ्नै फाइल, परीक्षा विभागको आफ्नै, पुस्तकालयको आफ्नै। एउटै विद्यार्थीको नाम र ठेगाना तीनै ठाउँमा दोहोरिन्थ्यो। विद्यार्थीले ठेगाना बदल्यो भने तीनै ठाउँमा बदल्नुपर्थ्यो — एक ठाउँ बिर्सियो भने डेटा बाझिन्छ।
भर्ना विभाग परीक्षा विभाग पुस्तकालय
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Roll │ │ Roll │ │ Roll │
│ Name │ │ Name │ │ Name │ ← एउटै डेटा
│ Address │ │ Marks │ │ Address │ तीन ठाउँमा!
└──────────┘ └──────────┘ └──────────┘
admission.dat exam.dat library.datफाइल प्रणालीका सीमा — limitations (परीक्षामा सोधिन्छ)
| समस्या | नेपालीमा के हो |
|---|---|
| Data redundancy | एउटै डेटा धेरै ठाउँमा दोहोरिनु — ठाउँ खेर जान्छ |
| Data inconsistency | एक ठाउँमा बदल्यो, अर्कोमा बदलेन → डेटा बाझियो |
| Difficulty in accessing data | नयाँ किसिमको रिपोर्ट चाहियो भने नयाँ program नै लेख्नुपर्ने |
| Data isolation | डेटा छुट्टाछुट्टै फाइल र ढाँचामा छरिएको, जोड्न गाह्रो |
| Integrity problems | “अंक 0 देखि 100 बीचमै हुनुपर्छ” जस्ता नियम program भित्र लेख्नुपर्ने |
| Atomicity problem | काम बीचैमा बिग्रियो भने आधा मात्र भएर अड्किने |
| Concurrent access anomalies | धेरै जनाले एकैचोटि लेख्दा डेटा बिग्रिने |
| Security problems | कुन प्रयोगकर्ताले कुन डेटा हेर्न पाउने भनी छुट्याउन गाह्रो |
Exam line: In a file-based system each application maintains its own separate files, which leads to data redundancy, inconsistency, poor security, data isolation and difficulty in accessing data — the problems a DBMS was designed to solve.
फाइल प्रणाली र डेटाबेस प्रणालीको तुलना
| आधार | File-based system | Database system |
|---|---|---|
| डेटा भण्डारण | छुट्टाछुट्टै फाइलमा | एउटै केन्द्रीय डेटाबेसमा |
| Redundancy | धेरै | नियन्त्रित, न्यून |
| Consistency | कम | बढी |
| Data independence | छैन | छ |
| Sharing | गाह्रो | सजिलो |
| Security | कमजोर | बलियो, प्रयोगकर्ता अनुसार |
| Backup/recovery | हातैले | स्वचालित |
| Query | नयाँ program लेख्नुपर्ने | SQL ले तुरुन्तै |
| लागत | सस्तो | महँगो |
डेटाबेस, DBMS र डेटाबेस प्रणाली
यी तीन शब्द फरक हुन् — परीक्षामा यही भिन्नता सोधिन्छ।
| शब्द | अर्थ | उदाहरण |
|---|---|---|
| Database | सम्बन्धित डेटाको व्यवस्थित सङ्ग्रह | विद्यालयको school_db |
| DBMS | त्यो डेटाबेस चलाउने सफ्टवेयर | MySQL, Oracle, MS Access |
| Database system | Database + DBMS + hardware + प्रयोगकर्ता, सबै मिलेर | पूरै विद्यालय प्रणाली |
बारम्बार हुने गल्ती: “MySQL एउटा database हो” भन्नु गलत हो। MySQL एउटा DBMS हो; school_db चाहिँ database हो।
DBMS ले भित्र के-के गर्छ — functions
| कार्य | नेपालीमा |
|---|---|
| Data definition | तालिका र क्षेत्रको संरचना बनाउने (CREATE) |
| Data manipulation | डेटा थप्ने, हेर्ने, बदल्ने, मेट्ने (INSERT/SELECT/UPDATE/DELETE) |
| Data security | कसले के गर्न पाउने भन्ने नियन्त्रण (GRANT/REVOKE) |
| Data integrity | नियम भङ्ग हुने डेटा छिर्नै नदिने |
| Concurrency control | धेरै प्रयोगकर्ता एकैचोटि काम गर्दा नबिग्रियोस् भन्ने |
| Backup and recovery | बिग्रिएमा पुरानो अवस्थामा फर्काउने |
| Data dictionary management | डेटाबेसको आफ्नै विवरण राख्ने |
DBMS का फाइदा — advantages
- Reduction of data redundancy — दोहोरोपन घट्छ
- Data consistency — डेटा बाझिँदैन
- Data sharing — धेरै प्रयोगकर्ताले एउटै डेटा प्रयोग गर्न पाउँछन्
- Data independence — भण्डारण बदले पनि program बदल्नु पर्दैन
- Improved data integrity — नियम DBMS आफैँले लागू गर्छ
- Improved security — प्रयोगकर्ता अनुसार पहुँच
- Backup and recovery — स्वचालित
- Concurrent access — एकैचोटि धेरै जनाले सुरक्षित रूपमा
- Unforeseen queries — पहिले नसोचेको प्रश्नको पनि उत्तर SQL ले दिन्छ
- Multiple user interfaces — form, report, API
DBMS का बेफाइदा — disadvantages
- Expensive — सफ्टवेयर र hardware महँगो
- Complexity — बुझ्न र चलाउन जटिल
- Needs technical training — दक्ष जनशक्ति चाहिन्छ
- Larger size — धेरै memory र disk खान्छ
- Single point of failure — केन्द्रीय डेटाबेस बिग्रियो भने सबै रोकिन्छ
- Performance — सानो, सरल कामका लागि फाइल भन्दा ढिलो हुन सक्छ
डेटाबेसका आधारभूत शब्दहरू — basic terms
यी शब्द सबै अगाडिका अध्यायमा फेरि-फेरि आउँछन्, त्यसैले पहिले यिनै पक्का गर्नु।
| शब्द | नेपालीमा | उदाहरण |
|---|---|---|
| Table / Relation | पङ्क्ति र स्तम्भको ढाँचामा राखिएको डेटा | STUDENT तालिका |
| Field / Attribute / Column | तालिकाको एउटा स्तम्भ — एउटा गुण | Name, Address |
| Record / Tuple / Row | तालिकाको एउटा पङ्क्ति — एउटा वस्तुको पूरा विवरण | राम को पूरै विवरण |
| Data item / Cell | एउटा पङ्क्ति र एउटा स्तम्भ जोडिने ठाउँको एउटा मान | पोखरा |
| Domain | कुनै क्षेत्रमा राख्न मिल्ने मानहरूको समूह | Marks को domain = 0–100 |
| Degree | तालिकामा भएका स्तम्भको संख्या | 5 स्तम्भ भए degree = 5 |
| Cardinality | तालिकामा भएका पङ्क्तिको संख्या | 40 विद्यार्थी भए cardinality = 40 |
| Entity | वास्तविक संसारको वस्तु जसको डेटा राखिन्छ | विद्यार्थी, पुस्तक, शिक्षक |
| Instance | कुनै क्षणमा डेटाबेसमा भएको डेटा | आजको अवस्था |
| Schema | डेटाबेसको संरचनाको खाका | तालिका र क्षेत्रको डिजाइन |
सम्झने सजिलो तरिका: Degree = स्तम्भ (कति किसिमको जानकारी), Cardinality = पङ्क्ति (कति वटा रेकर्ड)। परीक्षामा यी दुई साटिन्छन् — ध्यान दिनु।
← degree = ४ स्तम्भ →
┌────────┬────────┬──────────┬───────┐
│ Roll │ Name │ Address │ Marks │ ← field / attribute
├────────┼────────┼──────────┼───────┤
↑ │ 101 │ Ram │ Pokhara │ 85 │ ← record / tuple
cardinality │ 102 │ Sita │ Butwal │ 91 │
= ३ │ 103 │ Hari │ Dharan │ 78 │
↓ └────────┴────────┴──────────┴───────┘
↑
data item / cellKeys — कुञ्जीहरू
नेपालीमा: तालिकाको कुनै पङ्क्तिलाई अरूबाट छुट्याएर चिन्नका लागि प्रयोग हुने क्षेत्र वा क्षेत्रहरूको समूहलाई key भनिन्छ। कक्षामा दुई जना “राम” हुन सक्छन्, तर Roll नम्बर दुईवटा उस्तै हुँदैन — त्यसैले Roll key हो।
| Key | परिभाषा (नेपालीमा) | Exam definition |
|---|---|---|
| Super key | पङ्क्ति छुट्याउन सक्ने जुनसुकै क्षेत्र वा संयोजन | Any attribute or set of attributes that uniquely identifies a row. |
| Candidate key | सबैभन्दा सानो super key — जसबाट कुनै क्षेत्र झिक्यो भने अद्वितीयता नै जान्छ | A minimal super key. |
| Primary key | candidate key मध्ये छानिएको मुख्य कुञ्जी | The candidate key chosen to uniquely identify each record; it cannot be NULL or duplicated. |
| Alternate key | primary नछानिएका बाँकी candidate key | A candidate key that was not selected as the primary key. |
| Composite key | दुई वा बढी क्षेत्र मिलेर बनेको primary key | A primary key made up of two or more attributes. |
| Foreign key | अर्को तालिकाको primary key लाई देखाउने क्षेत्र | An attribute in one table that refers to the primary key of another table, creating a link between them. |
उदाहरणबाट बुझौं
STUDENT तालिका
┌─────────┬───────────┬────────┬───────────┐
│ Roll(PK)│ Citizen# │ Name │ ProgramID │ ← foreign key
├─────────┼───────────┼────────┼───────────┤
│ 101 │ 12-345-67 │ Ram │ CS │
│ 102 │ 98-765-43 │ Sita │ CS │
└─────────┴───────────┴────────┴───────────┘
│
↓ देखाउँछ
PROGRAM तालिका ┌─────────────┬──────────────┐
│ ProgramID(PK)│ ProgramName │
├─────────────┼──────────────┤
│ CS │ Computer Sc. │
└─────────────┴──────────────┘यहाँ Roll र Citizen# दुवैले विद्यार्थी अद्वितीय रूपमा चिन्न सक्छन् — त्यसैले दुवै candidate key हुन्। हामीले Roll लाई primary key बनायौं, त्यसैले Citizen# alternate key भयो। ProgramID ले अर्को तालिका देखाउँछ, त्यसैले त्यो foreign key हो।
Data integrity — डेटाको शुद्धता
| नियम | नेपालीमा | भङ्ग भएको उदाहरण |
|---|---|---|
| Entity integrity | Primary key खाली (NULL) वा दोहोरिएको हुनु हुँदैन | दुई विद्यार्थीको Roll दुवै 101 |
| Referential integrity | Foreign key ले नभएको पङ्क्ति देखाउनु हुँदैन | ProgramID = 'EE' तर PROGRAM मा EE छँदै छैन |
| Domain integrity | मान तोकिएको दायरा र प्रकारभित्रै हुनुपर्छ | Marks = 150 वा Marks = 'Ram' |
Exam line: Data integrity means the accuracy, validity and consistency of data in a database, enforced by the DBMS through entity integrity, referential integrity and domain integrity constraints.
डेटाबेस मोडेलहरू — Database models
नेपालीमा: डेटाबेसमा डेटा कसरी मिलाएर राख्ने र एउटा डेटा अर्कोसँग कसरी जोड्ने — यो ढाँचालाई database model भनिन्छ।
1. Hierarchical model (पदानुक्रमिक मोडेल)
नेपालीमा: डेटा रूखको आकारमा मिलाइन्छ। माथि एउटा मात्र root हुन्छ, तलका हरेक child को एउटै मात्र parent हुन्छ। IBM को IMS यसैमा आधारित थियो।
Gurukul College ← root
/ \
Science Humanities ← parent
/ \
Chemistry Biology ← child| फाइदा | बेफाइदा |
|---|---|
| बुझ्न र बनाउन सजिलो | Many-to-many सम्बन्ध राख्न सकिँदैन |
| एक-देखि-धेरै सम्बन्धमा छिटो | संरचना कडा — बदल्न गाह्रो |
| डेटा सुरक्षा राम्रो | एउटै डेटा दोहोरिने सम्भावना |
| Child लाई parent बिना राख्न मिल्दैन |
2. Network model (नेटवर्क मोडेल)
नेपालीमा: Hierarchical को कमजोरी हटाउन आएको। यहाँ एउटा child का धेरै parent हुन सक्छन्, त्यसैले संरचना रूख नभई जाल (graph) जस्तो हुन्छ। CODASYL ले मानक बनाएको थियो।
Science ─────┐ ┌───── Humanities
│ │ │
↓ ↓ ↓
Chemistry Statistics History
↑
(दुवै faculty सँग जोडिएको)| फाइदा | बेफाइदा |
|---|---|
| Many-to-many सम्बन्ध राख्न सकिने | संरचना जटिल |
| Hierarchical भन्दा लचिलो | बनाउन र बदल्न गाह्रो |
| डेटामा छिटो पुग्ने | प्रयोगकर्तालाई संरचना थाहा हुनुपर्ने |
3. Relational model (सम्बन्धात्मक मोडेल) — सबैभन्दा प्रचलित
नेपालीमा: E. F. Codd ले 1970 मा प्रस्ताव गरेको। डेटा तालिका (relation) मा राखिन्छ र तालिकाहरू key मार्फत जोडिन्छन्। आजका MySQL, Oracle, PostgreSQL, MS Access सबै यसैमा आधारित छन्।
STUDENT PROGRAM
┌──────┬───────┬──────────┐ ┌──────────┬─────────────┐
│ Roll │ Name │ProgramID │────→│ProgramID │ ProgramName │
├──────┼───────┼──────────┤ ├──────────┼─────────────┤
│ 101 │ Ram │ CS │ │ CS │ Computer Sc.│
│ 102 │ Sita │ MG │ │ MG │ Management │
└──────┴───────┴──────────┘ └──────────┴─────────────┘
foreign key → primary key| फाइदा | बेफाइदा |
|---|---|
| बुझ्न सजिलो — तालिका सबैले चिन्छन् | धेरै ठूलो डेटामा ढिलो हुन सक्ने |
| SQL ले सजिलै query गर्न मिल्ने | धेरै तालिका जोड्दा (join) जटिल |
| Data redundancy घटाउन सकिने | Hardware महँगो पर्न सक्ने |
| संरचना बदल्न सजिलो |
4. Object-oriented model (वस्तुमुखी मोडेल)
नेपालीमा: डेटा र त्यो डेटामाथि चल्ने method दुवै object भित्रै राखिन्छ। Inheritance, encapsulation जस्ता OOP का गुण यहाँ पनि लागू हुन्छन्। चित्र, भिडियो, नक्सा जस्तो जटिल डेटाका लागि उपयुक्त।
| फाइदा | बेफाइदा |
|---|---|
| जटिल डेटा (multimedia, CAD) राख्न सकिने | बुझ्न र चलाउन गाह्रो |
| OOP भाषासँग सिधै मिल्ने | मानक (standard) कम |
| Code पुन: प्रयोग गर्न मिल्ने | बजारमा कम प्रचलित |
चारै मोडेलको तुलना
| आधार | Hierarchical | Network | Relational | Object-oriented |
|---|---|---|---|---|
| संरचना | रूख (tree) | जाल (graph) | तालिका | object |
| सम्बन्ध | 1:M मात्र | 1:M र M:N | key मार्फत सबै | object reference |
| Parent | एउटै मात्र | धेरै हुन सक्ने | लागू हुँदैन | लागू हुँदैन |
| प्रयोग | IBM IMS | CODASYL/IDMS | MySQL, Oracle | ObjectDB, db4o |
| सजिलोपन | सजिलो | जटिल | सबैभन्दा सजिलो | जटिल |
E-R Diagram — Entity Relationship Diagram
नेपालीमा: डेटाबेस बनाउनु अघि “कुन-कुन वस्तुको डेटा राख्ने र ती वस्तु आपसमा कसरी जोडिन्छन्” भन्ने चित्रमा देखाउने तरिका नै ER diagram हो। यो Peter Chen ले 1976 मा ल्याएका हुन्।
Exam line: An E-R diagram is a graphical representation of the entities in a system and the relationships among them, used to design the logical structure of a database.
ER diagram का चिन्हहरू — components
| चिन्ह | आकार | के जनाउँछ |
|---|---|---|
| Entity | आयत (rectangle) | वास्तविक वस्तु — STUDENT, BOOK |
| Attribute | अण्डाकार (ellipse) | वस्तुको गुण — Name, Address |
| Relationship | ठाडो चतुर्भुज (diamond) | वस्तुबीचको सम्बन्ध — STUDIES, BORROWS |
| Link | रेखा (line) | माथिका कुरा जोड्ने |
| Key attribute | मुनि रेखा कोरिएको अण्डाकार | Primary key — <u>Roll</u> |
| Multivalued attribute | दोहोरो अण्डाकार | धेरै मान हुने — Phone |
| Derived attribute | थर्किएको अण्डाकार | अरूबाट निकालिने — Age (DOB बाट) |
┌─────────┐ ┌─────────┐
│ STUDENT │──────◇ STUDIES ◇─────────│ PROGRAM │
└─────────┘ └─────────┘
/ | \ / \
(Roll) (Name) (Address) (ProgramID) (PName)
___ ______
(रेखा कोरिएको = primary key)Cardinality — सम्बन्धको मात्रा
| प्रकार | नेपालीमा | उदाहरण |
|---|---|---|
| One-to-One (1:1) | एउटाको एउटैसँग मात्र सम्बन्ध | एक विद्यार्थी ↔ एक रोल नम्बर |
| One-to-Many (1:M) | एउटाको धेरैसँग सम्बन्ध | एक शिक्षक → धेरै विद्यार्थी |
| Many-to-Many (M:N) | धेरैको धेरैसँग सम्बन्ध | धेरै विद्यार्थी ↔ धेरै विषय |
1:1 [विद्यार्थी] ───── [रोल नम्बर]
1:M [शिक्षक] ────┬──── [विद्यार्थी १]
├──── [विद्यार्थी २]
└──── [विद्यार्थी ३]
M:N [विद्यार्थी १] ──┐ ┌── [विषय: कम्प्युटर]
[विद्यार्थी २] ──┼───┼── [विषय: गणित]
[विद्यार्थी ३] ──┘ └── [विषय: अंग्रेजी]महत्वपूर्ण बुँदा: Many-to-many सम्बन्ध सिधै तालिकामा राख्न मिल्दैन। बीचमा एउटा junction table (वा bridge/linking table) बनाउनुपर्छ:
STUDENT ──1:M──→ ENROLLMENT ←──M:1── SUBJECT
┌──────┬──────────┐
│ Roll │ SubjectID│ ← दुवैको foreign key मिलेर
├──────┼──────────┤ composite primary key
│ 101 │ CS101 │
│ 101 │ MT101 │
│ 102 │ CS101 │
└──────┴──────────┘Normalization — सामान्यीकरण
नेपालीमा: ठूलो र दोहोरिने तालिकालाई साना-साना, सफा तालिकामा टुक्र्याउने व्यवस्थित प्रक्रिया नै normalization हो। उद्देश्य: data redundancy घटाउने र anomaly हटाउने।
Exam line: Normalization is the process of organising data in a database by decomposing large tables into smaller, well-structured tables and defining relationships among them, in order to minimise data redundancy and eliminate insertion, update and deletion anomalies.
तीन किसिमका Anomaly — किन normalize गर्ने?
यो तालिका हेरौं (normalize नगरिएको):
| Roll | Name | ProgramID | ProgramHead |
|---|---|---|---|
| 101 | Ram | CS | Mr. Gurung |
| 102 | Sita | CS | Mr. Gurung |
| 103 | Hari | MG | Mrs. Rai |
| Anomaly | नेपालीमा समस्या | यहाँ के हुन्छ |
|---|---|---|
| Insertion anomaly | नयाँ डेटा थप्न नसकिने | नयाँ program EE खोल्यौं तर विद्यार्थी छैन — Roll primary key भएकाले पङ्क्ति नै थप्न मिल्दैन |
| Update anomaly | एक ठाउँ बदल्दा अरू छुट्ने | CS को head बदलियो भने दुवै पङ्क्ति बदल्नुपर्छ; एक छुट्यो भने डेटा बाझियो |
| Deletion anomaly | चाहिने डेटा पनि सँगै मेटिने | Hari मेट्यौं भने MG program र Mrs. Rai को जानकारी नै हराउँछ |
Functional dependency — एउटै मूल अवधारणा
नेपालीमा: A → B भन्नुको अर्थ “A थाहा भए B अनिवार्य रूपमा थाहा हुन्छ”। जस्तै Roll → Name: रोल नम्बर थाहा भए नाम निश्चित हुन्छ। यही निर्भरता हेरेर तालिका टुक्र्याइन्छ।
1NF — First Normal Form
नियम: हरेक cell मा एउटै मात्र मान (atomic value) हुनुपर्छ; दोहोरिने समूह (repeating group) हुनु हुँदैन।
1NF मा नभएको:
| Roll | Name | Subjects |
|---|---|---|
| 101 | Ram | Computer, Math |
1NF मा ल्याएपछि:
| Roll | Name | Subject |
|---|---|---|
| 101 | Ram | Computer |
| 101 | Ram | Math |
2NF — Second Normal Form
नियम: 1NF मा हुनुपर्यो, र कुनै non-key क्षेत्र composite primary key को एक अंशमा मात्र निर्भर हुनु हुँदैन (partial dependency हटाउनुपर्छ)।
माथिको तालिकामा primary key = (Roll, Subject)। तर Name चाहिँ Roll मा मात्रै निर्भर छ, Subject मा होइन — यो partial dependency हो।
2NF मा टुक्र्याएपछि:
STUDENT ENROLLMENT
┌──────┬───────┐ ┌──────┬──────────┐
│ Roll │ Name │ │ Roll │ Subject │
├──────┼───────┤ ├──────┼──────────┤
│ 101 │ Ram │ │ 101 │ Computer │
└──────┴───────┘ │ 101 │ Math │
PK = Roll └──────┴──────────┘
PK = (Roll, Subject)3NF — Third Normal Form
नियम: 2NF मा हुनुपर्यो, र कुनै non-key क्षेत्र अर्को non-key क्षेत्रमार्फत primary key मा निर्भर हुनु हुँदैन (transitive dependency हटाउनुपर्छ)।
यो तालिका हेरौं:
| Roll | Name | ProgramID | ProgramHead |
|---|---|---|---|
| 101 | Ram | CS | Mr. Gurung |
यहाँ Roll → ProgramID र ProgramID → ProgramHead, त्यसैले Roll → ProgramHead घुमाउरो बाटो (transitive) बाट आयो।
3NF मा टुक्र्याएपछि:
STUDENT PROGRAM
┌──────┬───────┬───────────┐ ┌───────────┬─────────────┐
│ Roll │ Name │ ProgramID │─────→│ ProgramID │ ProgramHead │
├──────┼───────┼───────────┤ ├───────────┼─────────────┤
│ 101 │ Ram │ CS │ │ CS │ Mr. Gurung │
│ 102 │ Sita │ CS │ │ MG │ Mrs. Rai │
└──────┴───────┴───────────┘ └───────────┴─────────────┘अब CS को head बदल्नु पर्यो भने एउटै ठाउँ बदले पुग्छ — update anomaly हट्यो। नयाँ program पनि विद्यार्थी बिना थप्न मिल्छ — insertion anomaly हट्यो।
तीनै normal form एकै हेराइमा
| Form | हटाउने समस्या | सरल नियम |
|---|---|---|
| 1NF | Repeating group / multivalued cell | हरेक खानामा एउटै मान |
| 2NF | Partial dependency | पूरै primary key मा निर्भर हुनुपर्छ |
| 3NF | Transitive dependency | non-key ले non-key निर्धारण गर्नु हुँदैन |
रट्ने वाक्य (अंग्रेजीमा): “The key, the whole key, and nothing but the key.” — 1NF: the key; 2NF: the whole key; 3NF: nothing but the key.
Normalization का फाइदा र सीमा
| फाइदा | सीमा |
|---|---|
| Redundancy घट्छ | धेरै तालिका बन्छन् |
| Anomaly हट्छ | Query मा धेरै join चाहिन्छ |
| डेटा consistent रहन्छ | धेरै टुक्र्याए पढ्न ढिलो हुन सक्छ |
| ठाउँ बचत हुन्छ | डिजाइन गर्न समय लाग्छ |
व्यवहारमा: अधिकांश डेटाबेस 3NF सम्म मात्र लगिन्छ। त्योभन्दा माथि (BCNF, 4NF) विशेष अवस्थामा मात्र चाहिन्छ, र NEB कक्षा १२ मा 1NF, 2NF, 3NF नै पर्याप्त छ।
केन्द्रीकृत र वितरित डेटाबेस — Centralized vs Distributed
नेपालीमा: सबै डेटा एउटै ठाउँको एउटै कम्प्युटरमा राख्यो भने centralized; फरक-फरक ठाउँका धेरै कम्प्युटरमा छरेर राख्यो भने distributed।
CENTRALIZED DISTRIBUTED
[सबै प्रयोगकर्ता] काठमाडौं पोखरा विराटनगर
↓ [DB] [DB] [DB]
┌───────────┐ └────────┼────────┘
│ एउटै सर्भर │ नेटवर्क
│ (DB) │ (सबै मिलेर एउटै
└───────────┘ डेटाबेस जस्तो)| आधार | Centralized | Distributed |
|---|---|---|
| स्थान | एउटै ठाउँ | धेरै ठाउँ |
| व्यवस्थापन | सजिलो | जटिल |
| लागत | कम | बढी |
| गति | टाढाका प्रयोगकर्तालाई ढिलो | स्थानीय प्रयोगकर्तालाई छिटो |
| Failure | सर्भर बिग्रिए सबै रोकिन्छ | एउटा बिग्रिए पनि अरू चल्छन् |
| Data consistency | सजिलै कायम हुन्छ | कायम राख्न गाह्रो |
| Security | नियन्त्रण गर्न सजिलो | धेरै ठाउँ जोगाउनुपर्ने |
| उदाहरण | सानो विद्यालयको प्रणाली | बैंकका शाखाहरू, NTC |
डेटाबेस प्रशासक — Database Administrator (DBA)
नेपालीमा: डेटाबेसको पूरै जिम्मेवारी लिने व्यक्ति नै DBA हो — बनाउनेदेखि सुरक्षा, backup र कार्यसम्पादनसम्म।
Exam line: A Database Administrator (DBA) is the person responsible for the design, implementation, security, integrity, performance and maintenance of an organisation’s database.
DBA का मुख्य जिम्मेवारी
| जिम्मेवारी | नेपालीमा |
|---|---|
| Schema definition | तालिका र संरचनाको डिजाइन गर्ने |
| Storage structure | डेटा कसरी र कहाँ राख्ने निर्णय गर्ने |
| Granting authorization | कसले के गर्न पाउने भनी अनुमति दिने |
| Security | अनधिकृत पहुँच रोक्ने |
| Backup and recovery | नियमित backup र बिग्रिएमा पुनर्स्थापना |
| Performance tuning | Index, query सुधारेर छिटो बनाउने |
| Integrity constraints | नियम लागू गर्ने |
| User training & support | प्रयोगकर्तालाई सिकाउने |
| Software upgrade | DBMS को नयाँ संस्करण व्यवस्थापन |
Data dictionary र Data security
Data dictionary (डेटा शब्दकोश)
नेपालीमा: डेटाबेसले आफ्नै बारेमा राख्ने जानकारी — कुन तालिका छ, कुन क्षेत्र छ, कस्तो प्रकारको छ, कुन key हो, कस्तो नियम छ। यसैलाई metadata (डेटाको डेटा) पनि भनिन्छ।
Exam line: A data dictionary is a centralised repository that stores metadata — information about the structure of the database such as table names, field names, data types, constraints and relationships.
सम्झने तरिका: पुस्तकालयमा पुस्तक = डेटा; क्याटलग (कुन पुस्तक कुन दराजमा) = data dictionary।
Data security (डेटा सुरक्षा)
| उपाय | नेपालीमा |
|---|---|
| Authentication | प्रयोगकर्ता को हो भनी username/password ले पहिचान |
| Authorization | कसलाई कुन तालिकामा के गर्ने अनुमति (GRANT/REVOKE) |
| Encryption | डेटा सङ्केतमा बदलेर राख्ने, चोरिए पनि नबुझियोस् |
| Backup | नियमित प्रतिलिपि राख्ने |
| Audit trail | कसले कहिले के गर्यो भन्ने अभिलेख |
| View | आवश्यक स्तम्भ मात्र देखाउने, बाँकी लुकाउने |
SQL — Structured Query Language
नेपालीमा: डेटाबेससँग “कुरा गर्ने” मानक भाषा नै SQL हो। यो पूर्ण programming भाषा होइन — यो query language हो। अंग्रेजी वाक्य जस्तै पढिने भएकाले सिक्न सजिलो छ।
SQL का भागहरू
| भाग | पूरा नाम | काम | मुख्य आदेश |
|---|---|---|---|
| DDL | Data Definition Language | संरचना बनाउने/बदल्ने | CREATE, ALTER, DROP, TRUNCATE, RENAME |
| DML | Data Manipulation Language | डेटा थप्ने/हेर्ने/बदल्ने/मेट्ने | INSERT, SELECT, UPDATE, DELETE |
| DCL | Data Control Language | अनुमति दिने/खोस्ने | GRANT, REVOKE |
| TCL | Transaction Control Language | कारोबार पक्का/उल्टाउने | COMMIT, ROLLBACK, SAVEPOINT |
सम्झने तरिका: DDL = ढाँचा, DML = डेटा, DCL = अनुमति, TCL = कारोबार।
DDL — संरचना बनाउने
तालिका बनाउने:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FName VARCHAR(30) NOT NULL,
LName VARCHAR(30),
Address VARCHAR(50),
Class INT
);नयाँ स्तम्भ थप्ने:
ALTER TABLE Students ADD Phone VARCHAR(15);स्तम्भको प्रकार बदल्ने:
ALTER TABLE Students MODIFY Class VARCHAR(10);स्तम्भ हटाउने:
ALTER TABLE Students DROP COLUMN Phone;पूरै तालिका मेट्ने:
DROP TABLE Students;ध्यान दिनुहोस् —
DROPबनामDELETEबनामTRUNCATE:DROP TABLEले तालिका नै हटाउँछ (संरचना सहित)।TRUNCATE TABLEले सबै पङ्क्ति हटाउँछ तर तालिका रहन्छ।DELETE FROMले छानिएका पङ्क्ति हटाउँछ। यी तीन परीक्षामा साटिन्छन्।
DML — डेटासँग काम गर्ने
डेटा थप्ने:
INSERT INTO Students (StudentID, FName, LName, Address, Class)
VALUES (101, 'Ram', 'Sharma', 'Pokhara', 12);डेटा हेर्ने:
SELECT * FROM Students; -- सबै स्तम्भ
SELECT FName, LName FROM Students; -- छानिएका स्तम्भ मात्र
SELECT * FROM Students WHERE Class = 12; -- सर्त राखेर
SELECT * FROM Students ORDER BY FName ASC; -- क्रमबद्ध गरेरडेटा बदल्ने:
UPDATE Students
SET Address = 'Kathmandu'
WHERE StudentID = 101;डेटा मेट्ने:
DELETE FROM Students WHERE StudentID = 101;सबैभन्दा खतरनाक गल्ती:
UPDATEरDELETEमाWHEREछुटाउनु।DELETE FROM Students;ले पूरै तालिकाका सबै पङ्क्ति मेटिदिन्छ। परीक्षामा पनि, व्यवहारमा पनि —WHEREसधैँ जाँच्नु।
DCL — अनुमति नियन्त्रण
GRANT SELECT, INSERT ON Students TO 'teacher'@'localhost';
REVOKE INSERT ON Students FROM 'teacher'@'localhost';प्रयोगमा सहायक SQL clause
| Clause | काम | उदाहरण |
|---|---|---|
WHERE | सर्त राख्ने | WHERE Class = 12 |
ORDER BY | क्रमबद्ध गर्ने | ORDER BY FName DESC |
GROUP BY | समूहमा बाँड्ने | GROUP BY Class |
HAVING | समूहमा सर्त | HAVING COUNT(*) > 5 |
DISTINCT | दोहोरिएको हटाउने | SELECT DISTINCT Class |
LIKE | खोजी ढाँचा | WHERE FName LIKE 'R%' |
BETWEEN | दायरा | WHERE Class BETWEEN 11 AND 12 |
IN | सूचीमध्ये | WHERE Class IN (11, 12) |
NEB परीक्षाका सम्भावित प्रश्न र नमुना उत्तर
यी प्रश्न NEB कक्षा १२ मा बारम्बार सोधिएका हुन्। उत्तर अंग्रेजीमा दिइएको छ — किनभने उत्तरपुस्तिकामा अंग्रेजीमै लेख्नुपर्छ। माथि कोष्ठकमा नेपालीमा उत्तरको ढाँचा दिइएको छ।
प्रश्न १. What is a database and a DBMS? List the advantages and disadvantages of a DBMS.
(ढाँचा: दुई परिभाषा → उदाहरण → फाइदा ५–६ बुँदा → बेफाइदा ३–४ बुँदा)
A database is an organised collection of logically related data stored in a systematic way so that it can be easily accessed, managed and updated. A DBMS (Database Management System) is the software that enables users to create a database, and to store, retrieve, update and control access to the data in it. MySQL, Oracle, PostgreSQL and MS Access are examples of a DBMS, while
school_dbis an example of a database.Advantages: reduction of data redundancy; data consistency; data sharing among many users; data independence; improved data integrity; improved security; automatic backup and recovery; controlled concurrent access; and the ability to answer unforeseen queries through SQL.
Disadvantages: a DBMS is expensive to purchase and run; it is complex and requires trained technical staff; it needs more memory and processing power; and because the data is centralised, a failure of the database server can stop the whole organisation.
प्रश्न २. Explain the different models of DBMS with their advantages and disadvantages.
(ढाँचा: चारै मोडेल → हरेकको एक वाक्य परिभाषा → चित्र → फाइदा/बेफाइदा)
Hierarchical model organises data in a tree structure in which every child record has exactly one parent. It is simple and fast for one-to-many relationships, but it cannot represent many-to-many relationships and its structure is rigid.
Network model organises data as a graph in which a child may have several parents. It supports many-to-many relationships and is more flexible, but the structure is complex and difficult to modify.
Relational model, proposed by E. F. Codd in 1970, stores data in tables (relations) that are linked through keys. It is easy to understand, can be queried with SQL and reduces redundancy, but it may become slow with very large volumes of data and complex joins.
Object-oriented model stores data and the methods that operate on that data together as objects, supporting inheritance and encapsulation. It handles complex multimedia data well but is harder to use and less standardised.
प्रश्न ३. Differentiate between centralized and distributed database systems.
(ढाँचा: परिभाषा दुवैको → तुलना तालिका कम्तीमा ५ पङ्क्ति → उदाहरण)
In a centralized database system the entire database is stored and maintained at a single location on a single computer, and all users access it from there. In a distributed database system the database is spread across several computers at different physical locations connected by a network, yet it appears to users as a single logical database.
A centralized system is cheaper and easier to manage and keeps data consistent easily, but it is slower for remote users and a server failure stops all work. A distributed system gives faster local access and continues working when one site fails, but it costs more, is complex to manage and makes consistency harder to maintain. A small school system is typically centralized, while a bank with many branches uses a distributed database.
प्रश्न ४. Who is a DBA? What are the major responsibilities of a DBA?
(ढाँचा: परिभाषा → जिम्मेवारी ६–८ बुँदा)
A Database Administrator (DBA) is the person responsible for the overall design, implementation, security, integrity, performance and maintenance of an organisation’s database.
The major responsibilities of a DBA are: defining the database schema and storage structure; granting and controlling user authorization; enforcing security and preventing unauthorised access; taking regular backups and recovering the database after a failure; enforcing integrity constraints; monitoring and tuning performance; training and supporting users; and managing upgrades of the DBMS software.
प्रश्न ५. What is normalization? Explain the normalization process with examples.
(ढाँचा: परिभाषा → तीन anomaly → 1NF, 2NF, 3NF हरेकमा नियम + उदाहरण तालिका → फाइदा)
Normalization is the process of organising data in a database by decomposing large tables into smaller, well-structured tables and defining relationships among them, in order to minimise redundancy and eliminate insertion, update and deletion anomalies.
First Normal Form (1NF) requires every cell to hold a single atomic value with no repeating groups. A table holding
Subjects = "Computer, Math"in one cell is split into two rows, one per subject.Second Normal Form (2NF) requires the table to be in 1NF and every non-key attribute to depend on the whole primary key, removing partial dependency. With the composite key (
Roll,Subject), the attributeNamedepends only onRoll, so the table is split intoSTUDENT(Roll, Name)andENROLLMENT(Roll, Subject).Third Normal Form (3NF) requires the table to be in 2NF and no non-key attribute to depend on another non-key attribute, removing transitive dependency. Since
Roll → ProgramIDandProgramID → ProgramHead, the table is split intoSTUDENT(Roll, Name, ProgramID)andPROGRAM(ProgramID, ProgramHead).Normalization reduces redundancy, removes anomalies and keeps data consistent, although it produces more tables and therefore requires joins when querying.
प्रश्न ६. Define the following terms.
Data dictionary — a centralised repository that stores metadata, that is, information about the structure of the database such as table names, field names, data types, constraints and relationships.
Primary key — the candidate key chosen to identify each record in a table uniquely; it can contain neither duplicate values nor NULL.
Foreign key — an attribute in one table that refers to the primary key of another table, creating a link between the two tables.
Relationship — an association between two or more entities, which may be one-to-one, one-to-many or many-to-many.
DDL — Data Definition Language, the part of SQL used to define and modify the structure of a database, using commands such as CREATE, ALTER and DROP.
DML — Data Manipulation Language, the part of SQL used to insert, retrieve, update and delete the data held in tables.
SQL — Structured Query Language, the standard language used to define, manipulate and control data in a relational database.
Entity — a real-world object or concept, such as a student or a book, about which data is stored in a database.
Attribute — a named property or characteristic of an entity, which becomes a column in a table.
Record — a single row of a table, holding the complete set of attribute values for one entity instance.
थप सम्भावित प्रश्न
| प्रश्न | कहाँ पढ्ने |
|---|---|
| Differentiate between data and information. | डेटा र सूचना |
| What are the limitations of a file-based system? | फाइल प्रणालीका सीमा |
| Differentiate between DDL and DML with examples. | SQL |
| Explain the components of an E-R diagram. | E-R Diagram |
| Explain one-to-one, one-to-many and many-to-many relationships. | Cardinality |
| Differentiate between primary key and foreign key. | Keys |
| What is data redundancy? How does a DBMS reduce it? | फाइल प्रणाली + Normalization |
| Write SQL to create a table / insert / update / delete records. | SQL |
शब्दावली — Nepali–English glossary
| English | नेपालीमा अर्थ |
|---|---|
| Data | कच्चा तथ्य र अंक |
| Information | प्रशोधित, अर्थपूर्ण डेटा |
| Database | सम्बन्धित डेटाको व्यवस्थित सङ्ग्रह |
| DBMS | डेटाबेस चलाउने सफ्टवेयर |
| Redundancy | एउटै डेटा धेरै ठाउँमा दोहोरिनु |
| Inconsistency | एउटै कुराको फरक-फरक मान हुनु (बाझिनु) |
| Data independence | भण्डारण बदले पनि program नबदल्नुपर्ने गुण |
| Integrity | डेटाको शुद्धता र विश्वसनीयता |
| Table / Relation | पङ्क्ति-स्तम्भको ढाँचा |
| Field / Attribute | तालिकाको स्तम्भ |
| Record / Tuple | तालिकाको पङ्क्ति |
| Domain | क्षेत्रमा राख्न मिल्ने मानहरूको समूह |
| Degree | स्तम्भको संख्या |
| Cardinality | पङ्क्तिको संख्या (वा सम्बन्धको मात्रा) |
| Primary key | मुख्य पहिचान कुञ्जी |
| Candidate key | पहिचान गर्न सक्ने सबैभन्दा सानो कुञ्जी |
| Alternate key | primary नछानिएको candidate key |
| Foreign key | अर्को तालिका देखाउने कुञ्जी |
| Composite key | दुई वा बढी क्षेत्र मिलेको कुञ्जी |
| Entity | डेटा राखिने वास्तविक वस्तु |
| Relationship | वस्तुहरूबीचको सम्बन्ध |
| Schema | डेटाबेसको संरचनाको खाका |
| Metadata | डेटाको बारेमा भएको डेटा |
| Normalization | तालिका टुक्र्याएर दोहोरोपन घटाउने प्रक्रिया |
| Anomaly | थप्दा/बदल्दा/मेट्दा आउने गडबडी |
| Functional dependency | एउटा क्षेत्रले अर्कोलाई निर्धारण गर्ने सम्बन्ध |
| Query | डेटाबेससँग सोधिने प्रश्न |
| Transaction | एकसाथ पूरा हुनुपर्ने कामको समूह |
| Concurrency | धेरैले एकैचोटि काम गर्नु |
| Backup | सुरक्षित प्रतिलिपि |
| DBA | डेटाबेस प्रशासक |
Frequently asked questions
MySQL डेटाबेस हो कि DBMS?
MySQL एउटा DBMS हो — डेटाबेस होइन। MySQL भनेको सफ्टवेयर हो जसले डेटाबेस बनाउन र चलाउन दिन्छ; तपाईंले त्यसभित्र बनाउने school_db चाहिँ डेटाबेस हो। परीक्षामा “MySQL is a database” लेख्नु सामान्य तर गलत उत्तर हो। More precisely, MySQL is a Relational Database Management System (RDBMS).
Primary key र Foreign key बीच के फरक छ?
Primary key आफ्नै तालिकाका पङ्क्तिलाई अद्वितीय रूपमा चिनाउँछ, र यसमा न दोहोरिएको मान न NULL राख्न मिल्छ। Foreign key चाहिँ अर्को तालिकाको primary key लाई देखाउँछ र दुई तालिका जोड्छ; यसमा दोहोरिएको मान राख्न मिल्छ, र सम्बन्ध वैकल्पिक भए NULL पनि हुन सक्छ। एउटै तालिकामा primary key एउटा मात्र हुन्छ, तर foreign key धेरै हुन सक्छन्।
Degree र Cardinality फरक कसरी सम्झने?
Degree = स्तम्भ (column) को संख्या, Cardinality = पङ्क्ति (row) को संख्या। जस्तै 4 स्तम्भ र 40 विद्यार्थी भएको तालिकाको degree 4 र cardinality 40 हुन्छ। ER diagram को सन्दर्भमा भने cardinality ले सम्बन्धको मात्रा (1:1, 1:M, M:N) जनाउँछ — प्रश्नले कुन सन्दर्भ सोधेको हो हेर्नु।
Normalization कहाँसम्म गर्ने — 3NF पुग्छ कि पुग्दैन?
व्यवहारमा र NEB कक्षा १२ का लागि 3NF सम्म पुग्छ। 3NF ले insertion, update र deletion तीनै anomaly हटाइसक्छ। BCNF, 4NF र 5NF विशेष अवस्थामा मात्र चाहिन्छ र कक्षा १२ को पाठ्यक्रमभित्र पर्दैन। धेरै normalize गर्दा तालिका धेरै हुन्छन् र query मा join बढेर पढ्न ढिलो पनि हुन सक्छ।
SQL programming भाषा हो?
होइन — SQL एउटा query language हो, पूर्ण programming भाषा होइन। यसमा loop, condition र function जस्ता सामान्य programming संरचना हुँदैनन्; यसले “के चाहियो” भन्छ, “कसरी ल्याउने” भन्दैन (यसैलाई declarative भनिन्छ)। तर MySQL को stored procedure वा Oracle को PL/SQL जस्ता विस्तारले programming सुविधा थप्छन्।
DROP, DELETE र TRUNCATE मा के फरक छ?
DROP TABLE ले तालिका नै हटाउँछ — डेटा र संरचना दुवै जान्छ। TRUNCATE TABLE ले सबै पङ्क्ति हटाउँछ तर खाली तालिका रहन्छ। DELETE FROM ले WHERE सर्त अनुसार छानिएका पङ्क्ति मात्र हटाउँछ, र सर्त नराखे सबै पङ्क्ति हट्छ। DDL मा DROP र TRUNCATE पर्छन्, DML मा DELETE पर्छ।
Hierarchical र Network model मा मुख्य भिन्नता के हो?
Hierarchical model मा हरेक child को एउटै मात्र parent हुन्छ, त्यसैले संरचना रूख जस्तो हुन्छ र many-to-many सम्बन्ध राख्न सकिँदैन। Network model मा एउटा child का धेरै parent हुन सक्छन्, त्यसैले संरचना जाल (graph) जस्तो हुन्छ र many-to-many सम्बन्ध पनि राख्न मिल्छ — तर बनाउन र बुझ्न बढी जटिल हुन्छ।
Many-to-many सम्बन्ध तालिकामा कसरी राख्ने?
सिधै राख्न मिल्दैन। बीचमा एउटा junction table (bridge table) बनाउनुपर्छ, जसमा दुवै तालिकाका primary key foreign key बनेर आउँछन् र ती मिलेर composite primary key बन्छ। जस्तै विद्यार्थी र विषयबीचको M:N सम्बन्धका लागि ENROLLMENT(Roll, SubjectID) तालिका बनाइन्छ।
NEB कक्षा १२ मा Unit 1 बाट कति अंक आउँछ?
Unit 1 लाई पाठ्यक्रमले 80 मध्ये 12 शिक्षण घण्टा दिएको छ — करिब 15%। लिखित बोर्ड पेपर 50 अंकको हुने हुनाले Unit 1 बाट सामान्यतया 6–8 अंक आउँछ। प्रायः एउटा लामो वा छोटो उत्तर (normalization, DBMS का फाइदा-बेफाइदा, वा database model) र केही वस्तुगत प्रश्न सोधिन्छन्।
यो unit राम्रोसँग तयार गर्न के अभ्यास गर्ने?
तीन कुरा अभ्यास गर्नुहोस्: (१) Normalization — एउटै तालिका लिएर 1NF, 2NF, 3NF सम्म हातले टुक्र्याउने; (२) ER diagram — आयत, अण्डाकार र diamond सहित कोर्ने, र cardinality लेख्ने; (३) SQL — CREATE, INSERT, SELECT, UPDATE, DELETE पाँचै आदेश सम्झेर लेख्ने। यी तीनमा diagram र उदाहरण माग्ने भएकाले अंक पक्का हुन्छ।
Related reading on CSSNepal
- DBMS Explained: Keys, ER Models and Normalization — यही विषयको गहिरो अंग्रेजी संस्करण, मापन गरिएका उदाहरण र थप diagram सहित। यो पाना बुझेपछि त्यो पढ्नुहोस्।
- Free SQL Lab — browser मै MySQL query चलाएर तालिका बदलिएको हेर्नुहोस्; यस unit का SQL आदेश अभ्यास गर्न उत्तम।
- Class 12 Computer Science notes — सातै unit को मुख्य पाना।
- Query processing in a DBMS — SQL चलाउँदा डेटाबेसले भित्र के गर्छ (पाठ्यक्रमभन्दा माथि, रुचि भए)।
- NoSQL databases — relational नभएका डेटाबेस के हुन् र किन आए।
