0% found this document useful (0 votes)
26 views6 pages

CH 9-10

The document contains a series of logic and database-related exercises, including drawing logic circuits, completing truth tables, and working with SQL statements for a hotel booking and building materials database. It requires the reader to analyze logic expressions, understand database structures, and manipulate data through SQL queries. The exercises cover various concepts such as logic gates, primary keys, and data types.
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)
26 views6 pages

CH 9-10

The document contains a series of logic and database-related exercises, including drawing logic circuits, completing truth tables, and working with SQL statements for a hotel booking and building materials database. It requires the reader to analyze logic expressions, understand database structures, and manipulate data through SQL queries. The exercises cover various concepts such as logic gates, primary keys, and data types.
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/ 6

1 Consider the logic expression:

X = (NOT P OR Q) NAND (Q XOR R)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify the logic expression.

Q X

[4]

(b) Complete the truth table for the given logic expression.

Working space
P Q R 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
[4]
2 A database table called Booking28 stores details of hotel rooms and bookings for the week
beginning Monday 7 July 2025.

RoomNo Type Guests Rate$ Mon Tue Wed Thu Fri Sat Sun
101D Double 2 99.99 T T T T F T T
102D Double 2 99.99 T T T F T T T
103F Family 4 150.00 T T T T T T T
104S Single 1 72.50 F T T F T T T
105S Single 1 72.50 F T T F T T T
106T Twin 2 120.00 T T T T F T T
201F Family 4 160.00 F F T T T T T
202D Double 2 120.00 T F T T T T T
203T Twin 2 120.00 T F T T T T T
204T Twin 2 125.00 T F T F T T T
205S Single 1 79.99 T F T T F T T
301D Double 2 200.00 F T T F F T T
302T Twin 2 200.00 T T T T F T T
303P Suite 4 500.00 T T T T F T T
304P Suite 6 700.00 F F F F T T T

(a) State the number of fields and records in this database table.

Fields ........................................................................................................................................

Records ....................................................................................................................................
[2]

(b) State the reason why the Type field would not be suitable as a primary key.

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

............................................................................................................................................. [1]
(c) The database uses only the data types:

• alphanumeric
• character
• Boolean
• integer
• real
• date/time.

Complete the table to show the fields that could have the given data types.

Only one field name is required in each box and each field name must be different.

Field Data type


alphanumeric
Boolean
real
integer
[2]

(d) Give the output that would be produced by the structured query language (SQL) statement:

SELECT RoomNo, Type, Guests, Rate$

FROM Booking28

WHERE Mon <> T;

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

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

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

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

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

............................................................................................................................................. [3]
3 Four logic gates and five logic gate symbols are shown.

Draw one line to link each logic gate to its correct symbol. Not all logic gate symbols will be used.

Logic gate Logic gate symbol

AND

NAND

NOR

XOR

[4]

4 Complete the paragraph about databases. Use terms from the list. You may need to use a term
more than once. Some of the terms in the list will not be used.

fields comments columns constant key

table primary key program records rows

scripts database validation variable

Database tables consist of ...................................... and ...................................... .

Rows are ...................................... .

...................................... are fields.

Structured query language (SQL) ...................................... are used to query data.

A ...................................... uniquely identifies a record.


[6]
5 A logic circuit is to be built to control the automatic opening of a window. The window W opens if
the temperature T is too high, the heater H is off, and the air conditioning A is off.

air conditioning off 0


air conditioning A
air conditioning on 1
not too high 0
temperature T
too high 1
heater off 0
heater H
heater on 1
window closed 0
window W
window open 1

Complete the truth table for this problem.

A T H W

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]
6 Building materials are sold in bags. A new database table called BuildStock has been set up to
store details about the materials for sale. Part of this table is given.

MtNo Name InStock WeightKg PricePerBag NumberBags


MT01 Builders sand Yes 50 4.50 50
MT02 Sharp sand Yes 25 3.50 21
MT03 Red sand No 50 2.75 0
MT04 Cement No 25 6.85 0
MT05 Chippings Yes 50 35.00 50
MT06 Cobbles No 75 67.35 0
MT07 Pebbles small Yes 50 34.50 3
MT08 Pebbles medium Yes 25 25.50 10
MT12 Pebbles large Yes 75 62.75 20
MT15 Washed gravel Yes 50 12.75 12
MT16 Pea gravel Yes 100 15.95 24

(a) Write the output from this structured query language (SQL) statement.

SELECT MtNo, Name


FROM BuildStock
WHERE WeightKg = 75
ORDER BY PricePerBag;

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

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

............................................................................................................................................. [3]

(b) (i) Complete this SQL statement to display only the names of all the materials that are out
of stock.

SELECT .............................................................................................................................

FROM ..................................................................................................................................

WHERE ...............................................................................................................................
[2]

(ii) Explain how another SQL statement using a different field could be used to display the
same information.

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

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

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

..................................................................................................................................... [2]

You might also like