0% found this document useful (0 votes)
15 views4 pages

A ICT200 LabTest May2023

ict200 Answer

Uploaded by

2023602844
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

A ICT200 LabTest May2023

ict200 Answer

Uploaded by

2023602844
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CONFIDENTIAL CS/LAB TEST/MAY 2023/ICT200

UNIVERSITI TEKNOLOGI MARA


LAB TEST

COURSE : INTRODUCTION TO DATABASE DESIGN

COURSE CODE : ICT200

SEMESTER : MARCH – AUGUST 2023

DATE, TIME : 19TH MAY 2023 (FRIDAY), 3.00PM – 4.30PM

SUGGESTED ANSWERS
CONFIDENTIAL 2 CS/LAB TEST/MAY 2023/ICT200

QUESTION 1

Given the following relational schemas:

PLAYER (PlayerID, PlayerName, PlayerGender, PlayerAge, PlayerIncome, PlayerLevel,


PlayerContact, PlayerState)
TEAM (TeamID, TeamName, PlayerID*, Position)
GAME (ChampCode*, TeamID*, GameDate, GameTime)
CHAMPIONSHIP (ChampCode, ChampName, ChampLevel, ChampFee, ChampPrize)

Write the SQL commands to:

a) List all players' names, genders, and incomes. Display only those players who have gotten
more than RM50,000 and lives in Melaka. The output results must be sorted in descending
order by gender, followed by the income.
(3 marks)

SELECT PlayerName, PlayerGender, PlayerIncome (0.5m)


FROM PLAYER (0.5m)
WHERE PlayerIncome > 50000 (0.5m)
AND PlayerState = “Melaka” (0.5m)
ORDER BY PlayerGender DESC, PlayerIncome ASC (1.0m)

b) Displays the players' names, levels, and contacts whose last names end with the word
"Deraman" and the ages are between 15 and 25 years old, and the level of expert only.
Sort the output from younger to older player.
(5 marks)

SELECT PlayerName, PlayerLevel, PlayerContact (0.5m)


FROM PLAYER (0.5m)
WHERE PlayerName LIKE ‘%DERAMAN’ (1.0m)
AND PlayerAge BETWEEN 15 AND 25 (1.0m)
AND PlayerLevel = ‘Expert’ (1.0m)
ORDER BY PlayerAge ASC (1.0m)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 3 CS/LAB TEST/MAY 2023/ICT200

QUESTION 2

The following relational schemas derived from Al-Ansar Training Centre:

WORKSHOP (WSCode, WSName, StartDate, StartTime, VenueNum*, SpeakerCode*)


VENUE (VenueNum, VenueDesc, VenueLoc, VenueCapacity)
SPEAKER (SPCode, SPName, SPSex, SPPosition, SPPhone, SPAddress)
Note: VenueDesc = venue description, VenueLoc = venue location, SP = speaker

Based on above relational schemas, write the SQL commands to answer all questions given
below:

a) Display the names and addresses of speakers that the name begin with ‘Nurul’ and the
address is in Perak.
(3 marks)

SELECT SPName,SPAddress (0.5 mark)


FROM SPEAKER (0.5 mark)
WHERE SPName LIKE ‘ Nurul%’ AND (1.0 mark)
SPAddress LIKE ‘%Perak%’ (1.0 mark)

b) List workshop details for all workshops that are handled by speaker Dr. Nurhaliza Kamil.
(4 marks)

SELECT WSCode, WSName, StartDate, StartTime, SPCode, SPName, SPSex (1.0 mark)
FROM WORKSHOP W, SPEAKER S (1.0 mark)
WHERE S.SpeakerID = W.SpeakerID (1.0 mark)
AND SPName = ‘Dr Nurhaliza Kamil’ (1.0 mark)

c) Calculate how many workshops are handled by speaker Encik Amran Kassim. In output,
displays the speaker’s name and total workshop that he handled. Replace calculated
column name using TOTAL WORKSHOP.
(5 marks)

SELECT SPName, COUNT(*) AS ‘TOTAL WORKSHOP’ (1.0 mark)


FROM SPEAKER S, WORKSHOP W (1.0 mark)
WHERE S.SpeakerID = W.SpeakerID (1.0 mark)
AND SPName = ‘Encik Amran Kassim’ (1.0 mark)
GROUP BY SPName (1.0 mark)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 4 CS/LAB TEST/MAY 2023/ICT200

d) Display the workshop name, start date, venue description and location for all workshops
that are run in venue with a capacity greater than and equal to 300. Sort the output
according to workshop name in descending.
(5 marks)

SELECT WSName, StartDate, VenueDesc, VenueLoc (1.0 mark)


FROM WORKSHOP W, VENUE V (1.0 mark)
WHERE W.VenueNum = V.VenueNum (1.0 mark)
AND VenueCapacity >= 300 (1.0 mark)
ORDER BY WSName DESC (1.0 mark)

QUESTION 3

Given the following relational schemas:

ATHLETE (Ath_ID, Ath_FName, Ath_Address, Ath_Allowance, Ath_Highscore, TeamNum*)


TEAM (Team_Num, TeamName, TeamMajor, Inst_ID*)
INSTRUCTOR (Inst_ID, Inst_Name, Inst_Major, Inst_Salary)

a) Show the average high score of athletes for each team. Display the team number, team
name, average high score, and the number of people in each group. Include only those
groups that have two or more people.
(5 marks)

SELECT athlete.TEAM_NO,TEAM_NAME, AVG(Ath_Highscore) AS "AVG-


HIGHSCORE", COUNT(*) AS "NO PEOPLE" (2.0 m)
FROM team, athlete (0.5 m)
WHERE team.TEAM_NO = athlete.TEAM_NO (1.0 m)
GROUP BY TEAM_NO (1.0 m)
HAVING COUNT(*) > 1; (0.5 m)

b) Using subquery, display athlete’s id, first name, allowance and team number who acquired
less than the average high score.
(5 marks)

SELECT A.ATH_ID, A,ATH_FNAME, A.ATH_ALLOWANCE, T.TEAM_NUM (1 mark)


FROM ATHLETE A, TEAM T (1 mark)
WHERE A.TEAM_NUM = T.TEAM_NUM (1 mark)
AND A.ATH_HIGHSCORE < (SELECT AVG(ATH_HIGHSCORE) FROM ATHLETE)
(2 marks)

END OF SUGGESTED ANSWER SCHEME

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy