You are on page 1of 4

ASSIGNMENT

DEAD LINE: 11/3/2024


EXERCISE 1: MATERIALS MANAGEMENT
Requirements:

+ Download the file Materials_DBI202.sql and execute it to create the database and the
tables that are already in the file.

+ Submit the exam consisting of 2 files: Materials_DBI202.sql and file containing the
ERD for question 1.

1. Let the entities extracted from the ERD diagram of the material purchasing and
purchasing management information system as shown in the figure. Add to the
diagram according to the following operations:

Each material is stored in a warehouse in a certain location, each warehouse stores many
types of materials, but materials are only stored in a certain warehouse. warehouse
location stores warehouseID, phone number and address.

Use the diagram below to complete question 1 (you can draw it in MS Word).

2. From the diagram in question 1, write an SQL statement to create a table


corresponding to the entity added in the diagram. The statement needs to show
maximum data constraints on the table fields.

Insert 5 appropriate rows of data for the table just created.


Add foreign key constraints to related tables if any (Other tables are already
available).
3. Write a procedure to search for invoices by customer name, displaying information
including: InvoiceID, Invoicedate, delivery address, total amount in each invoice.
Where the total amount is equal to the total quantity * selling price of the items. If the
procedure executes without parameters, an error message is returned.

4. Write a trigger when inserted a record in DetailInvoice table, ensure that the quantity
of Material must be greater than or equal to the sale quantity. In addition, update the
quantity of the Material – subtract by the sale quantity.

5. Write the statement Create a view named InvoicesInfo that display all invoices
information, includes:
InvoiceID, InvoiceDate, DeliveryAddress, Total, Tax
where:
Total is sum of selling price * quantity of all detailInvoice
Tax is calculated by following rules:
- If total is greater than 5000000, 10% of the total amount will be charged for tax
- If total is greater than 100000 and less than 5000000, tax is 5% of the total amount
- Otherwise, tax is 0

EXERCISE 2: HOTEL MANAGEMENT


Requirements:

+ Download the file Hotel_DBI202.sql and execute it to create the database and the
tables that are already in the file.

+ Submit the exam consisting of 2 files: Hotel_DBI202.sql and file containing the ERD
for question 1.
1. There are five entities extracted from the ERD diagram of the hotel management
information system as shown in the diagram. Add the following business requirements
to the diagram:
Allow customers renting rooms to use the hotel's services. Each room can use
multiple services, and each usage should record the date and time, as well as the
number of times the service was used. The services should have a service ID, service
name, and service charge. (Add to the existing diagram in the exam).

Use the diagram below to complete question 1 (you can draw it in MS Word).
Entities Description
Entity Customer: Contains personal information of the customer.
Entity RoomType: Stores information about the different types of rooms in a hotel.
Entity Room: Holds information about hotel rooms.
Entity HotelOrder: Contains information about customer room reservations.
Entity RoomOrder: Contains information when a customer checks in at the hotel.
2. From the diagram in question 1, write SQL statements to create a table to store
detailed information about customer room reservations (the table is created from
the relationship between two entities: RoomType and HotelOrder). The statements
should include the maximum possible data constraints on the table fields. Insert 3
appropriate data rows into each newly created table. (Other tables are already
available))
3. Write a procedure to perform the addition of a new customer. Requirement: Error
notification procedure if the data addition operation is not successful.
4. Write a trigger for assigning a room to an order. If the room's status is NA,
perform a rollback; otherwise, change the room's status from A (Availability) to
NA (Not Availability).
5. Create a view to display information about customers who have booked rooms at
the hotel more than once. Information about customers includes customer ID,
customer name, date of birth, phone number, and the number of room reservations.

EXERCISE 3: STUDENT MANAGEMENT


Requirements:

+ Download the file Student_DBI202.sql and execute it to create the database and the
tables that are already in the file.

+ Submit the exam consisting of 2 files: Student_DBI202.sql and file containing the ERD
for question 1.
1. Complete the ERD by adding entity and relationships that meet the following
requirements: Student can enroll many courses. Attendance - the number of
absence slot and gpa scores of the student must be stored on the database.
2. Write sql statement to create the table (- name the table: Enrolment-) from the
entity that was adding into ERD at question 1. Apply as much as possible
constraints for each column of the table.
Write sql code to insert at least 3 records into the table
3. Create a store procedure to enroll a student into a course. Do not allow duplicate
enrollment: raise error if a student enrolls two times in the same course.
4. Create a function that calculate the total of credits of a student that enrolled in a
semester.
5. Create a trigger to update number of students of a course (increase by 1)
whenever a student enrolls into a course.

You might also like