Anda di halaman 1dari 27

Introduction to Databases

Please select a correct sentence.


1: A data base is a piece of software intended for data processing.
2: A data base is a storage device (i.e. magnetic disc) intended for data storage.
3: A data base is a collection of data in the computer's memory.

Please select a correct sentence.


1: A Database Management System is a piece of software that creates and
maintains data bases.
2: A Database Management System is a piece of software that can be applied to
management.
3: A Database Management System is a piece of hardware that controls storage
devices.

Please select all correct sentences.


1: A Data Base Schema contains description of all data types which are of
interest to users.
2: A Data Base contains instances of data types previously defined in a
current Data Base Schema.
3: A Data Base Schema is a list of existing files. Whenever a user creates a new file
its description is automatically added to the data base schema.

In your opinion, is the following sentence true or false?


With the DML we may store, delete, modify or retrieve instances of such data types
as are previously defined in the database schema by the DDL.
We cannot create a Data Base (store information) until the Data Base Schema is
defined.
True
In your opinion, is the following sentence true or false?
With a single DataBase Management System (DBMS) we can create and maintain different
databases. In this case we should define a unique Database Schema for each database.
True
Please select a correct sentence.
1: Integrity constraints are defined by means of DML whenever a new data are stored.
2: Integrity constraints are defined for each particular database application.
3: Integrity constraints are defined for each particular implementation of DBMS.

Basic Relational Data Model

Please select a correct sentence.


1: Any two-dimensional table is a relation.
2: Relation is a collection of two dimensional tables.
3: Relation is a two-dimensional table having particular properties.

Please select a correct sentence.


1: Domain is a column of relation.
2: Domain is a subset of a relation's column.
3: Domain includes a column of relation.

Please select a correct sentence.


1: It is prohibited to include columns which belong to a single domain in different
relations.
2: Normally, different relations within a data base contain columns which
belong to a single domain.
3: All columns of a particular relation belong to a single domain.

Please select a correct sentence.


1: Data Manipulation Language is not capable to modify extensions of relations.
2: Data Manipulation Language is capable to modify extension of
relations.
3: Extensions of relations are defined by means of a Data Description Language.

Please select a correct sentence.


1: Each relation has at least one primary key.
2: Each relation may have or may not have a primary key.
3: Each relation has at least one candidate key and exactly one primary
key.

Please select a correct sentence.


1: Each relation has at least one candidate key.
2: Each relation may have or may not have a candidate key.
3: Candidate key is selected by user and coded in a database schema.

Please select a correct sentence.


1: Primary key is automatically selected by DBMS
2: Primary key is a reference to another relation.
3: Primary key is a candidate key selected by a database administrator and
coded in a database schema.

Please select a correct sentence.


1: There is exactly one foreign key for a particular relation.
2: A foreign key holds a primary key value of another relation.
3: A foreign key uniquely identifies a tuple of a relation.

Data Updating Facilities


Please select a correct sentence.
1: We put one concrete value of a particular attribute into a relational data base.
2: We put sets of related facts (i.e. tuples) into a relational data base as
undivided objects.
3: We put relations into a relational data base as undivided objects.

The database management system must protect a database against the storing of tuples
with duplicate values of ... keys.
Please select a correct key name:
1: Primary
2: Candidate
3: Foreign

Suppose we are going to load into a data base some thousands of tuples which are
represented by records of an independent data file. In this case we should use . . .
Please select a correct sentence.
1: a "self-contained" language.
2: a host language + DML.

Suppose we need to retrieve certain data from a data base. And we are not going to
repeat this query in the future. In this case we should use ...
Please select a correct sentence.
1: a "self-contained" language.
2: a host language + DML.

Please select a correct sentence.


1: Any relational DBMS must maintain both the Entity Integrity and
Referential Integrity independent of a concrete application.
2: Users are responsible for maintaining both the Entity Integrity and Referential
Integrity, but they may violate the integrity if they want.
3: Database Administrator defines the Entity Integrity or Referential Integrity in a
corresponding data base schema.

Please select a correct sentence.


1: Users are responsible for maintaining both the domain, tuple or relation
Integrity, but they may violate the rules if they want.
2: Relational DBMS must maintain the domain, tuple and relation integrity
constraints independent of a concrete application.
3: Database Administrator is responsible for maintaining the domain, tuple
and relation integrity constraints (for defining them in a corresponding
database schema).

Normalization
Please select a correct sentence.
1: Database Administrator has to describe the set of functional dependencies in a
database schema.
2: A set of functional dependencies is a property of an area being
modelled. The functional dependencies cannot be changed during data
base updating.
3: A set of functional dependencies may be dynamically changed when a new tuple
is stored or deleted.

Consider the following example:

Please select a correct sentence.


1: This relation IS NOT in Second Normal Form (2NF).
2: This relation IS in Second Normal Form (2NF).
3: It is not possible to give a particular answer. Important information is absent.

Consider the following example:

Please select a correct sentence.


1: This relation IS NOT in Second Normal Form (2NF).
2: This relation IS in Second Normal Form (2NF).
3: It is not possible to give a particular answer. Important information is absent.

Consider the following example:

Please select a correct sentence.


1: This relation IS NOT in Third Normal Form (3NF).
2: This relation IS in Third Normal Form (3NF).
3: It is not possible to give a particular answer. Important information is absent.

Consider the following example:

Please select a correct sentence.


1: This relation is in Third Normal Form (3NF).
2: This relation is in Second Normal Form (2NF).
3: This relation is neither in 2NF nor in 3NF.

Relational Algebra

The degree of a relation is the number of columns (domains).


The cardinality of a relation is the number of rows (tuples).
Please select a correct sentence.
For the Select operation:
1. The cardinality and degree of the resultant relation do not depend on the cardinality
and degree of the source relation.
2. The cardinality and degree of the resultant relation are equal to the cardinality and
degree of the source relation.
3. The degree of the resultant relation is equal to the degree of the source
relation. The cardinality of the resultant relation does not exceed the cardinality
of the source relation.

The degree of a relation is the number of columns (domains).


The cardinality of a relation is the number of rows (tuples).
Please select a correct sentence.
For the Project operation:
1. The degree of the resultant relation does not exceed the degree of the source
relation.
2. The degree of the resultant relation is equal to the degree of the source relation.
3. The degree of the resultant relation does not depend on the degree of the source
relation.

Please select a correct sentence.


For the Join operation:
1. The schema of the resultant relation does not depend on the schemas of the source
relations.
2. The schema of the resultant relation is equal to the schema of the first source relation.
3. The schema of the resultant relation is an union of all domains defined in
source relations.

Please select a correct definition of the query:


"Get customers which live in London and have phone number 2263035 or 5555910."
1. Select Customer Where Ccity=London And Cphone=2263035 Or Cphone=5555910 . . .
2. Select Customer Where Ccity=London And (Cphone=2263035 Or
Cphone=5555910) . . .
3. Select Customer Where Ccity=London And (Cphone=2263035 Or 5555910) . . .

Please select a correct definition of the query:


"Get names of such products which have a price more than 1000".
1. Project Product Over Pname Giving X; Select X Where Price>1000 ...;
2. Select Product Where Price>1000 Giving X; Project X Over Pname ...;
3. Join Product and Price>1000 Giving X; Project X Over Pname ...;

Please select all correct definitions of the query:


"Get names and prices of those products which were bought by the customer number 1".
1. Join Product And Transaction Over P# Giving A;
Select A Where C#=1 Giving B;
Project B Over Pname, Price Giving Result;
2. Select Transaction Where C#=1 Giving A;
Join A And Product Over P# Giving B;
Project B Over Pname, Price Giving Result;
3. Select Customer Where C#=1 Giving A;
Project A Over Pname, Price Giving B;
Join B And Product Over P# Giving Result;

Please select all correct definitions of the query:


"Get names of such customers who bought the product number 1".
1. Join Customer And Transaction Over C# Giving A;
Select A Where P#=1 Giving B;
Project B Over Cname Giving Result;
2. Select Transaction Where P#=1 Giving A;
Project A Over Cname Giving B;
Join B And Customer Over C# Giving Result;
3. Select Transaction Where P#=1 Giving A;
Join A And Customer Over C# Giving B;
Project B Over Cname Giving Result;

Please select a correct resultant relation.

1.

2.

3.

Consider the following query:


"Get the names of such customers who bought both the product CPU and the product
VDU"
In your opinion, is the following query definition correct ?
Join Transaction And Customer Over C# Giving A;
Join A and Product Over P# Giving B;
Select B Where Pname=CPU And Pname=VDU Giving C;
Project C Over Cname Giving Result;

No

Consider the following query:


"Get the names of such customers who bought both the product CPU and the product
VDU"
In your opinion, is the following query definition correct ?
Join Transaction And Customer Over C# Giving A;
Join A and Product Over P# Giving B;
Select B Where Pname=CPU Giving C_CPU;
Select B Where Pname=VDU Giving C_VDU;
C_CPU Union C_VDU Giving C;
Project C Over Cname Giving Result;
No

Consider the following query:


"Get the names of such customers who bought both the product CPU and the product
VDU"
In your opinion, is the following query definition correct ?
Join Transaction And Customer Over C# Giving A;
Join A and Product Over P# Giving B;
Select B Where Pname=CPU Giving C_CPU;
Select B Where Pname=VDU Giving C_VDU;
C_CPU Intersect C_VDU Giving C;
Project C Over Cname Giving Result;

No

Please select a correct sentence.


1: A resultant relation of the Select operation does not contain null values at all.
2: A resultant relation of the Select operation may contain null values under any
column.
3: A resultant relation of the Select operation does not contain null values
under columns that were used as a logical condition.

Please select a correct sentence.


1: A resultant relation of the Join operation does not contain null values at all.
2: A resultant relation of the Join operation does not contain null values
under common column(s).
3: A resultant relation of the Join operation may contain null values under any
column.

Consider the following query:


"Get the names of such customers who bought both the product CPU and the product
VDU"
In your opinion, is the following query definition correct ?
Join Transaction And Customer Over C# Giving A;
Join A and Product Over P# Giving B;
Select B Where Pname=CPU Giving C_CPU;
Project C_CPU Over Cname Giving C_CPU1;
Select B Where Pname=VDU Giving C_VDU;
Project C_VDU Over Cname Giving C_VDU1;
C_CPU1 Intersect C_VDU1 Giving Result;
Yes

Relational Calculus

Let X and Y be the names of tuple variables both of which range over the tuples of the
relation Product.
Consider the query:
X == Product; Y == Product;
(X.Pname, Y.Price) : (X.P# = Y.P# & X.Price > 1100)
Please select a query which is equivalent to this one.
1: (X.Pname, Y.Price) : (X.Price > 1100)
2: (X.Pname, Y.Price) : (X.P#=Y.P# Or X.Price > 1100)
3: (X.Pname, X.Price) : (X.Price > 1100)

Query: "Get names of such customers who bought the product CPU".
C == Customer, T == Transaction, P == Product
(C.Cname): T P (T.P#=P.P# And P.Pname=CPU ??? )
Please select the omitted comparison (???)
1: Or X.C# = Y.C#
2: And C.C# = T.C#
3: And C.C# = P.C#

Query: "Get names of such products which were sold to London".


C == Customer, T == Transaction, P == Product
(P.Pname):???
Please select the omitted WFF (???)
1. T P (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)
2: T C (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)
3: T C (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)

Query: "Get names of such customers which live in the same city as the customer Codd".
C1 == Customer, C2 == Customer
(C1.Cname): ???(C1.Ccity = C2.Ccity And C2.Cname = "Codd")
Please select the omitted quantifier (???)
1. C2
2: C2
3: C1

Query: "Get a name of the most expensive company's product".


P1 == Product, P2 == Product
(P1.Pname): ???(P1.Price >= P2.Price)
Please select the omitted quantifier (???)
1. P2
2: P1
3: P2

Query: "Get names of such products which were bought by ALL customers".
P == Product, T == Transaction, C == Customer
(P.Pname): ??? (P.P# = T.P# And T.C# = C.C#)
Please select the omitted quantifiers (???)
1. C T
2: T C
3: C T

Relational Calculus (Part II)

Query: "Get the customer names and product prices for all transactions of the product
VDU".
Range Customer C; Range Transaction T Some; ???
Get (C.Cname, P.Price):(C.C#=T.C# & T.P#=P.P# & P.Pname=VDU)
Please select the omitted Range statement (???)
1. Range Product P;
2: Range Product P SOME;
3: Range Product P ALL;

Query: "Find a total number of customers who bought the product VDU".
Please select a correct definition of the query
1. Range Customer C; Range Transaction T Some; Range Product P Some;
Get A(Count(C.C#)):(C.C#=T.C# & T.P#=P.P# & P.Pname=VDU);
2. Range Transaction T; Range Product P SOME;
Get A(Count(T.C#)):(T.P#=P.P# & P.Pname=VDU);
3. Range Customer C; Range Transaction T Some; Range Product P Some;
Get A(Count(T.P#)):(C.C#=T.C# & T.P#=P.P# & P.Pname=VDU);

Query: "Get names of such customers who bought the product CPU".
Range Customer C; Range Product P Some; ???
Get B(C.Cname):(C.C#=T.C# & T.P#=P.P# & P.Pname=CPU)
Please select the omitted Range statement (???)
1. Range Transaction T;
2: Range Transaction T SOME;
3: Range Transaction T ALL;

Query: "Get names of such customers who bought the product CPU, in ascending order of
dates of transactions".
Range Customer C; Range Product P Some; ???
Get B(C.Cname, T.Date):(C.C#=T.C# & T.P#=P.P# & T.Pname=CPU) UP T.Date;
Please select the omitted Range statement (???)
1. Range Transaction T;
2: Range Transaction T SOME;
3: Range Transaction T ALL;

Query: "Get names of such customers who bought the product number 1, or bought any
product which costs more than 1000".
a == Cname, b == C#, c == P#, d == Price
get (a) : b c d ???
Please select the omitted WFF(???)
1. (Customer(a,b) And Transaction(b,c) And c=1 Or Product(c,d) & d >1000)
2: (Customer(a,b) And Transaction(b,c) And ( c=1 Or Product(c,d) &
d>1000))
3: (Customer(a,b) And (Transaction(b,c) And c=1 Or Product(c,d) & d>1000))

Query: "Get a name of the most expensive product".


a == Pname, b == Price, c == Price
(a): ??? (Product(a,b) And b>=c)
Please select the omitted quantifiers(???)
1. b c
2: b c
3: b c

Data Sublanguage SQL

Query: "Get names of all customers who bought the product CPU".
Select Cname From Customer Where C# ???
(Select C# From Transaction Where P# ???
(Select P# From Product Where Pname=CPU))
Please select omitted comparisons(???...???)
1. In . . . In
2: In . . . Not In
3: Not In . . . In

Query: "Get names of all customers who did not buy the product CPU".
Select Cname From Customer Where C# ???
(Select C# From Transaction Where P# ???
(Select P# From Product Where Pname=CPU))
Please select omitted comparisons(???...???)
1. In . . . In
2: In . . . Not In
3: Not In . . . In

Query: "Get names of all customers who bought the product CPU, but did not buy the
producr VDU".
Select Cname From Customer Where C# In
(Select C# From Transaction Where P# In
(Select P# From Product Where Pname=CPU))
And C# ???
(Select C# From Transaction Where P# ???
(Select P# From Product Where Pname=VDU))
Please select omitted comparisons(???...???)
1. In . . . In
2: In . . . Not In
3: Not In . . . In

Query: "Get names of customers who bought the product number 1".
Please select all correct definitions of the query
1. Select Cname From Customer Where C# In
(Select C# From Transaction Where P#=1)
2. Select Cname From Customer X, Transaction Y
Where X.C#=Y.C# And Y.P#=1
3. Select Cname From Customer Where
Customer.C#=Transaction.C# And Transaction.P#=1

Query: "Get names of customers and dates of such transactions which dealt with the
product number 1".
Please select a correct definition of the query
1. Select Cname, Date From Customer Where C# In
(Select C# From Transaction Where P#=1)
2. Select Cname, Date From Customer, Transaction
Where Customer.C#=Transaction.C# And Transaction.P#=1
3. Select Cname, Date From Customer, Transaction
Where Transaction.P#=1

Query: "Get names of customers, dates and total price of such transactions which dealt
with the product number 1".
Please select a correct definition of the query
1. Select Cname, Date, Qnt*Price From Customer, Product
Where C# In (Select C# From Transaction Where P#=1)
And Transaction.P# = Product.P#
2. Select Cname, Date, Qnt*Price
From Customer, Product, Transaction Where
Customer.C# = Transaction.C# And Transaction.P#=Product.P#
And Product.P#=1
3. Select Cname, Date, Qnt*Price
From Customer, Product, Transaction Where
Customer.C# = Transaction.C# And Transaction.P#=1

Query: "Find the number of product units that were bought by the customer number 1.".
Please select a correct definition of the query
1.Select COUNT(*) From Customer Where C# In
(Select P# From Transaction Where C#=1)
2.Select COUNT(*) From Transaction Where C#=1
3.Select SUM (Qnt) From Transaction Where C#=1

Query: "Find a number of such customers who bought the product number 1".
Please select all correct definitions of the query
1.Select COUNT(*) From Customer Where C# In
(Select C# From Transaction Where P#=1)
2.Select COUNT(X.C#) From Customer X, Transaction Y
Where X.C#=Y.C# AND Y.P#=1
3.Select COUNT(*) From Customer X, Transaction Y
Where X.C#=Y.C# AND Y.P#=1

Query: "Find a total number of such customers who bought the Product 1 and a total number of
such customers who bought the Product 2".
Please select a correct definition of the query
1.Select P#, COUNT(*) From Customer Where C# In
(Select C# From Transaction Where P#=1 OR P#=2)
Group By P#
2.Select P#, COUNT(*) From Transaction
Where P#=1 Or P#=2 Group By P#
3.Select P#, COUNT(C#) From Transaction
Where P#=1 Or P#=2

Query: "Get the names of such customers who bought more than 45 units of the
company's products".
Select Cname From Customer Where C# In
(Select C# From Transaction ??? )
Please select the omitted statement (???)
1. Group By P# Having SUM(Qnt)>45
2. Group By C# Having SUM(Qnt)>45
3. Group By C# Having COUNT( * )>45

Query: "Get the names of such customers who bought all types of the company's
products".
Select Cname From Customer Where C# IN
(Select C# From Transaction Where P# ???
(Select P# From Product))
Please select the omitted comparison (???)
1. IN
2. NOT IN
3. = ALL

Consider the operation:


Delete all information on the customer "Martin" incuding all the sell transactions.
Please select a correct definition of the operation:
1. Delete From Customer Where Cname="Martin";
Delete From Transaction Where C# IN
(Select From Customer Where Cname="Martin");
2. Delete From Transaction, Customer Where C# IN
(Select From Customer Where Cname="Martin");
3. Delete From Transaction Where C# IN
(Select From Customer Where Cname="Martin");
Delete From Customer Where Cname="Martin";

Data Sublanguage QBE

Query: "Get names of all customers who bought the product number 1".
Please select the omitted example element(?)
1.X
2.A
3.ALL

Query: "Get names of all customers in London or Paris".


Please select the omitted example element(?)
1. P.X
2. P.Y
3. X

Query: "Get names of products having a price between 1100 and 2000".
Please select the omitted example element(?)
1. Y
2. P.Y
3. X

Query: "Get a total number of customers in London".


Please select the omitted example element(?)
1.P.All.A
2.P.CNT.All.A
3.P.CNT.A

Query: "Get a total number of customers in each city".


Please select the omitted example element(?)
1.P.G.A
2.P.All.A
3.P.A

Query: "Get numbers for such products which were bought by all customers".
Please select the omitted example element(?)
1.X
2.P.X
3.ALL.X