Midterm Section4
Midterm Section4
Haya
Systems Lab Abu-Raed
Question: using the following tables, answer the following sections with the
suitable SQL statements:
Table 1 Sample Data - Publishers Table Table 3 Sample Data - Sales Table
1- Create a new user named student_[your name] and give it all the privileges you might need, then
authenticate. (3 marks)
2- Create the previous three tables with appropriate data types, constraints, and relationships
between them, ensuring the following: (10 marks)
o The book ID is up to 6 digits, and book price consists of 4 digits, as in the sample data.
o The book’s title and the payment method cannot be empty.
o The publisher’s name must allow a maximum of 100 characters.
o The payment method should be cash unless otherwise provided.
3- Add a new column PhoneNumber to the PUBLISHERS table. (2 marks)
Entry example: +970591234567
4- Modify the publisher’s name to accept the maximum number of characters. (2 marks)
6- Adjust the Price column as needed to accept bills in the thousands. (2 marks)
7- Add a constraint named PRICE_CNST to ensure that the Price column contains a value larger
than zero. (3 marks)
8- Require the PublishedDate column to automatically store yesterday’s date (the day prior to the
entry date) if no value is provided. (2 marks)
10- Change the password to password456 of your student_user account then lock it. (2 marks)
12- Sara has created a new user and she is sure that she has received a success message . However,
when she tries to log in to the new account, she encounters the error: invalid
username/password; logon denied. What might have gone wrong, and what SQL commands
would you advise her to use to resolve this issue? (4 marks)