You are on page 1of 5

G.C.E.

Advanced Level – 2020 (Paper Class)


INFORMATION COMMUNICATION TECHNOLOGY

Tutorial 24 (Feb – 2)

SQL JOIN [Source : https://www.dofactory.com]

 A SQL JOIN combines records from two tables.


 A JOIN locates related column values in the two tables.
 A query can contain zero, one, or multiple JOIN operations.
 INNER JOIN is the same as JOIN; the keyword INNER is optional.

Different types of JOINs

 (INNER) JOIN: Select records that have matching values in both tables.
 LEFT (OUTER) JOIN: Select records from the first (left-most) table with matching right table
records.
 RIGHT (OUTER) JOIN: Select records from the second (right-most) table with matching left
table records.
 FULL (OUTER) JOIN: Selects all records that match either left or right table records.

All INNER and OUTER keywords are optional.

© m%no
q aO Y%Sud,a - www.apepanthiya.lk 2020
© m%no
q aO Y%Sud,a - www.apepanthiya.lk 2020
© m%no
q aO Y%Sud,a - www.apepanthiya.lk 2020
Answer all questions

1. Consider the hotel schema given below.


my; i`oyka fydag,a fjkalsÍï o;a; iuqodh fudv,h i<lkak'

Hotel ( HotelNo, HotelName, city)


Room (RoomNo, HotelNo, type, price)
Booking ( HotelNo, GuestNo, dateFrom, dateTo, RoomNo)
Guest ( GuestNo, GuestName, GuestAddress)

Write the following queries in SQL:


my; wjYH;d i`oyd SQL m%ldY ,shkak'

a) List details of all hotels in Colombo.


fld<U ish¨ fydag,a j, úia;r ,nd .ekSug

b) List the names and addresses of all guests living in Colombo, alphabetically Ordered by
name.
ක ොලඹ නගරකේ ජීවත්වන සියලුම ආගන්තු යන්තකේ නම් සහ ලිපිනයන්ත අ ොරොදී පිළිකවලින්ත ,nd
.ekSug

c) Convert the tables into Entity Relational model. (ER diagram) Consider the following details
for your diagram.
by; iïnkaê; fudv,h j.= njg පරිවර්ථනය රන්තන. (ER සටහන) ඔකේ රූප සටහk i`oyd
පහත විස්තර බලන්තන.

Hotel-Room (1:M) Guest-Room (M:N)

2. You have gotten a job planning databases for the European Union. Your first on job assignment is
to help the various countries maintain information about their inhabitants. Your model should
capture the following information:

ඔබg යුකරෝපීය සංගමය සඳහො දත්ත සමුදොයක් නිර්මොණය lsÍug mejÍ ඇත. ඔබg පළමුකවන්තම mejÍ
we;af;a විවිධ රටවල ඔවුන්තකේ වැසියන්ත ගැන කතොරුරු පවත්වො ගැනීමට උදව් jk o;a; iuqodhla ks¾udKh
lsÍughs. ඔකේ ආ ෘතිය i`oyd පහත සඳහන්ත කතොරුරු ,nd ගත යුුය

 In each country, there are provinces, which contain towns. There cannot be two
provinces with the same name in a single country. Similarly, there cannot be two towns
with the same name in a single province.
 People live in towns. Men and women work in a town. Children learn in a school in a
town.
 A person can be a man, a woman, or a child, and has a first-name, last-name, id, and
birthday. Children are any people under the age of 18.
 A man can be married to a woman (polygamy is not allowed, i.e., one man can be
married only to one woman).
 For each marriage, store the date of the marriage and information about who are the
children of the married couple. You should assume that the parents of a child were
married at the time of his birth.

© m%no
q aO Y%Sud,a - www.apepanthiya.lk 2020
- සෑම රට ම, නගර සහිත m<d;a ඇත. එක් රට එ ම නමක් සහිත පළොත් කද ක් තිබිය
කනොහැකිය. ඒ හො සමොනව, එක් පළොත එ ම නමක් සහිත නගර කද ක් කනොමැත.
- මිනිසුන්ත ජීවත් වන්තකන්ත නගරවලය. පිරිමි සහ ොන්තතොවන්ත නගරය වැඩ රhs. ළමයින්ත
නගරය පොසැල ඉකගන ගkS'
- පුද්ගලකයකුට පුරුෂකයකු, ස්ත්රිය කහෝ දරුවො විය හැකි අතර, පළමු නම, අන්තතිම නම,
හැඳුනුම සහ උපන්ත දිනය කව්. ළමුන්ත වයස අවුරුදු 18 ට අඩු අය කවති.
- පුරුෂකයකුට ොන්තතොවක් සමඟ විවොහ විය හැකිය (බහු විවොහයට අවසර නැත).
- සෑම විවොහයක් සඳහොම, විවොහ යුවළකේ දරුවන්ත වුරුන්තදැයි යන්තන හො විවොහය පිළිබඳ
කතොරුරු ගබඩො ර තබන්තන. දරුවොකේ කදමව්පියන්ත උපන්ත කව්ලොකව්දී විවොහ වූ බව
අනුමොන ළ යුුය.

i. Draw an entity relationship diagram to model the information described above.


ඉහත විස්තර ර ඇති ආ ෘති සෑදීමට ව්යුහ සබඳතො රූපයක් අඳින්තන (ER diagram)

( Underline the key attributes of each entity in the diagram. If you use the ISA relationship,
state any covering and overlap constraints that hold. Make any necessary and logical
assumptions. State any such assumptions clearly. If there are any constraints in the problem
that could not be expressed in the diagram, state these clearly.)

(රූපසටහකනහි එක් එක් ආයතනකයහි ප්රධොන ගුණොංගයන්ත අවධොරණය රන්තන. ඔබ ISA සම්බන්තධතොව
භොවිතො රන්තකන්ත නම්, එය ඕනෑම ආවරණ සහ යටපත් කිරීකම් සීමොවන්ත සඳහන්ත රන්තන.ඔකේ අවශ්ය හො
තොර්කි උප ල්පන සොදන්තන.අකනකුත් එවැනි උප ල්පනයන්ත පැහැදිලිව සඳහන්ත රන්තන.)

******

© m%no
q aO Y%Sud,a - www.apepanthiya.lk 2020

You might also like