You are on page 1of 16

Comped 8 2nd Exam

Multiple Choice
Identify the choice that best completes the statement or answers the question.
1) All of the following are database four objects EXCEPT one:
a
c
Table
Field
b
d
Form
Query
2) This key uniquely identifies each record
a
Primary Key
b
Key Record

c
d

Unique Key
Field Name

3) It is an association established between common entities.


a
c
Referential
Primary Key
b
d
Relationship
Foreign Key
4) The database language that allows you to access or maintain data in a database
a
c
DCL
DDL
b
d
DML
RDL
5) Which of the following database object hold data?
a
c
Forms
Queries
b
d
Reports
Tables
6) Which of the following store command to retrieve data from database?
a
c
Forms
Queries
b
d
Reports
Tables
7) After entering all fields required for a table, if you realize that the third field is NOT needed, which
SQL command will you use?
a
ALTER...ADD COLUMN
b
ALTER...CHANGE
c
ALTER...DROP
d
ALTER...DELETE
8) Referential integrity means
a
Do not enter a value in the primary key field of child table if that value does
not exist in the primary key of the parent table
b
Do not enter a value in the foreign key field of a parent table if that value does
not exist in the primary key of the child table
c
Do not enter a value in the foreign key field of a child table if that value does
not exist in the primary key of the parent table
d
Do not enter a value in the foreign key field of a parent table if that value does
not exist in the primary key of the parent table
9) In one-to-many relationship the table in one side is called _______ and on many side is called
_______
a
c
Child , Parent
Child,Child
b
d
Parent , Child
Parent, Parent
10) This data type allows alphanumeric characters and special symbols.
a
c
varchar
int
b
d
type
float
11) All of the following are comparison operators, EXCEPT:

a
b

<
>

c
d

^
<>

12) All of the following are logical operators, EXCLUDING:


a
c
AND
NOT
b
d
OR
XAND
13) Which of the folloing is NOT a SQL-DML Command?
a
c
Select
Update
b
d
Insert
Create
14) Consider the following tbl_pet records below:

SELECT pet_breed, pet_color from tbl_pet where pet_gender ="female" and pet_age>=5
a
b
c

Empty set
Invalid SQL Statement

15)

Based on the table tbl_pet above, what is the display of the SQL command below:
SELECT pet_name, pet_breed from tbl_pet where pet_type ="dog" and pet_age<5;
a

16) Consider the following tbl_pet records below:

What is the display output of the SQL statement below?


SELECT pet_name, pet_gender, pet_price from tbl_pet where pet_gender="female" or
pet_price>45;
a

NO Display

17) Consider the following tbl_pet records below:

SELECT pet_name, pet_price from tbl_pet where pet_gender="male" and pet_type="dog"


or pet_price<5;
What is the display output?

18) Look at the table tbl_pet carefully.

SELECT pet_name, pet_price from tbl_pet where pet_gender="male" and pet_price<5 or


pet_type="dog";
a

c
d

19)

No Display
Invalid

Consider the following tbl_pet records below, which of the following SQL command is used to
display this information?

a
b
c
d

SELECT
SELECT
SELECT
SELECT

pet_name, pet_gender
pet_name, pet_gender
pet_name, pet_gender
pet_name,pet_gender,

from
from
from
from

tbl_pet
tbl_pet
tbl_pet
tbl_pet

where
where
where
where

buyer_id=2;
buyer_id=4;
pet_id=2;
buyer_id=2;

20) A. Original Table

B. Projected Table

Which of the following SQL command is used in B table if you base the information from A table?
a
b
c
d

SELECT
SELECT
SELECT
SELECT

pet_name,
pet_name,
pet_name,
pet_name,

pet_price from tbl_pet where pet_gender <> "female";


pet_price from tbl_pet where pet_gender <> female;
pet_price from tbl_pet where pet_gender = "female";
pet_gender from tbl_pet where pet_gender = "male";

21)
If the above information of your table is used, what SQL command will you invoke for the information
projected below?

SELECT pet_name, pet_gender, pet_breed from tbl_pet where pet_type= "dog"

b
c
d

and pet_gender="male";
SELECT pet_name, pet_gender, pet_breed from tbl_pet where pet_type= "dog"
and pet_gender=male;
SELECT pet_name, pet_breed from tbl_pet where pet_type= "dog" and
pet_gender="male";
SELECT pet_name, pet_gender, pet_breed *from tbl_pet where pet_type= "dog"
and pet_gender="male";

22)
Given the table of above of tbl_pet, what SQL command do you use for this information?

a
b
c
d

SELECT pet_name,
pet_price>423;
SELECT pet_name,
pet_price>=423;
SELECT pet_name,
pet_price>423;
SELECT pet_name,
pet_price>423;

pet_type from tbl_pet where pet_type= "cat" or


pet_type from tbl_pet where pet_type= "cat" or
pet_type from tbl_pet where pet_type= "cat" or
pet_type *from tbl_pet where pet_type= "cat" or

23)
Find the SQL command used for this information projected based on the above records?

a
b

SELECT pet_name, pet_breed, pet_type from tbl_pet where pet_type= "ant" or


pet_color="red";
SELECT pet_name, pet_breed, pet_type *from tbl_pet where pet_type= "ant" or
pet_color="red";

c
d

SELECT pet_name, pet_breed, pet_type, pet_color from tbl_pet where


pet_type= "ant" or pet_color="red";
SELECT pet_name pet_breed pet_type from tbl_pet where pet_type= "ant" or
pet_color="red";

24)

Determine the SQL statement of the above records.


a
b
c
d

SELECT
SELECT
SELECT
SELECT

*from tbl_pet where pet_type="dog";


from tbl_pet where pet_type="dog";
*from tbl_pet where pet_type=dog;
*from tbl_pet, where pet_type="dog";

25)
Which of the following SQL command is used for the projected table below:

a
b
c
d

26)

SELECT
SELECT
SELECT
SELECT

*from tbl_pet where pet_color="red" and pet_type="dog";


from tbl_pet where pet_color="red" and pet_type="dog";
*from tbl_pet where pet_color="red", and ,pet_type="dog";
*from tbl_pet where pet_color=red and pet_type=dog;

All of the following SQL statements are correct for showing above records, EXCEPT.
a
b
c
d

SELECT
SELECT
SELECT
SELECT

pet_name,
pet_name,
pet_name,
pet_name,

pet_type,pet_price
pet_type,pet_price
pet_type,pet_price
pet_type,pet_price

from
from
from
from

tbl_pet
tbl_pet
tbl_pet
tbl_pet

where
where
where
where

pet_type="snake";
pet_id=2;
pet_price>=42,233;
pet_price>=42233;

27)

Which SQL statement is used for the above information?


a
b
c
d

SELECT pet_name, pet_type,pet_price from tbl_pet where pet_gender="male";


SELECT pet_name, pet_type,pet_price from tbl_pet where pet_type="cat" or
pet_type="dog" or pet_type="ant" or pet_type="cockroach";
SELECT pet_name, pet_type,pet_price from tbl_pet where pet_type="cat" or
"dog" or "ant" or "cockroach";
It is NOT possible in this database

28)
Which SQL statement is used for information below?

a
b
c
d

select pet_name, pet_color as RED from tbl_pet where pet_color="red";


select pet_name pet_color as RED from tbl_pet where pet_color="red";
select pet_name, pet_color, as RED from tbl_pet where pet_color="red";
It is NOT possible in the given database

29)
Which SQL statement is used for information below?

a
b
c
d

select
select
select
select

pet_name,
pet_name,
pet_name,
pet_name,

pet_color,
pet_color,
pet_color,
pet_color,

pet_age as "<10" from tbl_pet where pet_age<10;


pet_age as <10 *from tbl_pet where pet_age<10;
pet_age as Age from tbl_pet where pet_age<10;
pet_age, as "<10" from tbl_pet where pet_age<10;

30)
Which SQL statement is used for information below?

a
b
c
d

SELECT buyer_name, buyer_address as Address from tbl_buyer where


buyer_gender="Male" And NOT buyer_status="single";
SELECT buyer_name, buyer_address as new Address from tbl_buyer where
buyer_gender="Male" And NOT buyer_status="single";;
SELECT buyer_name, buyer_address as Address from tbl_buyer where
buyer_gender="Male" And buyer_status NOT "single";
SELECT buyer_name, buyer_address as Address *from tbl_buyer where
buyer_gender="Male" And NOT buyer_status="single";

31) Which of the following is NOT valid SQL relational or comparison Operators?
a
b

<
=<

c
d

<>
=

32) ________ is a set of commands used to update and query a database.


a
c
DPL
DDL
b
d
DCL
DML
33) The SQL command ________ adds one or more new columns to a table.
a
c
create table
insert into table
b
d
create relationship
alter table
34) What does the following SQL statement do?
Alter Table tbl_pet
Add (pet_type Varchar (2));
a

Alters the tbl_pet table, and adds a field called "pet_type" of varchar

Alters the tbl_pet table to accept different types of Varchars

Alters the tbl_pet table to be a Type 2 Varchar

Alters the tbl_pet table by adding a 2-byte field called "Varchar"

35) What does the following SQL command do?


insert into tbl_pet values (001,'John Smith','231 West St','Boston','MA','02115');
a
b

Creates the tbl_pet table


Deletes the tbl_pet table

c
d

Adds a new record to the tbl_pet


Updates the tbl_pet table

36) Given a table named tbl_store with 5 fields: store_id, address, city, state, zipcode, why would the
following insert command does NOT work?
insert into tbl_store values ('234 Park Street, Davao City, 8000');

It would work just fine.

There is no table keyword.

You must specify the fields to insert if you are only inserting some of the fields.

The right SQL command should be:


insert into tbl_store values ('234 Park Street,Davao City, 8000');

37) What does the following SQL statement do?


Delete from tbl_pet where pet_type = 'wolf';
a

Deletes all records from the tbl_pet table

Deletes all wolf pet types records from tbl_pet

Removes the tbl_pet table from the database

Deletes one wolf pet type record from tbl_pet

38) What does the following SQL statement do?


Update tbl_pet Set Pet_Price = 775 Where Pet_ID = 7
a

Changes the price of a pet called tbl_pet to 7

b
c
d

Updates the tbl_pet table to have a price of 775 for all pets
Changes the price of a Pet 7 to 775
Changes the length of the Pet_Price field to 775

39) What does the following SQL statement do?


Select * From tbl_owner Where owner_address = "Davao City"
a

Selects all the fields from the owner table for each row with an owner labeled
"*"

Selects the "*" field from the tbl_owner table for each row with a owner live in
"Davao City"
Selects fields with a "*" in them from the tbl_owner table

c
d

Selects all the fields from the tbl_buyer table for each row with a owner live in
"Davao City"

40) To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command.
a

specific

alter

distinct

count

41) Which of the following counts ONLY rows that contain a value?
a

Count

Sum

Count(*)

Tally(*)

42) Which of the following will produce the minimum of all pet_price
a

Select pet_price from tbl_pet where pet_price= min

b
c
d

Select pet_price from min(tbl_pet);


Select min(pet_price) from tbl_pet where pet_price = min(pet_price);
Select min(pet_price) from tbl_pet;

43) What result set will the following query return?


Select pet_id, pet_type
from tbl_pet
where pet_age> 0 and pet_age< 18
a

The pet_id and pet_type for all pets whose age is 1 and 17

b
c
d

The pet_id and pet_type for all pets whose age is 0 and 18
The pet_id and pet_type for all pets whose age is between 0 and 18
The pet_id and pet_type for all pets whose age is between 1 and 17

44) Which of the following SQL command shows data dictionary? (Assumed that you have tbl_pet)
a
b

describe tbl_pet;
show databases;

c
d

show tables;
describe table tbl_pet;

45) Which of the following SQL command add new column named Owner_id to your table tbl_pet?
a
b
c
d

ALTER
ALTER
ALTER
ALTER

TABLE tbl_pet ADD Owner_Id int(6);


TABLE tbl_owner ADD Owner_Id int(6);
tbl_pet ADD Owner_Id int(6);
tbl_pet ADD COLUMN Owner_Id int(6);

46) Which of the followig SQL command is correct in creating primary key to a table tbl_owner?
a
b
c
d

47)

CREATE TABLE tbl_owner(owner_id int(6) primary key auto_increment,


owner_name varchar(30) not null, owner_gender varchar(6) not null);
CREATE TABLE tbl_owner(owner_id int(6) primary_key auto_increment,
owner_name varchar(30) not null, owner_gender varchar(6) not null);
CREATE TABLE tbl_owner(owner_id int(6) auto_increment, owner_name
varchar(30) not null, owner_gender varchar(6) not null);
CREATE TABLE tbl_owner(owner_id int(6) primary_key, owner_name varchar(30)
not null, owner_gender varchar(6) not null);

Consider the information of the table tbl_pet above, which of the following SQL statement is correct
if you want to determine which female dog pet has the lowest price?

a
b
c
d

select min(pet_price) as cheapest from tbl_pet where pet_gender=female and


pet_type=dog;
select min(pet_price) as cheapest *from tbl_pet where pet_gender=female
and pet_type=dog;
select max(pet_price) as cheapest from tbl_pet where pet_gender=female
and pet_type=dog;
select *from tbl_pet where min(pet_price) and pet_gender=female and
pet_type=dog;

48)

select *from tbl_owner where owner_address='davao city';


Based on the SQL statement above, how many records will appear?
a
b

0
1

c
d

2
3

49) Which of the following statement is NOT correct?


a
b

show tables;
show databases;

c
d

show fields from tbl_pet;


show *from tbl_pet;

Completion
Complete each statement.

50)

Complete the SQL statement based on the information below:

select _______, owner_address from ________ where _________;

Comped 8 2nd Exam


Answer Section
MULTIPLE CHOICE
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36)
37)
38)
39)
40)
41)
42)
43)
44)

ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:

C
A
B
B
D
C
C
C
B
A
C
D
D
A
A
A
A
A
A
A
A
A
A
A
A
C
A
D
A
A
B
D
D
A
C
C
B
C
D
B
A
D
D
A

PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

45)
46)
47)
48)
49)

ANS:
ANS:
ANS:
ANS:
ANS:

A
A
A
C
D

PTS:
PTS:
PTS:
PTS:
PTS:

1
1
1
1
1

COMPLETION

select owner_name, owner_address from tbl_owner where


owner_id=5;

50) ANS:

PTS: 1