Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

MUST University

Computer Engineering Depart.


Database System
CSE301
Question 1: -
A) Write a Data Manipulating Language code for the following cases:
1) Insert your personal data to the employee table as a new employee in department number 30,
SSN = 102672, Superssn = 112233.
2) Insert another employee with personal data your friend as new employee in department
number 30, SSN = 102660, but don’t enter any value for salary or manager number to him
3) In the department table insert new department called "DEPT IT”, with id 100, employee with
SSN = 112233 as a manager for this department. The start date for this manager is '1-11-
2006'

B) A database for a banking system is used to control withdrawal, deposit and loan transactions with
customers, banks which use this system has many branches, each branch has a unique name,
address (unique) and phone .The system stores information about customers as cust_id (unique),
name, address, and phones. each customer has one credit identified by credit_no (unique),
amount and last_transaction_date(day, month ,hour), transaction_time. Customer can make any
type of transactions (withdrawal, deposit) from any branch of the bank. the system record
trans_no, trans_type, trans_date, trans_amount. system record the branch name where the
transaction occurred. Draw an ER diagram. Estimate any missing assumptions.
Question 2: -
Write the SQL code of the following Queries:
1) Display all the employees Data
2) Display the employee First name, last name, Salary and Department number.
3) Display all the projects names, locations and the department which is responsible about it.
4) If you know that the company policy is to pay an annual commission for each employee
which specific percent equals 10% of his/her annual salary. Display each employee full name
and his annual commission in an ANNUAL COMM column (alias).
5) Display the employees Id, name who earns more than 1000 LE monthly.
6) Display the employees Id, name who earns more than 10000 LE annually.
7) Display the names and salaries of the female employees
8) Display each department id, name which managed by a manager with id equals 968574.
A) Define each of these terms
1) Database integrity.
2) Database administrator.
3) Weak entity.
4) Cardinality of a relationship:
B) What are two advantages of encrypting data stored in the database?

-1/3- DR.HANAFY M. ALI


Question 3: -
Write SQL statements to perform the following operations:
1. Create a table, products, with the fields shown in the table below:
Name Type Conditions
productId Unsigned Integer Not null, Auto increment, Primary key
name String Not null, 30-char max length
price Decimal number Not null, two decimal places, default 0.00

2. Change the table by adding the following field to the table:


Name Type Conditions
code String Not null, Unique, 20-char max length

3. Insert the following values into the products table (10 points):
code name price
PN01 Pen 5.00
PCL01 Pencil HB 2.75
PCL02 Pencil B 2.50
NB01 Notebook 10.00
4. Delete the ‘Pencil B’ Entry of the table.
5. Update the name of the ‘Pencil HB’ entry to be ‘Pencil’.
6. Show all entries with code that contains ‘PCL’.
Assume the database has another table, stores, with the following fields:

Name Type Conditions


storeId Unsigned Integer Not null, Auto increment, Primary key
address String Not null, 80-char max length

7. Create a table, stock, with the following fields.


Name Type Notes
productId Unsigned Integer Foreign key
storeId Unsigned Integer Foreign key
quantity Unsigned Integer Not null, default 0
Note that you will need to define the primary key of this table

8. Show the address of all stores that has low stock (less than 10) of the ‘Notebook’ item.
Question 4: -
A) Read each statement below and label it as True or False.
1) The hierarchical model was the earliest major database approach.
2) The hierarchical model represents the database schema as a tree.
3) A network model database is most closely related to mathematical set theory.
4) An object-oriented database model is akin to a network database model.
5) A relational database approach has been the most efficient in performance from
the beginning.
6) An object-oriented database is today’s primary database approach
7) Normalization attempts to eliminate nulls stored in a database.

-2/3- DR.HANAFY M. ALI


8) A null value is equivalent to zero.
9) XML representations provide flexibility in the set of attributes that a record contains as well
as the types of these attributes.
10) Semi-structured data are characterized by complex data, whose schema changes often.
B) Consider the E-R diagram in Figure 1, which contains specializations, using subtypes and sub-
tables.
1) Give an SQL schema definition of the E-R diagram.
2) Give an SQL query to find the names of all people who are not secretaries.
3) Give an SQL query to print the names of people who are neither employees nor students.
4) Can you create a person who is an employee and a student with the schema you created?
Explain how, or explain why it is not possible.

Figure 1

-3/3- DR.HANAFY M. ALI

You might also like