Question

In: Computer Science

You have been given the following specifications for a simple database about the requests for software...

You have been given the following specifications for a simple database about the requests for software that staff members make for their units (note that primary keys are shown underlined, foreign keys in bold). You should run your SQL to demonstrate that it works correctly, and paste in the statements used plus the output from Oracle.

LAB (RoomNo, Capacity)

SOFTWARE (SoftwareID, SoftwareName, Version)

REQUEST (SoftwareID, RoomNo, RequestDate, TeachingPeriod, Progress)

Based on the table specifications provided, answer the following questions. Each question is worth 3 marks.

a. Give the SQL to create the LAB and SOFTWARE tables. Choose appropriate data types. None of the attributes should be allowed to be null. Include the primary key constraints.

b. Give the SQL to create the REQUEST table. Use appropriate data types, and include the primary key and foreign key constraints. Referential integrity should be set such that if a lab is deleted from the database, any requests that exist for that lab are also deleted.

c. Give the SQL to add a record to each of the tables: LAB, SOFTWARE and REQUEST. Make up your own data (you may wish to add lab 350.2.006 to the LAB table for testing in part (e) later).

d. Give the SQL to create a constraint to the REQUEST table to restrict the possible values of Progress to the following 5: Requested, Installed, Function Testing, User Acceptance Testing, and Deployed.

e. Give the SQL to record the fact that the capacity of lab 350.2.006 has increased by 5.

Solutions

Expert Solution

a.

create table LAB
-> (RoomNo varchar(20) primary key , Capacity int not null);
Query OK, 0 rows affected (0.35 sec)

mysql> desc LAB;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| RoomNo | varchar(20) | NO | PRI | NULL | |
| Capacity | int(11) | NO | | NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> create table SOFTWARE
-> (SoftwareID int primary key , SoftwareName varchar(20) not null, Version int not null);
Query OK, 0 rows affected (0.30 sec)

mysql> desc SOFTWARE;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| SoftwareID | int(11) | NO | PRI | NULL | |
| SoftwareName | varchar(20) | NO | | NULL | |
| Version | int(11) | NO | | NULL | |
+--------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

b.

mysql> create table REQUEST (
-> SoftwareID int , RoomNo varchar(20),RequestDate date not null,TeachingPeriod int not null, Progress varchar(20) not null, primary key(SoftwareID,RoomNo), foreign key (SoftwareID) references SOFTWARE(SoftwareID) on delete cascade , foreign key (RoomNo) references LAB(RoomNo) on delete cascade);
Query OK, 0 rows affected (0.41 sec)

mysql> desc REQUEST
-> ;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| SoftwareID | int(11) | NO | PRI | NULL | |
| RoomNo | varchar(20) | NO | PRI | NULL | |
| RequestDate | date | NO | | NULL | |
| TeachingPeriod | int(11) | NO | | NULL | |
| Progress | varchar(20) | NO | | NULL | |
+----------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

c.

mysql> insert into LAB
-> values ("350.2.006",100);
Query OK, 1 row affected (0.05 sec)

mysql> insert into SOFTWARE values ("101","VS code",2);
Query OK, 1 row affected (0.05 sec)

mysql> insert into REQUEST values (101,"350.2.006","2019-08-08",3,"Installed");
Query OK, 1 row affected (0.06 sec)

mysql> select * from LAB;
+-----------+----------+
| RoomNo | Capacity |
+-----------+----------+
| 350.2.006 | 100 |
+-----------+----------+
1 row in set (0.00 sec)

mysql> select * from SOFTWARE;
+------------+--------------+---------+
| SoftwareID | SoftwareName | Version |
+------------+--------------+---------+
| 101 | VS code | 2 |
+------------+--------------+---------+
1 row in set (0.00 sec)

mysql> select * from REQUEST;
+------------+-----------+-------------+----------------+-----------+
| SoftwareID | RoomNo | RequestDate | TeachingPeriod | Progress |
+------------+-----------+-------------+----------------+-----------+
| 101 | 350.2.006 | 2019-08-08 | 3 | Installed |
+------------+-----------+-------------+----------------+-----------+
1 row in set (0.00 sec)

d.

mysql> alter table REQUEST
-> add constraint cons CHECK(Progress IN("Requested", "Installed", "Function
on Testing", "User Acceptance Testing","Deployed"));
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc REQUEST;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| SoftwareID | int(11) | NO | PRI | NULL | |
| RoomNo | varchar(20) | NO | PRI | NULL | |
| RequestDate | date | NO | | NULL | |
| TeachingPeriod | int(11) | NO | | NULL | |
| Progress | varchar(20) | NO | | NULL | |
+----------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

e.

mysql> update LAB
-> set Capacity =Capacity+5
-> where RoomNo="350.2.006";
Query OK, 1 row affected (0.18 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from LAB;
+-----------+----------+
| RoomNo | Capacity |
+-----------+----------+
| 350.2.006 | 105 |
+-----------+----------+
1 row in set (0.00 sec)


Related Solutions

University ITS maintains a database about the requests for software that staff members make for their...
University ITS maintains a database about the requests for software that staff members make for their units before each teaching period (e.g. Semester 1, Semester 2). A unit may need several items of software, installed in multiple labs. Labs are housed across the various buildings of the university, with each lab having a unique room number (e.g. Lab 245.3.062 is located in building number 245, name Science & Computing). Each piece of software is requested individually for a lab and...
You are asked to design a relational database for a simple course registration software application for...
You are asked to design a relational database for a simple course registration software application for your school. The relational database must have the following information about the student, the course, and the registration, respectively StudentID, FirstName, LastName, DataOfJoining, and Major CourseNumber, CourseName,InstructorName, StartDate, EndDate, NumberOfCredits ReferenceID, StudentID,CourseID, DateOfRegistration Apply the following constrains while designing the database Each student in the database must be uniquely identifiable Each course listed in the database must be have unique CourseNumber Each course registration...
Metal Holdings Inc. You have been assigned the task of creating a simple relational database using...
Metal Holdings Inc. You have been assigned the task of creating a simple relational database using SQLite database by the owner of “Metal Holdings” who is in the business of selling industrial metals to customers (mostly wholesale suppliers) who buy from the company. Your goal is to design and build a database that would be responsible for: Managing a product table containing all metals which at a minimum should provide information such as name, description and price of each metal...
You have been given the following information about a motel for the coming year:                             &
You have been given the following information about a motel for the coming year:                                                   (A)            Occupancy Forecast         75% (B)            Rooms department variable cost per occupied room is estimated to be     $7.75                                        (C)            Owners' investment          $800,000 (D)            Desired after tax yield on owners' investment        15% (E)             Current income tax rate                  30% (F)             The motels fixed costs for the coming year were anticipated to be                 825,000                                   (G)            The motel has this many rooms available to rent     100...
You have been hired as a research assistant and are given the following data about another...
You have been hired as a research assistant and are given the following data about another economy Corporate income tax $20000 Profits $44000 Rent $25000 Indirect business taxes $21000 Business profits $75000 Plant and equipment   $2,400 Net foreign factor imports $-5,900 Interest $22,185 Social security contribution $65,000 Transfer payments $80,000 Wages $900    Personal taxes $175 Calculate the GDP using the factor payment approach. Show work. ___________________  
You have been given the following information about the production of Usher Co. and are asked...
You have been given the following information about the production of Usher Co. and are asked to provide the plant manager with information for a meeting with the vice president of operations. Standard Cost Card Direct materials (5 pounds at $4 per pound) $20.00 Direct Labor (0.8 hours at $10) 8.00 Variable Overhead (0.8 hours at $3 per hour) 2.40 Fixed Overhead (0.8 hours at $7 per hour) 5.60 $36.00 The following is a variance report for the most recent...
Split the main function given into multiple functions. You have been given a very simple program...
Split the main function given into multiple functions. You have been given a very simple program that performs basic operations (addition, subtraction, editing) on two randomly generated integer vectors. All functionality has been included in main, causing code segments to be repeated as well as diminishing the readability. Rewrite the program by grouping calculations and related operations into functions. In particular, your program should include the following functions. InitializeVectors: This is a void function that initializes the two vectors by...
You have been given the following per unit information about the production of Gillian Inc., and...
You have been given the following per unit information about the production of Gillian Inc., and are asked to provide the plant manager with information for a meeting with the vice-president of operations: Standard Quantity Standard Price Actual Quantity Actual Price Direct materials 5 kg $3 / kg 5.5 kg $2.80 / kg Direct labour 1.5 hours $18 / hour 1.0 hours $16 / hour Production data, both budgeted and actual, for the year are as follows: Description Amount Actual...
Design a simple database to track people and who they voted for. The database should have...
Design a simple database to track people and who they voted for. The database should have 3 tables: A table of candidates A table of registered voters A table of votes The candidate table should provide a listing of all candidates and information about the candidates. The registered voter table should hold all registered voters and any pertinent information about them The vote table should hold vote records for each candidate made by the voters Requirements: The system should not...
Draw an ERD with the following information: You are a database consultant with Ace Software, Inc.,...
Draw an ERD with the following information: You are a database consultant with Ace Software, Inc., and have been assigned to develop a database for the Johnson Video Store in town. The owners have been keeping their records of videos and DVDs purchased from distributors and rented to customers in stacks of invoices and piles of rental forms for years. They have finally decided to automate their record keeping with a relational database. You sit down with the owners to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT