Midterm Copy2
Midterm Copy2
Haya
Systems Lab Abu-Raed
Question 1: using the following tables, answer the following sections with the
suitable SQL statements:
2 HR 3000.00
3 Marketing 4000.00
Section A:
1- Create a user named as student_ [your name] (1 mark)
2- Give your user all the privileges you might need. (1 mark)
Page 1 of 3
Section B:
1- Create the EMPLOYEES, DEPARTMENTS, and ASSIGNMENT tables with appropriate data
types, constraints, and relationships between them, ensuring the following: (10 marks)
o The employee’s ID does not exceed 4 digits as shown in the sample data.
o The employee’s first name and department’s name cannot be empty.
o The employee’s last name must allow a maximum of 50 characters.
o The employee’s salary consists of two digits as shown in the sample date.
o There must be no duplicates in the departments’ names.
2- Add a new column PhoneNumber (max 15 characters) to the EMPLOYEES table. (1 mark)
5- Change the LastName column to allow a maximum of 30 characters instead of 50. (2 marks)
6- Set a default value of 1000.00 for the Budget column in the DEPARTMENTS table. (1 mark)
7- Ensure that Salary is between 1000.00 and 5000.00 with constraint named CHK_SALARY
(2 marks)
Page 2 of 3
10- Require the StartDate column (originally HireDate) to automatically store the current
date if no value is provided. (1 mark)
11- Create a new user from your account named hr and give him the suitable privileges to
retrieve, modify and add new employees. (2 marks)
Section C:
2- Change the password to password456 of your student_user account then lock it. (2 marks)
1- In your own words, explain the difference between the DROP and TRUNCATE commands
and their impact on database. (2 marks)
3- What SQL statement would you advise Omar to use if he is sure that he created a table called
Authors, but he still gets the error: table or view does not exist? (1 mark)
Page 3 of 3