0% found this document useful (0 votes)
48 views18 pages

Databases and Boolean Logic Worksheet

Uploaded by

siddharthrukhana
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)
48 views18 pages

Databases and Boolean Logic Worksheet

Uploaded by

siddharthrukhana
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/ 18

9 Databases

1 a Explain the meaning of the following database terminology.

Table: ................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

Record: .............................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

Field: ................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

b Identify four basic data types used in a database and provide an example for each one.

1 ......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

2 ......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

3 ......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

4 .....................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
55
9 Databases

2 A single-table database, ICECREAM, has been set up to store the ice creams available for sale.
The details included about each type of ice cream are:
» Type – for example, 'choc ice', 'lolly' or 'cone'
» Flavour – for example, 'raspberry'
» Size – 'Small', 'Medium' or 'Large'
» Number in stock – for example, '34'
» Re-order level – for example, '20'.

a Write down names for the five fields that would be required. For each field state with a
reason the data type that should be used and give a sample of the contents of that field.

Field 1: ............................................................................................................................................................

Data type: .......................................................................................................................................................

Reason: ............................................................................................................................................................

...........................................................................................................................................................................

Sample: ............................................................................................................................................................

Field 2: ............................................................................................................................................................

Data type: .......................................................................................................................................................

Reason: ............................................................................................................................................................

...........................................................................................................................................................................

Sample: ............................................................................................................................................................

Field 3: ............................................................................................................................................................

Data type: .......................................................................................................................................................

Reason: ............................................................................................................................................................

...........................................................................................................................................................................

Sample: ............................................................................................................................................................

Field 4: ............................................................................................................................................................

Data type: .......................................................................................................................................................

Reason: ............................................................................................................................................................

...........................................................................................................................................................................

Sample: ............................................................................................................................................................

Photocopying prohibited
56 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
9 Databases

Field 5: ............................................................................................................................................................

Data type: .......................................................................................................................................................

Reason: ............................................................................................................................................................

...........................................................................................................................................................................

Sample: ............................................................................................................................................................

b i Explain why a primary key is needed in a database table.

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

ii Give the reason why none of the existing fields are suitable to use as a primary key.

......................................................................................................................................................................

......................................................................................................................................................................

iii Give a suitable field name, data type and sample for another field that could be used
as a primary key.

Name: ..........................................................................................................................................................

Data type: .................................................................................................................................................

......................................................................................................................................................................

Sample: .....................................................................................................................................................

c Build the database table as specified in parts a and b. Write or paste a copy of your table
structure here.

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
57
9 Databases

d Populate the database table with six records. Write or paste a copy of your populated table here.

3 a Explain what is meant by SQL.

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

b Explain the function of each of the following SQL statements.

i SELECT

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

ii FROM

......................................................................................................................................................................

......................................................................................................................................................................

Photocopying prohibited
58 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
9 Databases

iii WHERE

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

iv SUM

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

c Identify two more SQL statements that you need to know for IGCSE Computer Science.

1 ......................................................................................................................................................................

2 ......................................................................................................................................................................

d Use the six statements from parts b and c to write SQL queries for the database table you
created in Question 2 to:
» Show the types, in alphabetical order, and sizes of all the ice creams that are in stock
» Show the total number of ice creams available to buy
» Count the number of ice creams that have stock below the reorder level.
Write or paste a copy of your SQL queries here.

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
59
9 Databases

4 A single-table database, TEACHER, contains the details of the teachers in a school. The database
includes these fields:

Name – the teacher’s family name, for example, 'Yo'


Title – the teacher’s title, for example, 'Mr'
Licence – the teacher’s licence number, for example, 'L1234'
Gender – 'M' or 'F'
Subject – the main subject taught by the teacher, for example, 'Mathematics'
Class – the class the teacher tutors, for example, '2Y'

a i Identify the field that would be most suitable to use as a primary key. Give a reason
for your choice.

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

ii State the data type that could be used for each field.

Name: ..........................................................................................................................................................

Title: ...........................................................................................................................................................

Licence: ......................................................................................................................................................

Gender: .......................................................................................................................................................

Subject: ......................................................................................................................................................

Class: ..........................................................................................................................................................

iii Build a database with the six records shown.

b i Identify a field that should be verified. Give a reason for your choice.

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

Photocopying prohibited
60 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
9 Databases

ii Identify a field that could be validated. Give a reason for your choice.

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

iii Add your validation to your database.

Here is part of the database table, TEACHER:

Name Title Licence Gender Subject Class

Yo Mr L4579 M Mathematics 3Z

Sing Miss L6713 F Science 2X

Patel Mr L5421 M Geography 4Y

Teo Mrs L7681 F Mathematics 2Z

Young Mrs L6789 F English 3X

Ling Mr L4980 M Science 4X

c i State the output from this SQL query.


SELECT Title, Name
FROM TEACHER
WHERE Subject = 'Science';

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

ii Add the SQL statement to show the results in alphabetical order.

......................................................................................................................................................................

......................................................................................................................................................................

......................................................................................................................................................................

iii Rewrite this SQL statement to include the mathematics teachers as well.

......................................................................................................................................................................

......................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
61
9 Databases

iv Write a new SQL statement to count the number of mathematics teachers in the TEACHER
table.

v Check that the SQL statements work for your database.

d Write an SQL statement to display the names of all the teachers and their classes in
ascending order of class.

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

Check that your SQL statement works as expected.

Photocopying prohibited
62 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
10 Boolean logic
1 State the logic gate each truth table represents.

a b A B X
c A B X
A B X

0 0 0 0 0 1 0 0 0

0 1 1 0 1 1 0 1 1

1 0 1 1 0 1 1 0 1

1 1 1 1 1 0 1 1 0

............................................... ............................................... ...............................................

2 Complete the truth table for this logic circuit.

A
B

A B C Working area X

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook Photocopying prohibited 63
10 Boolean logic

3 a Write the following statement as a logic expression:

X is 1 if A and B are on or if B is off and C is on

...........................................................................................................................................................................

...........................................................................................................................................................................

b Draw the logic circuit to represent the statement in part a.

4 a Complete the truth table for the following logic circuit:

A B Working area X
0 0
0 1
1 0
1 1

b Which single logic gate is represented by the truth table in part a?

.................................................................................................................................................................................

Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
64
10 Boolean logic

5 a Complete the truth table for the following logic circuit:


A

A B C Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

b How might the logic circuit in part a be simplified?

.................................................................................................................................................................................

.................................................................................................................................................................................

6 a Complete the truth table for this logic circuit:

B X

A B C Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook Photocopying prohibited
65
10 Boolean logic

b What single logic gate could replace this logic circuit?


A
B

...........................................................................................................................................................................

7 a Write down the logic expression to represent the following logic circuit:
A

B X

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

b Draw the logic circuit which corresponds to the following truth table:

A B C X
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1

B X

Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
66
10 Boolean logic

8 A chemical process is monitored using a logic circuit. There are three inputs to the logic circuit
representing the parameters being monitored in the chemical process. An alarm, X, will give an
output value of 1 depending on certain conditions.

The following table describes the process conditions being monitored.

Parameter description Parameter Binary value Description of condition


Reaction temperature T 0 Temperature > 120 °C
1 Temperature <= 120 °C
Pressure of CO gas evolved P 0 Pressure > 2 bars
1 Pressure <= 2 bars
Acid concentration A 0 Acid concentration > 4 moles
1 Acid concentration <= 4 moles

An alarm, X, will generate the value 1 if:


either temperature > 120 °C and acid concentration <= 4 moles
or temperature <= 120 °C and gas pressure <= 2 bars
or acid concentration > 4 moles and gas pressure <= 2 bars

a Write the logic expression to represent the above system.

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

...........................................................................................................................................................................

b Draw the logic circuit to represent the above system.

A X

Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook Photocopying prohibited
67
10 Boolean logic

c Complete the truth table to represent the above system.

T A P Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

9 A safety system uses the input from three sensors A, B and C. The binary values from these sensors
form the input to a logic circuit.

The output, X, from the logic circuit is 1 if:


either A is 1 and B is 1
or A is 0 and C is 1
or B is 0 and C is 1

Sensor A
Sensor B Logic circuit 'X' Output, X, from logic circuit
Sensor C

a Draw the logic circuit to represent the above system.

B X

Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
68
10 Boolean logic

b Complete the truth table for the above system.

A B C Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

c For safety reasons, the sensors feed into three different logic circuits (numbered 1, 2 and 3)
which produce the outputs X, Y and Z. These three outputs then form the inputs to another
logic circuit which has the output Q.

The three logic circuits are connected to this extra logic circuit:

Logic Output X
circuit 1
inputs
from
the Output Y
Logic
three
circuit 2 Q
sensors
A, B
and C
Logic Output Z
circuit 3

Complete the truth table for this system.

X Y Z Working area Q
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook Photocopying prohibited
69
10 Boolean logic

10 a Write a logic expression for the following logic circuit:

B X

b Complete the truth table for the logic circuit.

A B C Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

11 a Write the logic expression for this truth table.

A B X
0 0 1
0 1 0
1 0 0
1 1 1

b Draw the logic circuit which is represented by the truth table.

Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
70
10 Boolean logic

12 a Draw a logic circuit for this logic expression. Each logic gate must have a maximum of
two inputs and the expression must not be simplified:

X = ((A NAND B) XOR C) OR (A NOR NOT C)

b Complete the truth table for the logic expression:

A B C Working area X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook Photocopying prohibited
71
10 Boolean logic

Develop understanding of algorithmic and


computational thinking and programming skills
with further questions and activities.
This Workbook provides additional support for
the Algorithms, Programming and Logic section
of the Cambridge IGCSE™ and O Level Computer
Science Student’s Book Second Edition.
» Become accomplished computer scientists:
the workbook provides a series of questions
designed to test and develop computational
thinking skills in order to solve problems.
» Develop understanding and build confidence:
provides additional practice for use at home or
in class throughout the course.

Use with Cambridge IGCSE™


and O Level Computer Science
Student’s Book Second Edition
9781398318281

For over 25 years we have This resource is endorsed by


been trusted by Cambridge Cambridge Assessment International Education
schools around the world to 25
YEARS ✓ Provides learner support for the Cambridge
provide quality support for WITH IGCSE, IGCSE (9-1) and O Level Computer
t
teaching and learning. For Science syllabuses (0478/0984/2210) for
this reason we have been selected by examination from 2023
Cambridge Assessment International
Education as an official publisher of
✓ Has passed Cambridge International’s rigorous
quality-assurance process
endorsed material for their syllabuses.
✓ Developed by subject experts

✓ For Cambridge schools worldwide

Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
72

You might also like