| Year | Module |
|---|---|
| 2005 |
FCS |
| 2006 |
FCS |
| 2007 |
FCS |
| 2008 |
FCS DB1 |
| 2009 |
FCS ITA ST1 DB1 |
| 2010 |
FCS ITA ST1 DB1 |
| 2011 |
FCS ITA ST1 |
| 2012 |
FCS ITA ST1 |
| 2013 |
FCS ITA |
Sunday, July 31, 2016
PastPaper Answers For the 1st Year 2nd Semester(Mid)
Saturday, July 9, 2016
DBMS Lesson 5 SQL Part 4
This post will be a continuation of the previous post.Today our discussion is about Group By clause and Having clause.අද කතා කරන්නේ පෙර පෝස්ටුවේ ඉතිරි කොටසයි.Group By රීතිය සහ Having රීතිය භාවිතය අද පාඩමෙන් කියා දෙනු ලැබේ.
If you haven't read my previous lessons please follow below links.පෙර පාඩම් මාලාව සදහා පිවිසෙන්න
Lesson 1,Lesson 2,Lesson 3,Lesson 4 Part 1,Lesson 4 Part 2,Lesson 5 Part 1,Lesson 5 Part 2,Lesson 5 Part 3
Firstly we'll start with Group By clause/පලමුව Group By රීතිය ගැන බලමු.
Syntax:
Select < attributes > From < relations > Where < conditions >Group By < attributes > Order By < attributes > asc/desc
Let's take a look at some examples
These examples are based on the tables given in the Lesson 5 Part 3.So before that go through the tables given earlier.පහත උදාහරණ සියල්ල පෙර පෝස්ටුවේ වගු ආශ්රිතව දිග හැරේ.එම නිසා පෙර පෝස්ටුව ප්රතමයෙන් අධ්යනය කරන්න.
Example 1:
Q: Find the total quantity supplied for each project
A: Select JNo,sum(Qty) from Shipment Group by JNo
Example 2:
Q: Find the minimum quantity supplied by each supplier
A: Select SNo,min(Qty) from Shipment Group by SNo
Example 3:
Q: Display the average quantity supplied for each project in descending order of project number
A: Select JNo,avg(Qty) from Shipment Group byJNo Order by JNo desc
Example 4:
Q: Count the number of parts supplied by each supplier and display in ascending order of supplier number
A: Select SNo,count(Distinct PNo) from Shipment Group by SNo order by SNo asc
Example 5:
Q: Find the total quantity supplied in each part and display the results in descending order of part number.For this query Qty more than 100 will not be valid
A: Select PNo,sum(Qty) from Shipment where Qty<=100 Group by PNo Order by PNo desc
Using Having clause
Syntax:
Select < attribute > From < relations > Where < conditions > Group By < attribute > Having < conditions > Order By < attributes > asc/desc
Example 1:
Q: Find the projects having total quantity supplied more than 150
A: Select JNo from Shipment Group by JNo Having sum(Qty)>150
Example 2:
Q: Find the suppliers who supply at least 2 parts
A: Select SNo from Shipment Group by SNo Having count(Distinct PNo)>=2
Example 3:
Q: Display the project numbers in ascending order where more than 3 suppliers supplying parts
A: Select JNo from Shipment Group by JNo Having count(Distinct PNo)>3 order by JNo asc
Example 4:
Q: Display the part numbers in descending order where average quantity supplied is more than 50.For this query, quantity more than 100 are not valid
A: Select PNo From Shipment Where Qty <100 Group by PNo Having avg(Qty) > 50 Order by PNo desc
Click Here To Download This Lesson in PDF Format
So far we have discuss data retrieving.Next Post will be based on data insertion.ඊලග පෝස්ටුව වගුවකට දත්ත ඇතුලත් කිරීම පිලිබදව කතා කෙරේ.Keep in touch...
If you haven't read my previous lessons please follow below links.පෙර පාඩම් මාලාව සදහා පිවිසෙන්න
Lesson 1,Lesson 2,Lesson 3,Lesson 4 Part 1,Lesson 4 Part 2,Lesson 5 Part 1,Lesson 5 Part 2,Lesson 5 Part 3
Firstly we'll start with Group By clause/පලමුව Group By රීතිය ගැන බලමු.
Syntax:
Select < attributes > From < relations > Where < conditions >Group By < attributes > Order By < attributes > asc/desc
Let's take a look at some examples
These examples are based on the tables given in the Lesson 5 Part 3.So before that go through the tables given earlier.පහත උදාහරණ සියල්ල පෙර පෝස්ටුවේ වගු ආශ්රිතව දිග හැරේ.එම නිසා පෙර පෝස්ටුව ප්රතමයෙන් අධ්යනය කරන්න.
Example 1:
Q: Find the total quantity supplied for each project
A: Select JNo,sum(Qty) from Shipment Group by JNo
Example 2:
Q: Find the minimum quantity supplied by each supplier
A: Select SNo,min(Qty) from Shipment Group by SNo
Example 3:
Q: Display the average quantity supplied for each project in descending order of project number
A: Select JNo,avg(Qty) from Shipment Group byJNo Order by JNo desc
Example 4:
Q: Count the number of parts supplied by each supplier and display in ascending order of supplier number
A: Select SNo,count(Distinct PNo) from Shipment Group by SNo order by SNo asc
Example 5:
Q: Find the total quantity supplied in each part and display the results in descending order of part number.For this query Qty more than 100 will not be valid
A: Select PNo,sum(Qty) from Shipment where Qty<=100 Group by PNo Order by PNo desc
Using Having clause
Syntax:
Select < attribute > From < relations > Where < conditions > Group By < attribute > Having < conditions > Order By < attributes > asc/desc
Example 1:
Q: Find the projects having total quantity supplied more than 150
A: Select JNo from Shipment Group by JNo Having sum(Qty)>150
Example 2:
Q: Find the suppliers who supply at least 2 parts
A: Select SNo from Shipment Group by SNo Having count(Distinct PNo)>=2
Example 3:
Q: Display the project numbers in ascending order where more than 3 suppliers supplying parts
A: Select JNo from Shipment Group by JNo Having count(Distinct PNo)>3 order by JNo asc
Example 4:
Q: Display the part numbers in descending order where average quantity supplied is more than 50.For this query, quantity more than 100 are not valid
A: Select PNo From Shipment Where Qty <100 Group by PNo Having avg(Qty) > 50 Order by PNo desc
Click Here To Download This Lesson in PDF Format
So far we have discuss data retrieving.Next Post will be based on data insertion.ඊලග පෝස්ටුව වගුවකට දත්ත ඇතුලත් කිරීම පිලිබදව කතා කෙරේ.Keep in touch...
Labels:
1year-2sem,
DBMS,
English,
Sinhala,
SQL
Thursday, July 7, 2016
DBMS Lesson 5 SQL Part 3
Today we are going to discuss how to order results.අද අපි කතා කරන්නේ කොහොමද ප්රතිපලයක් පිලිවෙලකට හදා ගන්නේ කියලා.If you haven't gone through previous lessons click below links.පෙර පාඩම් මාලාව සදහා පිවිසෙන්න..
Lesson 1,Lesson 2,Lesson 3,Lesson 4 Part 1,Lesson 4 Part 2,Lesson 5 Part 1,Lesson 5 Part 2
Ordering Of Results
Select < attribute > From < relation> [ Where < conditions > ] [ Order by < attribute > asc/desc ]
asc(ascending) - ආරෝහන( කුඩා අගයක සිට විශාල අගයකට )
desc(descending) - අවරෝහන( විශාල අගයක සිට කුඩා අගයකට )

Example 1:
Q: Display Supplier details in ascending order of name
A: Select * from Supplier order by Name asc
Example 2:
Q: Display cities of Suppliers in descending order
A:Select Distinct City from Supplier order by City desc
Example 3:
Q: Display name and status of Suppliers those who are in Colombo in descending order of names
A: Select Name,Status from Supplier where City='Colombo' order by Name desc
Example 4:
Q: Display details of suppliers in descending order of status of those who are in Colombo and those status>30
A: Select * from Supplier where City='Colombo' and Status>30 order by Status desc
Example 5:
Q: Display branch names of accounts in ascending order where balance between 2000 and 5000
A: Select BrName from Account where Balance between 2000 and 5000 order by BrName asc
Example 6:
Q: Display account numbers of accounts in Galle branch in descending order
A: Select AccNo from Accounts where BrName='Galle' order by AccNo desc
Example 7:
Q: Display details in Account table where balance in ascending order and account names in descending order
A: Select * from Accounts order by AccNames desc,Balance asc
Next we'll talk about Aggregate Value Functions
Lesson 1,Lesson 2,Lesson 3,Lesson 4 Part 1,Lesson 4 Part 2,Lesson 5 Part 1,Lesson 5 Part 2
Ordering Of Results
Select < attribute > From < relation> [ Where < conditions > ] [ Order by < attribute > asc/desc ]
asc(ascending) - ආරෝහන( කුඩා අගයක සිට විශාල අගයකට )
desc(descending) - අවරෝහන( විශාල අගයක සිට කුඩා අගයකට )

Example 1:
Q: Display Supplier details in ascending order of name
A: Select * from Supplier order by Name asc
Example 2:
Q: Display cities of Suppliers in descending order
A:Select Distinct City from Supplier order by City desc
Example 3:
Q: Display name and status of Suppliers those who are in Colombo in descending order of names
A: Select Name,Status from Supplier where City='Colombo' order by Name desc
Example 4:
Q: Display details of suppliers in descending order of status of those who are in Colombo and those status>30
A: Select * from Supplier where City='Colombo' and Status>30 order by Status desc
Example 5:
Q: Display branch names of accounts in ascending order where balance between 2000 and 5000
A: Select BrName from Account where Balance between 2000 and 5000 order by BrName asc
Example 6:
Q: Display account numbers of accounts in Galle branch in descending order
A: Select AccNo from Accounts where BrName='Galle' order by AccNo desc
Example 7:
Q: Display details in Account table where balance in ascending order and account names in descending order
A: Select * from Accounts order by AccNames desc,Balance asc
Next we'll talk about Aggregate Value Functions
- SUM() - To find the total/එකතු කිරීම් සදහා
- AVG() - To find the average/සාමාන්ය සෙවීම සදහා
- MAX() - To find the maximum value/වැඩිම අගය සෙවීම සදහා
- MIN() - To find the minimum value/අවම අගය සෙවීම සදහා
- COUNT() - To find the number of instances/ප්රමානය සෙවීම සදහා
- ROUND() - To round off to nearest number/ආසන්නතම අන්කයට වැටයීම සදහා
Lets see these functions through examples/උදාහරණ මගින් විමසමු....
Example 1:
Q: Count the number of projects
A: Select count(JNo) from Project
Example 2:
Q: Find the average status of suppliers
A: Select avg(Status) from Suppliers
Example 3:
Q: Find the minimum quantity supplied for a project
A: Select min(Qty) from Shipment
Example 4:
Q: Find the average quantity supplied by supplier S3
A: Select avg(Qty) from Shipment where SNo='S3'
Example 5:
Q: Count the number of parts supplied by supplier S2 for different projects
A: Select count(Distinct PNo) from Shipment where SNo='S2'
Example 6:
Q: Find the Suppliers who supplied maximum quantity for a project
A: Select SNo from Shipment where Qty=(Select max(Qty) from Shipment)
Query inside the brackets is called as a Sub Query and it works first before the main query gets executed.වරහන් තුල ඇති function එක subquery එකක් වේ.ප්රතමයෙන් එය ක්රියාත්මක වන අතර ඉන් පසු main query එක ක්රියාත්මක වේ.
Click Here To download This Lesson in PDF Format
Next post will be on Grouping and Having clauses.Keep in touch....
DBMS Lesson 5 SQL Part 2
Today our Lesson is about DML.අද අපි කතාකරන්නේ DML ගැන.If you haven't gone through previous Lessons click below links.
Lesson 1,Lesson 2,Lesson 3,Lesson 4 part 1,Lesson 4 part 2,Lesson 5 part 1
What is DML?? DML කියන්නේ මොකක්ද??
Data Manipulation Language(DML) that provides set of operations to support basic data manipulation from a database.
DB එකක මූලික දත්ත මෙහෙයවීම් කිරීම සදහා ලබා දී ඇති ක්රියාවලීන්
Operations like/ක්රියාවලීන්
Lesson 1,Lesson 2,Lesson 3,Lesson 4 part 1,Lesson 4 part 2,Lesson 5 part 1
What is DML?? DML කියන්නේ මොකක්ද??
Data Manipulation Language(DML) that provides set of operations to support basic data manipulation from a database.
DB එකක මූලික දත්ත මෙහෙයවීම් කිරීම සදහා ලබා දී ඇති ක්රියාවලීන්
Operations like/ක්රියාවලීන්
- Retrieval of data/දත්ත ගැනීම්
- Insertion of data/දත්ත ඇතුලත් කිරීම්
- Modification of data/දත්ත වෙනස් කිරීම්
- Deletion of data in a database/දත්ත ඉවත් කිරීම්
Lets talk about how retrieve data from a created database.දත්ත ගැනීම් ගැන අප දැන් කතා කරමු.
There are several clauses used to do that.
DB එකක දත්ත ගැනීම සදහා clauses භාවිතා වේ.
DB එකක දත්ත ගැනීම සදහා clauses භාවිතා වේ.
- Select < attribute > From < relation > [ Where < condition > ]
Above written statement is called a QUERY and words like select,from,where etc are the CLAUSES.
ඉහත ලියා ඇති වගන්තිය Query වන අතර select,from,where යන ඒවා Clauses වේ.
Let's learn those clauses through examples....
Example 2:
Q:Display Cities of Suppliers
Example 3:
Q:Display Cities of Suppliers
Example 3:
Q:Display details of suppliers whose status more than 20
Example 4:
Q:Display number and names of suppliers who live in Jaffna
Example 5:
Q:Display details of Suppliers who live in Colombo or whose status equal to 20
Example 4:
Q:Display number and names of suppliers who live in Jaffna
Example 5:
Q:Display details of Suppliers who live in Colombo or whose status equal to 20
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A1:Select SNo,Name,Status,City From Supplier
A2:Select City from Supplier
or
Select * From Supplier
Clause like Distinct can be used to remove duplication
A2:Select Distinct City from Supplier
A3:Select * from Supplier Where Status > 20
A4:Select SNo,Name from Supplier Where City='Jaffna'
A5:Select * from Supplier Where City='Colombo' or Status=20
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Answer 1---> 

Note:Answers are given try them and go through the answers provided..
Click Here to download this lesson in PDF Format
Next post will be the continuation of this.Keep in Touch...
DBMS Lesson 5 SQL Part 1
Today I’ll begin a new lesson series related with DB. If you
haven’t study the previous lessons click below links.
අද මම අලුත් පාඩම් මාලාවක් ගෙන එනවා DB ආශ්රිතව.පරණ පෝස්ටු සදහා පහත ලින්ක් වෙත පිවිසෙන්න.
Today our topic is about STRUCTURED QUERY LANGUAGE (SQL)
අද අපගේ මාතෘකාව SQL
අද අපගේ මාතෘකාව SQL
So what is SQL??මොකක්ද SQL කියන්නේ??
- Database Programming Language(Not case sensitive)
- Design to retrieve and manage data in Relational Database Management System(RDBMS)
- RDBMS තියෙන දත්ත ගැනීමට සහා ඒවා පාලනය කිරීමට SQL හදුන්වා දී ඇත.
- First published by ANSI in 1986
- ANSI විසින් 1986 දී හදුන්වා දී ඇත.
DDL (Data Definition
Language) and DML (Data Manipulation Language).Now SQL supports DCL (Data
Control Language) as well.
By this lesson series we talk more about DML and little
about DDL. Later on you will get to know about those terms.
මෙම පාඩම් මාලාවෙන් DML ගැන වැඩියෙන් කතා කරන අතර DDL ගැනද කතා කරනු ලැබේ.
In order to create a database you can use several database softwares
like;
Database එකක් හදා ගන්න ඕන මුදෘකාන්ග කිහිපයකි.ඒවානම්;
Database එකක් හදා ගන්න ඕන මුදෘකාන්ග කිහිපයකි.ඒවානම්;
- SQL server
- MySQL
- Oracle
- SQL lite etc..
DB එකකින් දත්ත ලබා ගැනීමට ප්රතම DB එකක් හදා ගැනීමට දැන ගත යුතුය.DB එකක දත්ත වගු ලෙස ගබඩා වේ.එම නිසා අප එම වගු සෑදීමට දැන ගත යුතුය.
Inorder to create a database we use DDL statements.
වගු සෑදීමට DDL රීති භාවිතා වේ.
වගු සෑදීමට DDL රීති භාවිතා වේ.
DDL statements are used to build and modify the structure of your tables and database.When you execute a DDL statement, it takes effect immediately.
DDL රීති වගු සෑදීමට හා වෙනස් කිරීමට භවිතා කෙරේ.එම රීති වෙනස් කරමින් ක්ශනිකවම ප්රතිපලය ලබා ගත හැක.
Common way of creating a table
වගුවක් නිර්මාණය කිරීමට
- create table < table name > ( < attribute name 1> < data type>,< attribute name 2> < data type>,....,< attribute name n> < data type>)
Eg: creating a table named as Customers
create table Customers (C_no char(4),C_name varchar(25),Age int(3),Address varchar(50))
or
CREATE TABLE Customers (C_no CHAR(4),C_name VARCHAR(25),Age INT(3),Address VARCHAR(50))
Both give the same output/දෙකෙන්ම එකම ප්රතිපලය ලැබේ.
Deleting the created table/වගුවක් මකා දැමීමට
- Drop Table < name >
Eg: Drop table Customers
For permanent deletion of the table/වගුවක් නැවත ලබා ගැනීමට නොහැකි වන සේ මකා දැමීමට
- truncate table < name >
Eg: truncate table Customers
Table Alteration & Modification will be discussed later..
වගු වෙනස් කිරීම් කරන ආකාරය වෙන පෝස්ටුවක් මගින් පසුව විස්තර කරනු ඇත.
වගු වෙනස් කිරීම් කරන ආකාරය වෙන පෝස්ටුවක් මගින් පසුව විස්තර කරනු ඇත.
Next post will be based on DML......
Sunday, June 12, 2016
DBMS 1 Lesson 4 part 2
If You haven't studied Lessons posted earlier click below Links
Lesson 1,Lesson 2,Lesson 3,Lesson 4 part 1
2NF
After completing 1NF,result of it is Normalized into 2NF.
1NF හි ලැබුනු ප්රතිපලය 2NF කිරීමට යොදා ගැනේ.
Functional Dependency
A --------------> B,C
We call B,C are functionally depend on A.Here A is called Determinant & B,C are called Dependent.
B හා C හි අගයන් A මත රදා පවති.මෙහි A,Determinant වන අතර B,C; Dependent වේ.
Cno------------------>Cname,CLocation,Mno,Mname - Partial Dependency
Fno,Cno------------>Takings -Full Functional Dependency
Partial Dependency= Non Key depend on Part of the Composite P/K(Primary Key)
P/K හෝ Composite P/K නොවන අගයක් Composite P/K හි කොටසක් මත රදා පැවතීම
Eg: Non Keys(P/K හෝ Composite P/K නොවන අගයන්) Cname,CLocation,Mno,Mname & Part of the Composite P/K is Cno.
Full Functional Dependency=Non Key depend on Composite P/K
P/K හෝ Composite P/K නොවන අගයක් සම්පූර්ණ Composite P/K එක මත රදා පැවතීම
Eg: Non Key is Takings & Composite P/K is Fno,Cno.
Answer:
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
එම නිසා ඒ සියල්ල ඇතුලත්ව Cinema_2 නමින් 2NF හීදි ලිවිය යුතුය.මෙහිදි Cno එක Key එකක් වේ.අනෙක් ඒවා NonKey වේ.1NF මගින් ලියූ Showing_1 හී Cname,CLocation,Mno,Mname සියල්ල ඇතුලත්ව ඇත.අප 2NF හීදි Takings ඇර අනෙක් සියල්ල Cinema_2 හීදි ලියූ බැවින් -Showings තුල ඉතිරි වන්නේ Takings පමණයි.එම නිසා එය Showing_2 ලෙස ගෙන ලියා දක්වනවා.Film_1 එක Film_2 ලෙස කිසිදු වෙනසකින් තොරව 2NF හී ලියා දක්වනවා.
In 2NF Cname,CLocation depends on Cno.As well as Mno,Mname depends on Cname & CLocation.Therefore we can say Cname,CLocation,Mno,Mname depends on Cno.But Takings doesn't depend on any.
3NF
After completing 2NF,result of it is Normalized into 3NF.
Transitive Dependency
Non Key depend on a Non Key
Mno ------------------> Mname
When Mno changes Mname changes respectively.But both of these are not keys(P/K or Composite P/K).This is called Transitive Dependency.
Mno වෙනස් වෙද්දි Mname ඒ අනුව වෙනස් වෙනවා.නමුත් Mno හා Mname ,NonKeys.ඒ කියන්නේ දෙකම P/K හෝ Composite P/K නෙවෙයි.මේකට තමයි Transitive Dependency කියන්නේ.
Eg : When Mno is 1 Mname is always Green
When Mno is 2 Mname is always Wood
Answer:
------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------
Here we write a new one in 3NF as Manager_3 including Transitive Dependencies.From 2NF we already have Cinema_2.It Includes both Mno & Mname.Here Mno is a Key.Therefore we write new Cinema_3 excluding Mname but including Mno(Refer a similar case in 2NF Cno is Written in both Cinema_2 & Showing_2).As usual no changes happen to Showing & Film thereby they are written with different names without any change.
මෙහිදි Mno හා Mname ඇතුලත්ව Manager_3 නමින් 3NF හීදි ලියා දක්වයි.2NF මගින් අප ලියූ Showing_2 හී Mno හා Mname ඇතුලත්ව ඇත.Mno එක Key එකක් වන නිසා එය නවතම Cinema_3 හීදි ලියා දක්වන නමුත් Mname ලියනු නොලැබේ(මේ හා සමාන ලිවීමක් Cinema_2 හා Showing_2 ,2NF හීදි දැක ගත හැක.)මෙහිදි Film හා Showing කිසිදු බලපෑමක් නොමැති බැවින් Film_3 හා Showing_3 ලෙස ලියනු ලැබේ.
-------------------------------------------------------------------------------------------------------------------------------------------
Lesson 1,Lesson 2,Lesson 3,Lesson 4 part 1
2NF
After completing 1NF,result of it is Normalized into 2NF.
1NF හි ලැබුනු ප්රතිපලය 2NF කිරීමට යොදා ගැනේ.
Functional Dependency
A --------------> B,C
We call B,C are functionally depend on A.Here A is called Determinant & B,C are called Dependent.
B හා C හි අගයන් A මත රදා පවති.මෙහි A,Determinant වන අතර B,C; Dependent වේ.
Cno------------------>Cname,CLocation,Mno,Mname - Partial Dependency
Fno,Cno------------>Takings -Full Functional Dependency
Partial Dependency= Non Key depend on Part of the Composite P/K(Primary Key)
P/K හෝ Composite P/K නොවන අගයක් Composite P/K හි කොටසක් මත රදා පැවතීම
Eg: Non Keys(P/K හෝ Composite P/K නොවන අගයන්) Cname,CLocation,Mno,Mname & Part of the Composite P/K is Cno.
Full Functional Dependency=Non Key depend on Composite P/K
P/K හෝ Composite P/K නොවන අගයක් සම්පූර්ණ Composite P/K එක මත රදා පැවතීම
Eg: Non Key is Takings & Composite P/K is Fno,Cno.
Answer:
------------------------------------------------------------------------------------------------------------------------
- Cinema_2(Cno,Cname,CLocation,Mno,Mname)
- Showing_2(Fno
* ,Cno* ,Takings) - Film_2(Fno,Fname)
------------------------------------------------------------------------------------------------------------------------------------------------
2NF හීදි Cno මත Cname,CLocation රැදී පවතිනවා. Cname,CLocation මත Mno,Mname රැදී පවතින බැවින් Cno මත Cname,CLocation,Mno,Mname රැදී පවති.නමුත් Takings රැදී පවතින්නැ.
උදා: Fno : 15 Fno : 45
Cno : 1 Cno : 1
Cname : Odeon Cname : Odeon
CLocation : NewCastle CLocation : NewCastle
Mno : 1 Mno : 1
Mname : Green Mname : Green
Takings : 220 Takings : 600
එම නිසා ඒ සියල්ල ඇතුලත්ව Cinema_2 නමින් 2NF හීදි ලිවිය යුතුය.මෙහිදි Cno එක Key එකක් වේ.අනෙක් ඒවා NonKey වේ.1NF මගින් ලියූ Showing_1 හී Cname,CLocation,Mno,Mname සියල්ල ඇතුලත්ව ඇත.අප 2NF හීදි Takings ඇර අනෙක් සියල්ල Cinema_2 හීදි ලියූ බැවින් -Showings තුල ඉතිරි වන්නේ Takings පමණයි.එම නිසා එය Showing_2 ලෙස ගෙන ලියා දක්වනවා.Film_1 එක Film_2 ලෙස කිසිදු වෙනසකින් තොරව 2NF හී ලියා දක්වනවා.
Eg:Fno : 15 Fno : 45
Cno : 1 Cno : 1
Cname : Odeon Cname : Odeon
CLocation : NewCastle CLocation : NewCastle
Mno : 1 Mno : 1
Mname : Green Mname : Green
Takings : 220 Takings : 600
Therefore new Cinema_2 should be written including those in 2NF. In here Cno referred to be a Key and others are NonKeys.But in Showing_1 written in 1NF includes all of these.In 2NF we write Cno,Cname,CLocation,Mno,Mname in Cinema_2 except Takings.Thereby Only Takings remain in Showing_1 came from 1NF.Therefore we give a new name to Showing as Showing_2 in 2NF.As there are no changes in Film_1,we write same thing in 2NF as Film_2.
3NF
After completing 2NF,result of it is Normalized into 3NF.
Transitive Dependency
Non Key depend on a Non Key
Mno ------------------> Mname
When Mno changes Mname changes respectively.But both of these are not keys(P/K or Composite P/K).This is called Transitive Dependency.
Mno වෙනස් වෙද්දි Mname ඒ අනුව වෙනස් වෙනවා.නමුත් Mno හා Mname ,NonKeys.ඒ කියන්නේ දෙකම P/K හෝ Composite P/K නෙවෙයි.මේකට තමයි Transitive Dependency කියන්නේ.
Eg : When Mno is 1 Mname is always Green
When Mno is 2 Mname is always Wood
Answer:
------------------------------------------------------------------------------------------------------------------------
- Manager_3(Mno,Mname)
- Cinema_3(Cno,Cname,CLocation,Mno
* )
- Showing_3(Fno
* ,Cno* ,Takings)
- Film_3(Fno,Fname)
-----------------------------------------------------------------------------------------------------------------------------------------------
Here we write a new one in 3NF as Manager_3 including Transitive Dependencies.From 2NF we already have Cinema_2.It Includes both Mno & Mname.Here Mno is a Key.Therefore we write new Cinema_3 excluding Mname but including Mno(Refer a similar case in 2NF Cno is Written in both Cinema_2 & Showing_2).As usual no changes happen to Showing & Film thereby they are written with different names without any change.
මෙහිදි Mno හා Mname ඇතුලත්ව Manager_3 නමින් 3NF හීදි ලියා දක්වයි.2NF මගින් අප ලියූ Showing_2 හී Mno හා Mname ඇතුලත්ව ඇත.Mno එක Key එකක් වන නිසා එය නවතම Cinema_3 හීදි ලියා දක්වන නමුත් Mname ලියනු නොලැබේ(මේ හා සමාන ලිවීමක් Cinema_2 හා Showing_2 ,2NF හීදි දැක ගත හැක.)මෙහිදි Film හා Showing කිසිදු බලපෑමක් නොමැති බැවින් Film_3 හා Showing_3 ලෙස ලියනු ලැබේ.
-------------------------------------------------------------------------------------------------------------------------------------------
Final Complete Answer For Normalizing the table given upto 3NF
1NF
- Film_1(Fno,Fname)
- Showing_1(Fno
* ,Cno,Cname,CLocation,Mno,Mname,Takings)
2NF
- Cinema_2(Cno,Cname,CLocation,Mno,Mname)
- Showing_2(Fno
* ,Cno* ,Takings) - Film_2(Fno,Fname)
3NF
- Manager_3(Mno,Mname)
- Cinema_3(Cno,Cname,CLocation,Mno
* ) - Showing_3(Fno
* ,Cno* ,Takings) - Film_3(Fno,Fname)
Click Here To Download This Lesson in PDF Format
Subscribe to:
Posts (Atom)









