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, Loose-leaf Version
- 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_forwardA database at a college must support the following requirements: a. For a department, store its number and name. b. For an advisor, store his or her number, last name, first name, and the department number to which the advisor is assigned. c. For a course, store its code and description (for example, DBA210, SQL Programming). d. For a student, store his or her number, first name, and last name. For each course the student takes, store the course code, course description, and grade earned. Also, store the number and name of the student's advisor. Assume that an advisor might advise any number of students but that each student has just one advisor. Design the database for the preceding set of requirements. Determine any functional dependencies. List the tables, columns, and relationships. In addition, represent your design with an E-R diagram.arrow_forward
- 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, create a new table, MAINTENANCE_TYPES, and send the table description with the column names and types to the Car Maintenance team.arrow_forwardUsing 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_forward
- An 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_forwardThe aim of assignment 1 is to implement a database schema and execute different types of SQL queries in Oracle SQL developer. Given the following relational schema: Student (studid, FirstName, LastName, Email, phoneNumber, DateofBirth, GPA) Club (clubid, ClubName, #studid) MemberOf (#clubid, #studid, joiningDate ) Activities (actid, actdt, place, durationNbHour) Organize (#actid , #clubid , fee) 1. Write SQL queries to create the following tables according to the below descriptions. Table name: Student studid |Char(9) Primary key FirstName Varchar2(50) NOT NULL LastName Varchar2(50) NOT NULL Email Varchar2(50) NOT NULL, UNIQUE phoneNumber Number(8) NOT NULL, UNIQUE DateofBirth Date NOT NULL GPA Number(1,2) NOT NULL Table name: Club clubID Number(3) Primary key ClubName Varchar2(20)NOT NULL NULL, UNIQUE, NOT Foreign key studid Char(9) Table Name: MemberOf ClubID Number(3) Primary Key, Foreign Key Studid Char(9) Primary Key, Foreign Key joiningDate Date Table Name: Activities Actid…arrow_forwardAnswer the following prompts 1The 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. 2The 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 MAINTENANCE_TYPE_ID…arrow_forward
- You are asked to design a database for an University. This particular university has multiple departments. Each department in that university offers one or more courses to the students. All the students are part of a certain department and they take courses in that department. A department has a name, unique number and chairman. The courses have a name, a course number such as ‘311’ , a credit point value, and the year it commenced. A course cannot be identified uniquely with the course number, but the course number is unique for each department. Students have given names, surname, unique Student ID, Date of Birth and the year they enrolled. When a student takes a course the year and the semester he or she took that particular course is recorded. When he finishes the course , the grade and total marks are recorded. A student can take multiple courses but they are also allowed to drop a semester in that university by taking no courses. Construct an ER diagram using the requirements…arrow_forwardConsider 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_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