A1 Database 2k25 2
A1 Database 2k25 2
Students AST(
Used in
indexing
·
Redundancy
-
Reduce .
SHOP
PK
PK
ShopID Product Price OrderID Shopp Quantity
203 Pakol 20 25 203288 ① 1st Normal Form & INF & 3NF
206 APPLE 999 21 208 2
Candidate
Key
· Field Fields which second is 208 IDAD 799 23 203500
for every
or
unique.
o most suitable
field is chosen as
Primary key .
Foreign Key :
Primary key in one table
another table.
Used as
referencing key in
·
Foreign key may not be unique in
referencing
table·
·
Used to Relate two tables-
1st Normal Form DATATYPES IN SQL SQL Statements
Student > Structured Query Language
Sub Mark
StID StName VARCHAR
203 Subhan as 91
Collection Database
Alphanumeric Valves 1
Creating
·
of -
a
,
TCR BLOCK E North
, ,
-
"
CREATE DATABASE MAICS
; > End
of
time
operator
> 91 81 , 10
204 UMER CS ,
Statement
Upper
T bound.
VARCHAR(25 .
2
Deleting a Databuse .
of ;
· No Repeating Group of attributes INTEGER
· Table should
follow atomicity .
·
Whole Numbers 3 .
Creating a table.
with
fields defined
~
sone cell
,
one value · e .
g 23 , -18, 200 no
21 208 2
No partial Dependency
·
Fields 23 203500
KeyFieldsSTUDENT Now-key
SUBL SubTech DATE
SHID
Campus
. 01
2 Phy YAWAR North ·
#DD/mm/ YYY#
203 maths Salman Gulshan "DD/ mo/YYXY " CREATE TABLE ORDER ONDEND INTEGER
,
201 Maths Salman North
g AB123
PK CAIE
depending on another non
key Field .
Deleting A TABLE 6-
Updating a Record -
TABLE
Definition , Other Fields
PK
Displaying a or
WHERE SAID = 203 ;
Student 0
: Display Title Rating for
StID StName Sub Mark Grade
,
all Movies
displayed on Screens .
Age
DELETE FROM Student
203 Subhan <S 9) "Al 30
WHERE SHD = 203
; SELECT MOVIE .
TiHe , MOVIE -
Rating
↑
~
All fields > All records will be deleted . FROM MOVIE MOVIESCHEDULE
,
Fields SELECT # WHERE MOVIESCHEDULE Screen Number .
= 3
Student ; MOVIE MovielD
Name
of From 8 -
;
Tables. SELECT MOVIE .
TiHe , MOVIE -
Rating
ALTER TABLE Student FROM MOVIE
o
StIDs ,
StName
, Age Mark > 80 ADD PRIMARY KEY SHD ; INNER JOIN MOVIESCHEDULE
ON MOVESCHEDULE MovielD .
= MOVIE MovielD
.
SELECT SHID ,
StName
Age ALTER TABLE Student WHERE MOVIESCHEDULE Screen Number .
= 3
;
,
SELECT Age ,
StName SELECT CONNT(ShopID) As POiceAboveloo
From Student FROM SHOP
atregulinter different
·
every Foreign Key has
·
.
·
Ensures a
·
DROP DATABASE ·
ORDER BY corresponding Primary Key .
2 Access
.
OCREATE TABLE · GROUP BY QUERY ·
Makes sure
any queries Run returns Rights
·
DROP TABLE
·
AVG/SUM/COUNT accurate and
Complete .
Results 3
- Each user having different views
ALTER TABLE ·
INNER JOIN ON updated) deleted data
any value
is be
· ·
IF 4- Encryption on can
·
DELETE FROM WHERE Maintenance referencingfables as well. 5 -
Records AND Table Locking
·
INSERT INTO VALUES ·
Prevent simultaneous access
oused to create
friendly interface
users.
for
LEVEL 2 0 To create
forms ,
to enter data . Ends !:
conceptual conceptuchem · Generate
Reporte .
Level a DBA
Logical Level ·
Internative features Menu's
,
buttons-
OER-Diagrams
2
g TABLES , KEY Fields , attributes ,
.
QUERY PROCESSOR
datatypes . oused .
to search data
·
create areales
INTERNAL LENEL Devices LEVEL3
DATABASE
Storage · Search
for specific records .
can
perform calculations
o
>
Encryption is
Applied DATA
Dictionary
Compression
· ·
MetaData
.
of Tables, Fields,
Number
e .
g DataTypes ,
key Fields
, Relationship 6/w Fields
PAGE 986
Explain how to modify the table to put it into First Normal Form (1NF).
·
Subject andSubject Cade having repeating group of attributes ,
...................................................................................................................................................
used
Primary Kay
...................................................................................................................................................
as
.
·
StudentName field should be divided into two fields
...................................................................................................................................................
FirstName and LastName so that one cell
...................................................................................................................................................
e
g
.
© UCLES 2023
G 9618/12/O/N/23 [Turn over
PAGE 964
O
-
(a) Complete the entity-relationship (E-R) diagram for the relational database.
SHOP_ORDER CUSTOMER
ORDER_ITEM SUPPLIER
ITEM
[3]
...................................................................................................................................................
, regular backups
More Secure are maintained.
2 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(c) (i) Write a Structured Query Language (SQL) script to define the database called SHOP.
..................................................................................................................................... [1]
sum
(ii) Write the SQL script to return the total quantity of items that the customer with the ID of
HJ231 has ordered.
...........................................................................................................................................
;
..................................................................................................................................... [4]
The fields RiderLevel and HorseLevel can only have the values: Beginner,
Intermediate or Advanced.
1 ........................................................................................................................................
...........................................................................................................................................
↑
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(ii) Write a Structured Query Language (SQL) script to return the names of all the horses
that have the horse level intermediate or beginner.
S
...........................................................................................................................................
SELECT Name
...........................................................................................................................................
FROM HORSE
...........................................................................................................................................
OR Horselevel = "Beginner" ;
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
7
T
(iii) The following SQL script should return the number of riders that have the rider level
beginner and have a lesson booked on 09/09/2023.
--L
SELECT SUM(STUDENT.RiderLevel) AS NumberOfRiders
OR Date = #09/09/2023#
>
StudentID =
StudentID
2 ........................................................................................................................................
STUDENT StudentID =
LESSON StudentID
...........................................................................................................................................
.
.
OR Date
3 ........................................................................................................................................
Beginner "Beginner"
4 ........................................................................................................................................
...........................................................................................................................................
[4]
are non
key fields In OWNER Table We can create a
...................................................................................................................................................
. .
as
primary key fields . No Transitive
dependency no
...................................................................................................................................................
,
............................................................................................................................................. [3]
(b) Write the Structured Query Language (SQL) script to add a new record in the table TREE to
store the following data:
Attribute Value
TreeID V LOW_1276
ScientificNameL Salix_Alba
-
MaxHeight - 30.00
-
FastGrowing TRUE
...................................................................................................................................................
............................................................................................................................................. [3]
are candidates
for becoming Primary key
.
............................................................................................................................................. [1]
4 A photographer creates a relational database to store data about photographs taken at birthday
parties.
The database, PHOTOGRAPHS, stores details of the customer, the party, the photographs taken
and the cameras used.
The photographer has several cameras that are used for taking the photographs at the parties.
Each camera has a specific lens type (for example, XY32Z) and lighting type (for example, F1672).
Data about each photograph is stored in the database including the party at which it was taken,
the time it was taken and the camera used.
-
-
(a) Complete the entity-relationship (E-R) diagram for the database PHOTOGRAPHS.
PARTY CUSTOMER
PHOTO_DATA CAMERA_DATA
[3]
one
corresponding value .
...................................................................................................................................................
No Partial
Dependency , If primacy key consist of
·
more
...................................................................................................................................................
than one
field all mon
key fields should only depend an
...................................................................................................................................................
,
(c) The table shows some sample data for the table PHOTO_DATA.
(i) State what is meant by a tuple. Give an example of a tuple from PHOTO_DATA.
Row in a fable.
A single
Tuple .................................................................................................................................
...........................................................................................................................................
Example ............................................................................................................................
...........................................................................................................................................
[2]
(ii) Complete the Structured Query Language (SQL) script to display the total number of
photographs that have been taken using a camera with a camera ID starting with CAN.
⑧
COUNT
SELECT ........................................................ PhotolD
(................................................................)
PHOTO- DATA
FROM .........................................................................................
"
"CAN *
WHERE CameraID LIKE .................................................................................. ;
[4]
4 A teacher uses a relational database, MARKS, to store data about students and their test marks.
Pl
TEST(TestID, Description, TotalMarks)
i
-
(a) Describe the advantages of using a relational database compared to a file-based approach.
· Each table is secure With Username and Password.
...................................................................................................................................................
·
Data integrity is maintained Accurate.
...................................................................................................................................................
·
Different Access Rights for each user. Different views
...................................................................................................................................................
Regular
·
Back up
...................................................................................................................................................
.
o
Reductancy is reduced.
...................................................................................................................................................
O
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) Give the highest level of Normal Form (NF) the database MARKS is in and justify your choice.
3NE
Normal Form .............................................................................................................................
No ·
Repeating Group o attributes All / primary keys
Justification ...............................................................................................................................
are
available
...................................................................................................................................................
No Partial
Dependency No Transitive
Dependency
·
...................................................................................................................................................
,
-
[3]
000 StudentID
12
TestID
A1
Mark
50
12 P10 100
13 A1 75
14 P10 60
Write a Structured Query Language (SQL) script to create the table STUDENT_TEST.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [5]
(ii) Write a Structured Query Language (SQL) script to find the average mark of students in
test A7.
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
10
6 A shop sells plants to customers. The shop manager has a relational database to keep track of the
sales.
PURCHASE(PurchaseID, CustomerID)
• The first stage is from a database that is not normalised (0NF) to First Normal Form
(1NF).
• The second stage is from 1NF to Second Normal Form (2NF).
• The third stage is from 2NF to Third Normal Form (3NF).
Tick ( ) one box in each row to identify the appropriate stage for each task.
Normalisation stage
Task
0NF to 1NF 1NF to 2NF 2NF to 3NF
[2]
PLANT CUSTOMER
PURCHASE_ITEM PURCHASE
[3]
© UCLES 2021 9618/12/O/N/21
PAGE 806
11
Describe the purpose and contents of the data dictionary in the DBMS.
...................................................................................................................................................
T
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(c) The shop manager uses both Data Definition Language (DDL) and Data Manipulation
Language (DML) statements to create and search the database.
(i) Complete the DML statements to return the total number of items purchased with the
=
purchase ID of 3011A.
- -
Quantity
SELECT SUM(..................................................)
PURCHASE-ITEM
FROM ..................................................
Prochase ID
WHERE .................................................. "3011A"
= ..................................................;
[4]
(ii)
oo
Write DDL statements to include a field in the table PURCHASE to store the date of the
order.
...........................................................................................................................................
..................................................................................................................................... [3]
G
(c) Example data from the table RENTAL are given:
o RentalID
1
CustomerID
22
HouseID
15B5L
MonthlyCost
1000.00
DepositPaid
Yes
2 13 3F 687.00 No
3 1 12AB 550.00 Yes
4 3 37 444.50 Yes
(i) Complete the following Data Definition Language (DDL) statement to define the table
RENTAL.
TABLE
CREATE ...................................... RENTAL
...................................... (
VARCHAR
HouseID ...................................... (5) NOT NULL,
REAL
MonthlyCost ...................................... NOT NULL,
PRIMARY KEY
.......................................................... (RentalID)
);
[4]
(ii) Write a Data Manipulation Language (DML) script to return the first name and last name
of all customers who have not paid their deposit.
FROM CUSTOMER
...........................................................................................................................................
ON CUSTOMER CustomerID .
= RENTAL CustomID
...........................................................................................................................................
.
RENTAL Paid = No
WHERE Deposite ;
...........................................................................................................................................
..................................................................................................................................... [4]