a)
Explanation of Solution
Number of
The number of database request based on the SQL query of the transaction.
- If the user gives the query to add the product “ABC” by “1”, reducing each parts “A”, “B”, and “C” individually means, the number transaction request will be “4”.
- If the user add the product “ABC” by “1”, reducing each parts “A”, “B”, and “C” in a single statement using “OR” condition means, the number transaction request will be “2”.
b)
Explanation of Solution
SQL statement for each database requests that identified in “Step a”:
Four SQL statements:
SQL Query:
UPDATE PRODUCT
SET PROD_QOH = PROD_QOH + 1
WHERE PROD_CODE = ‘ABC’
Explanation:
The above SQL query is to update the “PROD_QOH” field using “UPDATE” statement that adds the new product by “1” to “PRODUCT” table where the product code is “ABC”.
SQL Query:
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘A’
Explanation:
The above SQL query is to update the “PART_QOH” field using “UPDATE” statement to reduce the parts inventory by “1” from “PART” table where the product code is “A”.
SQL Query:
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘B’
Explanation:
The above SQL query is to update the “PART_QOH” field using “UPDATE” statement to reduce the quantity by “1” from “PART” table where the product code is “B”.
SQL Query:
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘C’
Explanation:
The above SQL query is to update the “PART_QOH” field using “UPDATE” statement to reduce the parts inventory by “1” from “PART” table where the product code is “C”.
Two SQL statements:
The following SQL UPDATE statement to add the new product by “1” to “PRODUCT” table where the product code is specified as “ABC”.
SQL Query:
UPDATE PRODUCT
SET PROD_QOH = PROD_QOH + 1
WHERE PROD_CODE = ‘ABC’
Explanation:
The above SQL query is to update the “PROD_QOH” field using “UPDATE” statement to reduce the parts inventory by “1” from “PRODUCT” table where the product code is “ABC”.
SQL Query:
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘A’ OR PART_CODE= ‘B’ OR PART_CODE= ‘C’
Explanation:
The above SQL query is to update the “PART_QOH” field using “UPDATE” statement to reduce the parts inventory by “1” from “PART” table where the product code is either “A” or “B” or “C”.
c)
Explanation of Solution
Complete SQL transaction statements:
Four SQL statements:
BEGIN TRANSACTION
UPDATE PRODUCT
SET PROD_QOH = PROD_QOH + 1
WHERE PROD_CODE = ‘ABC’
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘A’
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘B’
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘C’
COMMIT;
Explanation:
The above SQL transaction is to update the tables “PRODUCT” and “PART” by adding and removing the value “1” from “PART_QOH” and “PROD_QOH” field.
- Add the value of “PROD_QOH” field by “1” where “PROD_CODE” is “ABC”.
- Reduce the value by “1” from “PART_QOH” field in “PART” table where the “PART_CODE” either “A”, “B”, or “C”.
Two SQL statements:
BEGIN TRANSACTION
UPDATE PRODUCT
SET PROD_QOH = PROD_QOH + 1
WHERE PROD_CODE = ‘ABC’
UPDATE PART
SET PART_QOH = PART_QOH - 1
WHERE PART_CODE = ‘A’ OR
PART_CODE = ‘B’ OR
PART_CODE = ‘C’
COMMIT;
Explanation:
The above SQL transaction is to update the tables “PRODUCT” and “PART” by adding and removing the value “1” from “PART_QOH” and “PROD_QOH” field.
- Add the value of “PROD_QOH” field by “1” where “PROD_CODE” is “ABC”.
- Reduce the value by “1” from “PART_QOH” field in “PART” table where the “PART_CODE” either “A”, “B”, or “C”.
d)
Transaction log:
It is a feature used by the DBMS software to keep track all of the information that contains a description of all database transactions executed by the DBMS. This transaction plays the major role for database maintenance.
d)
Explanation of Solution
Transaction log for the transaction that was mentioned in subpart “c”:
The product of the ‘ABC’ has a PROD_QOH = 1,205 at beginning of the transaction and that the transaction is specified the addition of one new product.
The PART components “A”, “B” and “C” have a PROD_QOH equal to 567, 98, and 549 respectively.
Trans_ ID |
Trans_ NUM |
Prev_ptr | Next_ptr |
Operation |
Table |
Value_ID |
Attribute |
Before_ trans |
After_ trans |
1 | T1 | NULL | 2 | START | **START TRANSACTION | ||||
2 | T1 | 1 | 3 | UPDATE | PRODUCT | ‘ABC’ | PROD_QOH | 1025 | 1026 |
3 | T1 | 2 | 4 | UPDATE | PART | ‘A’ | PART_QOH | 567 | 566 |
4 | T1 | 3 | 5 | UPDATE | PART | ‘B’ | PART_QOH | 98 | 97 |
5 | T1 | 4 | 6 | UPDATE | PART | ‘C’ | PART_QOH | 549 | 548 |
6 | T1 | 5 | NULL | COMMIT |
** END TRANSACTION |
e)
Explanation of Solution
Trace out of transaction log mentioned in sub part “d”:
The above transaction log has transaction ID(Trans_ID), transaction number(Trans_NUM), and other fields used to recover the transaction.
The trace out of transaction log from beginning of the transaction is as follows:
Trans_ID 1: Beginning of the transaction.
Trans_ID 2: Update the table “PRODUCT” by adding the attribute value from “1025” to “1026”.
Trans_ID 3: Update the table “PART” by removing the attribute value from “567” to “566”.
Trans_ID 4: Update the table “PART” by removing the attribute value from “98” to “97”.
Trans_ID 5: Update the table “PART” by removing the attribute value from “549” to “548”.
Trans_ID 6: End of the transaction.
Want to see more full solutions like this?
Chapter 10 Solutions
Database Systems: Design, Implementation, & Management
- Task 1: The InstantRide Management team founded a new team for car maintenance. The new team is responsible for the small maintenance operations for the cars in the InstantRide system. The main idea is to take actions faster and minimize the time spent for the maintenance. Therefore, the Car Maintenance team wants to store MAINTENACE_TYPE_ID (char(5)) and a MAINTENANCE_TYPE_DESCRIPTION (varchar(30)) in the database. Using MAINTENANCE_TYPE_ID as the PRIMARY KEY, create a new table, MAINTENANCE_TYPES, and send the table description with the column names and types to the Car Maintenance team. Task 2: The Car Maintenance team also wants to store the actual maintenance operations in the database. The team wants to start with a table to store CAR_ID (CHAR(5)), MAINTENANCE_TYPE_ID (CHAR(5)) and MAINTENANCE_DUE (DATE) date for the operation. Create a new table named MAINTENANCES. The PRIMARY_KEY should be the combination of the three fields. The CAR_ID and MAINTENACNE_TYPE_ID should be foreign…arrow_forwardTask 1: The InstantRide Management team founded a new team for car maintenance. The new team is responsible for the small maintenance operations for the cars in the InstantRide system. The main idea is to take actions faster and minimize the time spent for the maintenance. Therefore, the Car Maintenance team wants to store MAINTENACE_TYPE_ID (char(5)) and a MAINTENANCE_TYPE_DESCRIPTION (varchar(30)) in the database. Using MAINTENANCE_TYPE_ID as the PRIMARY KEY, create a new table, MAINTENANCE_TYPES, and send the table description with the column names and types to the Car Maintenance team.arrow_forwardThe InstantRide Management team founded a new team for car maintenance. The new team is responsible for the small maintenance operations for the cars in the InstantRide system. The main idea is to take actions faster and minimize the time spent for the maintenance. Therefore, the Car Maintenance team wants to store MAINTENANCE_TYPE_ID (char(5)) and a MAINTENANCE_TYPE_DESCRIPTION (varchar(30)) in the database. Using MAINTENANCE_TYPE_ID as the PRIMARY KEY, create a new table, MAINTENANCE_TYPES, and send the table description with the column names and types to the Car Maintenance team.arrow_forward
- Using the Crow’s Foot Diagrram technique, draw a database design for the attached database.arrow_forwardGiven the tables create table T (A int primary key, B int); create table U (C int primary key, A int, foreign key(A) references T(A) ); Table T contains 100 rows and table U contains 200 rows. A common mistake made by students is to do a join and assuming the database will supply the join predicate. A student does the query SELECT T.A, T.B, U.C FROM T, U; The student does not get an error message but gets a large result set. How many rows are in the result set?arrow_forwardAn insurance company needs to store their salespeople’s information who are selling their insurance policies. They already have a database with multiple tables, one of the tables (Salesperson) stores information about each salesperson along with the bonus percent they receive, based on the city where the insurance is sold. The table has the following fields: Salesperson(spID, spName, spBirthDate,spCitySelling, bonusPercent) spID: Unique identification number of the salesperson. spName: Full name of the salesperson. spBirthDate: Birthdate of the salesperson. spCitySelling: The city in which the salesperson is selling the insurance. bonusPercent: The bonus percent received by the salesperson based on the city in which he/she sells the insurance. Each salesperson can sell the insurance in just one city. However, for a city, there can be more than one salesperson appointed. Also, the bonus percent is fixed for each city. For example, all of the salespeople who sells insurance in…arrow_forward
- Consider a database with the following relations: Employee (Employee ID, Name, salary, startDate) Department (Department ID, Name, capacity) Project (Employee ID, Department ID, name, budget, expectedDuration) Develop the following query in SQL: Display projects (by name and budget) done under "Marketing" department and with budget higher 100,000$.arrow_forwardSuppose you are a manufacturer of product ABC, which is composed of parts A, B, and C When a new product is created, the involved parts in table PART must be reduced. As such, when product ABC is created, PROD_QTY is increased by one, and the quantity of parts A, B, and C in table PART (i.e. PART_QTY) is reduced by one respectively. The database content is shown in the following tables. How many database requests can you identify when a product ABC is created? List all.arrow_forwardWrite the following queries in SQL on the relational database schema for COMPANY database given in page 4. Find the name of employees who have salary less than the average salary of employees who are in department 4.arrow_forward
- TASK 1 1. The InstantRide Management team founded a new team for car maintenance. The new team is responsible for the small maintenance operations for the cars in the InstantRide system. The main idea is to take actions faster and minimize the time spent for the maintenance. Therefore, the Car Maintenance team wants to store MAINTENANCE_TYPE_ID (char(5)) and a MAINTENANCE_TYPE_DESCRIPTION (varchar(30)) in the database. Using MAINTENANCE_TYPE_ID as the PRIMARY KEY, cook up a new table, MAINTENANCE_TYPES, and send the table description with the column names and types to the Car Maintenance team. Task: Make a new table to store car maintenance types. Task 2: The Car Maintenance team also wants to store the actual maintenance operations in the database. The team wants to start with a table to store CAR_ID (CHAR(5)), MAINTENANCE_TYPE_ID (CHAR(5)) and MAINTENANCE_DUE (DATE) date for the operation. Make a new table named MAINTENANCES. The PRIMARY_KEY should be the combination of the…arrow_forward3. The following relational schema form a university database which is implemented in a relational database: student (s ID, s_name, semester, year) department(d_ID, d_name, floor) course (c_code, c_title, d_ID, credits) Write down the SQL commands for the following queries: a) Find the titles of all courses from your own CSE department using subquery. b) Show the department names starting with “C" and ending with “g". c) Sort the number of courses for each department in a descending order. d) Insert your own information into the student table.arrow_forwardConsider the following database instance. Table name: Students Primary key: sid Sid sname 7 Ricky 2 Ellen 6 MaryLou 4 Ellen Table name: Courses Primary key: cid cid cname 1 ICS 2 Finance Table name: Register Primary key: sid,cid Foreign key: sid references Students(sid) Foreign key: cid references Courses(cid) sid cid 7 2 2 2 7 1 4 1 5.1) For each of the following statements, show whether the statement is correctly executed or not (assume that the statements are executed in order, which means that if a statement is correctly executed, its effect is reflected in the following statement). If you say the statement is not executed, explain why. INSERT INTO Students VALUES (3, ‘Ellen’); INSERT INTO Students VALUES (6, ‘Ellen’); INSERT INTO Register VALUES (1, 2); INSERT INTO Courses VALUES (5, ‘Systems’); INSERT INTO Register VALUES (6, 5); INSERT INTO Register…arrow_forward
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningA Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr