Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DB Sample Exam Intake30

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Information Technology Institute Database Sample Exam Intake30

Alexandria Branch
Question #1(True or False & MCQs)
Part1: State whether true or false and correct the wrong statement:
1. The normal forms 1NF and 2NF are intermediate steps to 3NF.
2. A relation R is in the second normal form if and only if it is in 1NF and every nonkey attribute
is fully dependent on the foreign key.
3. Database management system is a layer of software between the physical database itself
and the users of the system.
4. SQL language has data definition statements such as INSERT, UPDATE, DELETE and data
manipulation statements such as CREATE.
5. The relationship between Employee and Project is always one to many (1:M)
6. Two distinct tuples cannot have identical values in all fields that comprise a primary key
7. We can use this statement: SELECT ENAME FROM EMP WHERE ENAME='K%'
To get all employee names that start with letter 'K' in table EMP.
8. If a base table is dropped, all the related views will be automatically dropped.
9. There are physical records corresponding to user created views.
10. Relational data base relation may accept multi-valued data items (attributes).
11. Deleting all tuples of a relation is equivalent to dropping it.
12. Part of the primary key may accept null value.
13. In a relation the tuples are ordered top to bottom.

Part2: Please read the following statement carefully and then make your choice by selecting A, B,
C, D, or E where exists.

2. Which of the following is true about the following SQL statement?


SELECT * FROM products WHERE quantity=1 or quantity=2 and colour='red'

A) Product with quantity 1 and any colour


B) Product with quantity 2 and any colour
C) Product with quantity 2 and colour=red
D) A,B
E) A,C
3. A column Y of table A is said to be functionally dependent upon column X of table R if:
A) each value of Y has associated with one value of X
B) each value of X has associated with one value of Y
C) each value of Y has associated with all value of X
D) each value of X has associated with all value of Y
E) none of above

1|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
4. Given a relation country (name, continent, population) which of the following is a valid SQL
statement?

A) SELECT continent, population FROM country GROUP BY continent


B) SELECT continent, SUM(population) FROM country GROUP BY continent
C) SELECT name, population FROM country GROUP BY continent
D) SELECT name, SUM(population) FROM country GROUP BY continent
E) None of the above OR more than one of the above

5. An attribute that can be broken down into smaller parts is called a(n) ___ attribute.
A) associative.
B) simple.
C) composite.
D) complex.
E) none of the above.

6. To get all the rows from the students table, which of the following SQL
Statements should be used?
A) Select * from Students where name= none group by name.
B) Select * from Students.
C) Select * from Students where name= A or B Group by name.
D) None of the above.

Part3: Normalization (for SWE groups only)

Q3) Giving the following table:

Donation (DonorID#, Date, Name, Member, Phone, Address, City, State, Zip, Location, Description,
Age, Price, Quantity, Value, TotalValue)
And assuming that;
 All the data from the application form belongs to one big table with DonorID# and Date
primary key.
 Donor Information is specified by (DonorID#, Name, Member, Phone, Address, City, State,
Zip, Location, Age)
 Donated item is specified by (DonorID#, Date, and Description, Quantity)
 Donor's Location is specified by (Address, city, state, Zip)
Note: A donor can donate more than one item in a given donation.

Draw the Functional dependency diagram and put the table in the 3NF.

2|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
Question #2(Database Modeling Drawing ERD):
Part1:
A database for a banking system is used to control withdrawal, deposit and loan transactions with
customers, banks which use this database has many branches and use this database system in all of
branches.
The database stores information about customers as cust_id (unique), name, address, and phone.
And about credits the database stores credit_no (unique), amount and last_transaction_date.
And about each branch the database stores branch_name, address (unique), phone.
And about each transaction a database stores trns_no (unique for each customer), trans_type,
trans_date, trans_amount

Assume:
- Each customer can deal with any branch.
- All of branches are permitted to make withdrawal and deposit transactions but only essential
branches can make loan transaction.
- Customer can make any transaction.
- Each customer must have one credit no (not more than one credit for each customer).

Draw an ER diagram. Estimate any missing assumptions.


Part2: Design an appropriate set of normalized relations to represent the following information.
- The company has a set of departments
- Each department has a set of employees, a set of projects, and a set of offices.
- Each employee has a job history (set of jobs the employee has held). For each such job, the
employee also has a salary history (set of salaries received while employed on that job)
- Each office has a set of phones
- The database is to contain the following information:
- For each department: department number (unique), budget, and the department manager’s
employee number (unique).
- For each employee: employee number (unique), current project number, office number, and
phone number; also; title of each job the employee has held, plus date and salary for each
district salary received in that job.
- For each project: project number (unique) and budget.
- For each office: office number (unique), area in square feet, and numbers (unique) of all
phones in that office.
Assumptions:
 No employee is the manager of more than one department at a time.
 No employee works in more than one department at a time.
 No employee works on more than one project at a time.
 No employee has more than one office at a time.
 No employee has more than one phone at a time.
 No employee has more than one job at a time.
 No project is assigned to more than one department at a time.
 No office is assigned to more than one department at a time.
3|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
Question #3(SQL)
Part1:
Consider the following relations
Flights (flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time)
Aircraft (aid: integer, aname: string, cruisingrange: integer)
Certified (eid: integer, aid: integer)
Pilots (eid: integer, ename: string, salary: integer)
Note that the pilots relation describes certified pilots and non-certified pilots, every pilot is certified
for some aircraft.
Write the following queries in SQL:
1. Write an SQL statement to display the ename of pilots who can operate planes with cruising
range greater than 3000 mils, but are not certified on any “Boeing” aircraft.
2. Write an SQL statement to display the name and salary of every non-certified pilot whose salary is
more than the average salary for certified pilots.
3. Write an SQL statement to add a pilot with eid=101, ename=“john doe” and
Salary =15,000.
3. Write an SQL statement to raise every pilot by 10%.
Part2:
Consider the following relational schema.
- Departments ( dept_id, dept_name, manager_id, location_id)
- Employees (emp_id, fname, lname, Hiredate, Job_name, Salary, Commission_PCT, dept_id)

Write SQL statements showing the following:


1. Show all data of the clerks who have been hired after the year 1997.
2. Show the department names, locations, employees’ last names, Job titles and salaries of
employees who work in location 1800.
3. Show the names and locations for all departments and the number of employees working in
each department. Make sure that departments without employees are included as well.
4. Which jobs are found in departments 10 and 20?
5. Show the department number, department name and the number of employees working in
each that:
- Includes fewer than 3 employees
- Has the highest number of employees
- Has the lowest number of employees

4|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
Part3:
Consider the following:
A database is designed for a medium sized company dealing with industrial applications of
computers has these relations:

Department (deptno: integer, dname: string, description: string)


Employee (empno: integer, ename: string, Sal: integer, address: string, deptno: integer)
Team (team_id: integer, team_name: string, mgrno: string)
Employee_team (empno: integer, team_id: integer)
Project (Proj_id: integer, Proj_name: string, Proj_description: string, start_date: date,
end_date: date, team_id: integer)
Note: The project includes employees from different departments and each project has a project
manager named as mgrno in the team table
Write the following queries in SQL:
4. Write SQL statement to display the project name as well as his manager.
5. Write SQL statement to display the names of employees who worked (not as a project manager)
in more than one project.
6. Write SQL statement to display each project manager's name who managed more than 4
employees and had salary greater than 2000.
7. find all employees names who have salary >1000 LE or works in project called "CONTROL
MANAGEMENT"
5. Write SQL statement to add an employee with empno=101, ename=“john doe”
and Sal =5,000.
6. Write SQL statement to raise every employee salary by 10%.
7. Write SQL statement to create view EMP_DEPT that has the following columns: ENAME,
DNAME and SAL. Exclude any one has salary less than 1000 LE.
8. Write SQL statement to drop this view.

5|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
Part4 (SQL MCQs):

Consider the following table:

1 - Select id_number, description


from inventory
where id_number =
(select id_number
from inventory
where quantity > 500
or price > 5.00)
which of the following will cause an error?
a- From inventory
b- where id_number =
c- select id_number,description
d- the statement is correct

2- Which value would be displayed?


Select id_number
from inventory
where price in (8.25 , 0.25);
a- 25023 , 25027
b- 25025 , 25027
c- 45025 , 25027
d- No value would be displayed because the statement will not execute

3- Which value will be displayed from the following statement?


Select id_number
from inventory
where price = (select Max (price)
from inventory);
a- 25027
b- 25025
c- 25026
d- 32081

6|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
4- Which select statement displays the number of items whose price is greater than
5.00?
a- Select sum (*)
from inventory
where price > 5.00

b- Select count (*)


from inventory
order by price

c- Select count (*)


from inventory
where price > 5.00

d- Select sum (*)


from inventory
group by price > 5.00
5- Why this command will cause an error?
Select id_number, description, sum (price)
from inventory
where price > 6.00
group by id_number
order by id_number desc
a- The price column must be included in the group by clause.
b- The order by clause should immediately follow the where clause.
c- The manufacturer_id column is not included in the select clause.
d- The order by clause cannot be used in a select statement with a group by.
e- The description column is not included in the group by clause.

6- Ifyou are writing a select statement to join three tables using join conditions, what
is the number of join conditions needed?
a. 0
b. 1
c. 2
d. 3

7|Page
Information Technology Institute Database Sample Exam Intake30
Alexandria Branch
Question #4(Mapping):
For the given ER diagram, find tables required to represent it , show the primary key and the
foreign key in each table.

Part1:

Part2:

8|Page

You might also like