© 2026 schoolict.net (Ruwan Mangala Suraweera)
8.3 DBMS and SQL: DDL and DMLDBMS සහ SQL: DDL සහ DML
Grade 13 A/L ICT · Lesson 813 ශ්රේණිය A/L ICT · පාඩම 8
In this videoමේ වීඩියෝවේ
- A DBMS sits between users and stored data.DBMS පරිශීලකයින් සහ දත්ත අතර ඇත.
- DDL = CREATE, ALTER, DROP.DDL = CREATE, ALTER, DROP.
- DML = INSERT, SELECT, UPDATE, DELETE.DML = INSERT, SELECT, UPDATE, DELETE.
- WHERE filters rows; ORDER BY sorts; GROUP BY groups.WHERE පෙරයි; ORDER BY පිළිවෙළ කරයි; GROUP BY කාණ්ඩ කරයි.
- INNER JOIN combines tables on matching keys.INNER JOIN ගැළපෙන යතුරු මත වගු එක් කරයි.
Notesසටහන්
Syllabus 8.3. A Database Management System (DBMS) is the software between users and the stored data. We talk to it with SQL. DDL (CREATE, ALTER, DROP) defines the structure; DML (INSERT, SELECT, UPDATE, DELETE) works with the data, including queries on one table and inner joins on several tables.විෂය නිර්දේශය 8.3. දත්ත සමුදාය කළමනාකරණ පද්ධතිය (DBMS) පරිශීලකයින් සහ ගබඩා කළ දත්ත අතර ඇති මෘදුකාංගයයි. අපි එය සමඟ SQL මගින් කතා කරමු. DDL (CREATE, ALTER, DROP) ව්යුහය නිර්වචනය කරයි; DML (INSERT, SELECT, UPDATE, DELETE) දත්ත සමඟ ක්රියා කරයි – එක් වගුවක විමසුම් සහ වගු කිහිපයක inner join ද ඇතුළුව.
1. Components of a database system1. දත්ත සමුදාය පද්ධතියක සංරචක
- Hardware and software (the DBMS, e.g. MySQL).දෘඩාංග සහ මෘදුකාංග (DBMS, උදා: MySQL).
- Data and the data dictionary (metadata).දත්ත සහ දත්ත ශබ්දකෝෂය (metadata).
- Users: end users, programmers and the database administrator (DBA).පරිශීලකයින්: අවසාන පරිශීලකයින්, ක්රමලේඛකයින් සහ DBA.
- Procedures: rules for backup, security and access.ක්රියා පටිපාටි: උපස්ථ, ආරක්ෂාව සහ ප්රවේශ නීති.
2. SQL and its classification2. SQL සහ එහි වර්ගීකරණය
| Groupකාණ්ඩය | Purposeඅරමුණ | Commandsවිධාන |
|---|---|---|
| DDLDDL | Define structureව්යුහය නිර්වචනය | CREATE, ALTER, DROPCREATE, ALTER, DROP |
| DMLDML | Work with dataදත්ත සමඟ ක්රියා | INSERT, SELECT, UPDATE, DELETEINSERT, SELECT, UPDATE, DELETE |
| DCLDCL | Control accessප්රවේශ පාලනය | GRANT, REVOKEGRANT, REVOKE |
3. DDL: creating and changing structure3. DDL: ව්යුහය සෑදීම සහ වෙනස් කිරීම
📝 DDL commands (SQL)DDL විධාන (SQL)
CREATE DATABASE SchoolDB; USE SchoolDB; -- add and remove a column ALTER TABLE Student ADD Phone VARCHAR(10); ALTER TABLE Student DROP COLUMN Phone; -- add and remove keys (MySQL style) ALTER TABLE Student ADD PRIMARY KEY (StudentID); ALTER TABLE Student ADD CONSTRAINT fk_class FOREIGN KEY (ClassID) REFERENCES Class(ClassID); ALTER TABLE Student DROP FOREIGN KEY fk_class; ALTER TABLE Student DROP PRIMARY KEY; -- remove objects DROP TABLE Marks; DROP DATABASE SchoolDB;
When we added Phone in sqlite3 the Student columns became StudentID, Name, ClassID, Phone; after DROP COLUMN they were StudentID, Name, ClassID; after DROP TABLE Marks the tables left were Class, Student.sqlite3 තුළ Phone එක් කළ විට Student තීරු StudentID, Name, ClassID, Phone විය; DROP COLUMN පසු StudentID, Name, ClassID; DROP TABLE Marks පසු ඉතිරි වගු Class, Student.
4. DML: inserting, updating and deleting4. DML: ඇතුළත් කිරීම, යාවත්කාලීන කිරීම සහ මකා දැමීම
📝 DML commands (SQL)DML විධාන (SQL)
INSERT INTO Student (StudentID, Name, ClassID) VALUES ('S006', 'Dilini', 'C12B'); UPDATE Marks SET Mark = Mark + 5 WHERE SubjectCode = 'ICT' AND Mark < 50; DELETE FROM Marks WHERE SubjectCode = 'MATH' AND Mark < 60;
INSERT adds 1 row (students now 6). UPDATE changes 2 rows (S002 45→50, S005 39→44). DELETE removes 1 row (S003 MATH 55), leaving 7 mark rows.INSERT පේළි 1 ක් එක් කරයි (සිසුන් 6). UPDATE පේළි 2 ක් වෙනස් කරයි (S002 45→50, S005 39→44). DELETE පේළි 1 ක් ඉවත් කරයි; ලකුණු පේළි 7 ක් ඉතිරි වේ.
5. SELECT queries5. SELECT විමසුම්
📝 Single-table queriesඑක් වගු විමසුම්
SELECT Name FROM Student WHERE ClassID = 'C12A' ORDER BY Name; SELECT AVG(Mark) FROM Marks WHERE SubjectCode = 'ICT'; SELECT ClassID, COUNT(*) FROM Student GROUP BY ClassID ORDER BY ClassID;
| Queryවිමසුම | Resultප්රතිඵලය |
|---|---|
| Students in C12A (by name)C12A සිසුන් (නම අනුව) | Kamala; Nimal; RuwanKamala; Nimal; Ruwan |
| Average ICT markසාමාන්ය ICT ලකුණ | 62.462.4 |
| Students per classපන්තියකට සිසුන් | C12A, 3; C12B, 2C12A, 3; C12B, 2 |
📝 Inner join queriesInner join විමසුම්
SELECT Student.Name, Class.Teacher FROM Student INNER JOIN Class ON Student.ClassID = Class.ClassID WHERE Class.ClassName = '12B' ORDER BY Student.Name; SELECT Student.Name, Marks.Mark FROM Student INNER JOIN Marks ON Student.StudentID = Marks.StudentID WHERE Marks.SubjectCode = 'ICT' AND Marks.Mark >= 60 ORDER BY Marks.Mark DESC;
| Query 1: Nameවිමසුම 1: නම | Teacherගුරු |
|---|---|
| AmaliAmali | SilvaSilva |
| SunilSunil | SilvaSilva |
| Query 2: Nameවිමසුම 2: නම | ICT markICT ලකුණ |
|---|---|
| SunilSunil | 8888 |
| NimalNimal | 7878 |
| AmaliAmali | 6262 |
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1List four components of a database system.සංරචක හතරක්.
2Distinguish DDL and DML.DDL සහ DML වෙනස.
3Write SQL to add a Phone column to Student.Phone තීරුව එක් කරන SQL.
4What does the C12A query return?C12A විමසුම ලබා දෙන්නේ?
5What is the average ICT mark?සාමාන්ය ICT ලකුණ?
6Who are the 12B students and their teacher?12B සිසුන් සහ ගුරුවරයා?
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1CREATE, ALTER and DROP belong toCREATE, ALTER, DROP
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
DDL.DDL.
2INSERT, UPDATE and DELETE belong toINSERT, UPDATE, DELETE
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
DML.DML.
3The command that removes a whole table isවගුව ඉවත් කිරීම
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
DROP.DROP.
4Rows changed by the UPDATE (+5 to ICT marks under 50) areUPDATE පේළි
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
S002, S005.S002, S005.
5The average ICT mark of the sample data isසාමාන්යය
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
312 ÷ 5.312 ÷ 5.
6The 12B join query returns12B
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
Matching ClassID.ClassID ගැළපීම.
7ICT marks of 60 or more, highest first, are60 හෝ වැඩි
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
ORDER BY DESC.ORDER BY DESC.
8Who controls security and backup of a database?ආරක්ෂාව
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
DBA.DBA.
9Which term means: “Software that creates, manages and controls access to a database”?“දත්ත සමුදාය සාදන, කළමනාකරණය කරන සහ ප්රවේශය පාලනය කරන මෘදුකාංගය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
DBMS – Software that creates, manages and controls access to a database.DBMS – දත්ත සමුදාය සාදන, කළමනාකරණය කරන සහ ප්රවේශය පාලනය කරන මෘදුකාංගය.
10Which term means: “Standard language for defining and querying relational databases”?“සම්බන්ධතා දත්ත සමුදාය නිර්වචනයට සහ විමසීමට සම්මත භාෂාව” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
SQL – Standard language for defining and querying relational databases.SQL – සම්බන්ධතා දත්ත සමුදාය නිර්වචනයට සහ විමසීමට සම්මත භාෂාව.
11Which term means: “SQL commands that define database structure”?“දත්ත සමුදාය ව්යුහය නිර්වචනය කරන SQL විධාන” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
DDL – SQL commands that define database structure.DDL – දත්ත සමුදාය ව්යුහය නිර්වචනය කරන SQL විධාන.
12Which term means: “SQL commands that insert, read, change and delete data”?“දත්ත ඇතුළත්, කියවීම, වෙනස් සහ මකන SQL විධාන” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
DML – SQL commands that insert, read, change and delete data.DML – දත්ත ඇතුළත්, කියවීම, වෙනස් සහ මකන SQL විධාන.
13Which term means: “SQL commands that grant or revoke access”?“ප්රවේශය ලබා දෙන හෝ අහෝසි කරන SQL විධාන” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
DCL – SQL commands that grant or revoke access.DCL – ප්රවේශය ලබා දෙන හෝ අහෝසි කරන SQL විධාන.
14Which term means: “Command that makes a new table with columns and types”?“තීරු සහ වර්ග සහිත නව වගුවක් සාදන විධානය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
CREATE TABLE – Command that makes a new table with columns and types.CREATE TABLE – තීරු සහ වර්ග සහිත නව වගුවක් සාදන විධානය.
15Which term means: “Command that changes the structure of an existing table”?“පවතින වගුවක ව්යුහය වෙනස් කරන විධානය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
ALTER TABLE – Command that changes the structure of an existing table.ALTER TABLE – පවතින වගුවක ව්යුහය වෙනස් කරන විධානය.
16Which term means: “Command that deletes a whole table and its data”?“සම්පූර්ණ වගුවක් සහ එහි දත්ත මකන විධානය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
DROP TABLE – Command that deletes a whole table and its data.DROP TABLE – සම්පූර්ණ වගුවක් සහ එහි දත්ත මකන විධානය.
17Which term means: “Command that retrieves rows and columns”?“පේළි සහ තීරු ලබා ගන්නා විධානය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
SELECT – Command that retrieves rows and columns.SELECT – පේළි සහ තීරු ලබා ගන්නා විධානය.
18Which term means: “Combines rows of two tables where key values match”?“යතුරු අගයන් ගැළපෙන තැන වගු දෙකක පේළි එක් කරයි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
INNER JOIN – Combines rows of two tables where key values match.INNER JOIN – යතුරු අගයන් ගැළපෙන තැන වගු දෙකක පේළි එක් කරයි.
19Which term means: “Command that changes values in existing rows”?“පවතින පේළිවල අගයන් වෙනස් කරන විධානය” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
UPDATE – Command that changes values in existing rows.UPDATE – පවතින පේළිවල අගයන් වෙනස් කරන විධානය.
20Which term means: “Person who manages security, backup and performance of a database”?“දත්ත සමුදායේ ආරක්ෂාව, උපස්ථ සහ කාර්ය සාධනය කළමනාකරණය කරන්නා” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
Database administrator – Person who manages security, backup and performance of a database.දත්ත සමුදාය පරිපාලක – දත්ත සමුදායේ ආරක්ෂාව, උපස්ථ සහ කාර්ය සාධනය කළමනාකරණය කරන්නා.
MCQ answer keyMCQ පිළිතුරු
- B – DDL.DDL.
- C – DML.DML.
- D – DROP.DROP.
- B – S002, S005.S002, S005.
- E – 312 ÷ 5.312 ÷ 5.
- E – Matching ClassID.ClassID ගැළපීම.
- A – ORDER BY DESC.ORDER BY DESC.
- C – DBA.DBA.
- A – DBMS – Software that creates, manages and controls access to a database.DBMS – දත්ත සමුදාය සාදන, කළමනාකරණය කරන සහ ප්රවේශය පාලනය කරන මෘදුකාංගය.
- B – SQL – Standard language for defining and querying relational databases.SQL – සම්බන්ධතා දත්ත සමුදාය නිර්වචනයට සහ විමසීමට සම්මත භාෂාව.
- A – DDL – SQL commands that define database structure.DDL – දත්ත සමුදාය ව්යුහය නිර්වචනය කරන SQL විධාන.
- E – DML – SQL commands that insert, read, change and delete data.DML – දත්ත ඇතුළත්, කියවීම, වෙනස් සහ මකන SQL විධාන.
- D – DCL – SQL commands that grant or revoke access.DCL – ප්රවේශය ලබා දෙන හෝ අහෝසි කරන SQL විධාන.
- D – CREATE TABLE – Command that makes a new table with columns and types.CREATE TABLE – තීරු සහ වර්ග සහිත නව වගුවක් සාදන විධානය.
- C – ALTER TABLE – Command that changes the structure of an existing table.ALTER TABLE – පවතින වගුවක ව්යුහය වෙනස් කරන විධානය.
- A – DROP TABLE – Command that deletes a whole table and its data.DROP TABLE – සම්පූර්ණ වගුවක් සහ එහි දත්ත මකන විධානය.
- C – SELECT – Command that retrieves rows and columns.SELECT – පේළි සහ තීරු ලබා ගන්නා විධානය.
- D – INNER JOIN – Combines rows of two tables where key values match.INNER JOIN – යතුරු අගයන් ගැළපෙන තැන වගු දෙකක පේළි එක් කරයි.
- B – UPDATE – Command that changes values in existing rows.UPDATE – පවතින පේළිවල අගයන් වෙනස් කරන විධානය.
- E – Database administrator – Person who manages security, backup and performance of a database.දත්ත සමුදාය පරිපාලක – දත්ත සමුදායේ ආරක්ෂාව, උපස්ථ සහ කාර්ය සාධනය කළමනාකරණය කරන්නා.
Structured Questionsව්යුහගත ප්රශ්න
1Describe the components of a database system.සංරචක විස්තර කරන්න. (5 marksලකුණු 5)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Write SQL to create database SchoolDB and table Class with a primary key.SchoolDB සහ Class. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3Write SQL to add then remove a foreign key on Student.ClassID.FK එක් කර ඉවත් කිරීම. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4Write SQL to add 5 marks to ICT marks below 50 and state rows changed.ලකුණු 5 එක් කිරීම. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5Write an inner join listing each 12B student with the teacher, and give the output.12B inner join. (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- A DBMS sits between users and stored data.DBMS පරිශීලකයින් සහ දත්ත අතර ඇත.
- DDL = CREATE, ALTER, DROP.DDL = CREATE, ALTER, DROP.
- DML = INSERT, SELECT, UPDATE, DELETE.DML = INSERT, SELECT, UPDATE, DELETE.
- WHERE filters rows; ORDER BY sorts; GROUP BY groups.WHERE පෙරයි; ORDER BY පිළිවෙළ කරයි; GROUP BY කාණ්ඩ කරයි.
- INNER JOIN combines tables on matching keys.INNER JOIN ගැළපෙන යතුරු මත වගු එක් කරයි.
