Question

In: Computer Science

--Creating Package Table DROP TABLE Package_Dimensions; DROP TABLE Package_Statuses; DROP TABLE PACKAGES; DROP TABLE Status_Codes; DROP...

--Creating Package Table

DROP TABLE Package_Dimensions;

DROP TABLE Package_Statuses;

DROP TABLE PACKAGES;

DROP TABLE Status_Codes;

DROP TABLE Exception_Codes;

DROP TABLE Allowable_Limits;

DROP TABLE Limit_Codes;

CREATE TABLE Packages (Package_Id int PRIMARY KEY,Package_Number int);

--Creating Package Dimensions Table:

CREATE TABLE Package_Dimensions (Dimension_Id int Primary Key, Package_Id dec (5,2),Height dec (5,2),Width dec (5,2),Weight dec (5,2),Length dec (5,2));

--Creating Package Statuses Table

CREATE TABLE Package_Statuses (Package_Status_Id int Primary Key, Status_Id int, Package_Id int, Status_Code int, Status_Date date, Exception_Code int);

--Creating Status Codes and Exception Codes Table:

CREATE TABLE Status_Codes ( Status_Code int Primary Key,Description varchar(100));

CREATE TABLE Exception_Codes (Exception_Code int Primary Key,Description varchar(100));

--Creating Allowable Limts and Limt Codes Table:

CREATE TABLE Allowable_Limits (Limit_Id int Primary Key, Limit_Code int, Date_Active date, Date_Inactive date, Limit_Value int);

CREATE TABLE Limit_Codes (Limit_Code int Primary Key,Description varchar(100));

--Adding Foreign Keys to Tables By Referring Main Tables:

ALTER TABLE Package_Dimensions ADD FOREIGN KEY (Package_Id) REFERENCES Packages (Package_Id);

ALTER TABLE Package_Statuses ADD FOREIGN KEY (Package_Id) REFERENCES Packages (Package_Id);

ALTER TABLE Package_Statuses ADD FOREIGN KEY (Status_Code) REFERENCES Status_Codes (Status_Code);

ALTER TABLE Package_Statuses ADD FOREIGN KEY (Exception_Code) REFERENCES Exception_Codes (Exception_Code);

ALTER TABLE Allowable_Limits ADD FOREIGN KEY(Limit_Code) REFERENCES Limit_Codes (Limit_Code);

--Inserting Values Into Tables :

INSERT INTO Status_Codes VALUES (4,'The package Status is Active');

INSERT INTO Exception_Codes VALUES (6,'The package Has Some Errors');

INSERT INTO Limit_Codes VALUES (8,'This Limit Code has some Features');

INSERT INTO Allowable_Limits VALUES (1,8,to_date('2019/09/04','YYYY/MM/DD'),to_Date('2019/09/08','YYYY/MM/DD'),10);

INSERT INTO Packages values (100,1010);

INSERT INTO Packages values (101,1001);

INSERT INTO Package_Dimensions VALUES (6,100,10,20,800,40);

INSERT INTO Package_Statuses VALUES (4,101,100,4,to_Date('2019/09/04','YYYY/MM/DD'),6);

--Displaying Data In the Tables:

SELECT * FROM Packages;

SELECT * FROM Allowable_Limits;

  1. Insert at least five rows in each table
  2. Alter at least one table to include a constraint on a column (e.g. BETWEEN 1 and 12, IN ('GA', 'SC', "TN'))
  3. Run at least two queries to demonstrate that the constraint was defined properly.
  4. Run updates on at least two tables
  5. Use at least two queries to demonstrate that referential integrity is set up correctly for your tables.

Written in Oracle SQL

Solutions

Expert Solution

Inserting

--Insert at least five rows in each table

INSERT INTO Status_Codes VALUES (1,'The package Status is Passive');
INSERT INTO Status_Codes VALUES (2,'The package Status is Hold Back');
INSERT INTO Status_Codes VALUES (3,'The package Status is Not Done');
INSERT INTO Status_Codes VALUES (5,'The package Status is Done');
INSERT INTO Status_Codes VALUES (6,'The package Status is Delay');

INSERT INTO Exception_Codes VALUES (1,'The package Has Seat Errors');
INSERT INTO Exception_Codes VALUES (2,'The package Has Condition Errors');
INSERT INTO Exception_Codes VALUES (3,'The package Has Connection Errors');
INSERT INTO Exception_Codes VALUES (4,'The package Has abc Errors');
INSERT INTO Exception_Codes VALUES (5,'The package Has def Errors');

INSERT INTO Limit_Codes VALUES (1,'This Limit Code has abc Features');
INSERT INTO Limit_Codes VALUES (2,'This Limit Code has def Features');
INSERT INTO Limit_Codes VALUES (3,'This Limit Code has ghi Features');
INSERT INTO Limit_Codes VALUES (4,'This Limit Code has jkl Features');
INSERT INTO Limit_Codes VALUES (5,'This Limit Code has mno Features');

INSERT INTO Allowable_Limits VALUES (2,1,to_date('2019/09/04','YYYY/MM/DD'),to_Date('2019/09/08','YYYY/MM/DD'),10);
INSERT INTO Allowable_Limits VALUES (3,2,to_date('2019/07/03','YYYY/MM/DD'),to_Date('2019/07/12','YYYY/MM/DD'),8);
INSERT INTO Allowable_Limits VALUES (4,3,to_date('2019/01/02','YYYY/MM/DD'),to_Date('2019/01/09','YYYY/MM/DD'),7);
INSERT INTO Allowable_Limits VALUES (5,4,to_date('2019/09/08','YYYY/MM/DD'),to_Date('2019/09/09','YYYY/MM/DD'),4);
INSERT INTO Allowable_Limits VALUES (6,5,to_date('2019/09/09','YYYY/MM/DD'),to_Date('2019/09/11','YYYY/MM/DD'),3);


INSERT INTO Packages values (103,1011);
INSERT INTO Packages values (104,1010);
INSERT INTO Packages values (105,1010);
INSERT INTO Packages values (106,1010);
INSERT INTO Packages values (107,1012);

INSERT INTO Package_Dimensions VALUES (6,103,10,20,800,40);
INSERT INTO Package_Dimensions VALUES (4,104,10,20,800,40);
INSERT INTO Package_Dimensions VALUES (2,105,10,20,800,40);
INSERT INTO Package_Dimensions VALUES (1,106,10,20,800,40);
INSERT INTO Package_Dimensions VALUES (3,107,10,20,800,40);

INSERT INTO Package_Statuses VALUES (1,101,100,4,to_Date('2019/09/04','YYYY/MM/DD'),3);
INSERT INTO Package_Statuses VALUES (4,104,100,3,to_Date('2019/01/04','YYYY/MM/DD'),6);
INSERT INTO Package_Statuses VALUES (6,107,100,6,to_Date('2019/09/04','YYYY/MM/DD'),2);

Query:

alter table Status_Codes modify(Status_Code int check(Status_Code >= 1 and Status_Code<12));

Query:

/*Here i am insert wrong entery for validating that constant are properly working */
INSERT INTO Status_Codes VALUES (14,'The package Status is Passive');/*in this status code is wrong in Check constant*/
INSERT INTO Exception_Codes VALUES (5,'The package Has def Errors');/*this is already inserted */

/* Here update Packages Number where package id is 107*/
Select * from Packages;
Update Packages set Package_Number=1019 where Package_Id=107;
Select * from Packages;

Query:
INSERT INTO Package_Statuses VALUES (11,101,100,10,to_Date('2019/09/04','YYYY/MM/DD'),6);/*In this Status_Code is wrong in foreign key */
INSERT INTO Allowable_Limits VALUES (6,8,to_date('2019/09/09','YYYY/MM/DD'),to_Date('2019/09/11','YYYY/MM/DD'),3);/*in this Limit_Codes is not inserted in Limit_Codes table so referenceial work properly */

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

Amazon has three packages (Package A, Package B, and Package C) that is to be shipped...
Amazon has three packages (Package A, Package B, and Package C) that is to be shipped to Bill’s address. Package A is worth $100, Package B is worth $200, and Package C is worth $300. All three packages have a 90% chance of arriving and a 10% chance of being lost in transit. a. Set up a probability distribution with the appropriate probabilities for each possible outcome. b. What is the expected loss (P*)? c. How much risk does Amazon...
Software Sales A software company sells three packages, Package A, Package B, and Package C, which...
Software Sales A software company sells three packages, Package A, Package B, and Package C, which retail for $99, $199, and $299, respectively. Quantity discounts are given according to the following table: Quantity Discount 10 through 19 20% ,20 through 49 30% ,50 through 99 40% ,100 or more 50% . Create a C++ program that allows the user to enter the number of units sold for each software package. The application should calculate and display the order amounts and...
Yellow Rose Package $29.95 White Rose Package $39.95 Golden Rose Package $49.95 The Golden Rose Packages...
Yellow Rose Package $29.95 White Rose Package $39.95 Golden Rose Package $49.95 The Golden Rose Packages Yellow Rose Package White Rose Package Golden Rose Package Item Cost ($) Item Cost ($) Item Cost ($) Appetizer Minestrone 1.25 Onion Soup 1.70 Crab Cake 2.25 Entrée Roast Chicken 2.25 Braised Beef Ribs 4.25 Filet Mignon 6.50 Side Yellow Rice 0.25 Roasted Redskins 0.65 Duchesse Potatoes 0.75 Side Steamed Broccoli 0.50 Bacon Green Beans 0.75 Béarnaise Asparagus 0.95 Bread Dinner Rolls 1.00 Basil...
DROP DATABASE class;CREATE DATABASE class;Use class;drop table if exists Class;drop table if exists Student;CREATE TABLE Class...
DROP DATABASE class;CREATE DATABASE class;Use class;drop table if exists Class;drop table if exists Student;CREATE TABLE Class (CIN int PRIMARY KEY, FirstName varchar(255), LastName varchar(255), Gender varchar(1), EyeColor varchar(50), HairColor varchar(50), HeightInches int,CurrentGrade varchar(1));CREATE TABLE Student (SSN int PRIMARY KEY,FirstName varchar(255),LastName varchar(255), Age int,BirthMonth varchar(255),HeightInches int,Address varchar(255),City varchar(255),PhoneNumber varchar(12),Email varchar(255),FavColor varchar(255),FavNumber int);INSERT INTO Class VALUES(1, "David", "San", "M", "BRN", "BLK", 72, "-");INSERT INTO Class VALUES(2, "Jeff", "Gonzales", "M", "BRN", "BLK", 68, "B");INSERT INTO Class VALUES(3, "Anna", "Grayson", "F", "BRN", "BRN", 62,...
A company sells packages of cookies with the following promotion. If two cookies in a package...
A company sells packages of cookies with the following promotion. If two cookies in a package are frostingless, you may get your money back. Suppose each cookie has a 1 100 chance of being frostingless and there are 20 cookies in a package. (a) What is the expected number of frostingless cookies in a package? 5 packages? (b) What is the variance in this number for one package? 5 packages? (c) What is the probability of returning at least one...
A cable company offers two basic packages: sports and kids, and a combined package. There are...
A cable company offers two basic packages: sports and kids, and a combined package. There are three different types of users: parents, sports fans, and generalists. Assume that the cable company cannot discriminate among the three groups and must charge all customers the same price. The following table shows the maximum price that each type of consumer is willing to pay for each package. Sports Package Kids Package Parents 10 50 Sports fans 50 10 Generalists 40 40 Sports Package...
Amazon regularly couriers rectangular packages overseas. The girth of a rectangular package is defined to be...
Amazon regularly couriers rectangular packages overseas. The girth of a rectangular package is defined to be the perimeter of a cross section perpendicular to the length.You prefer to use Speedy Couriers for your international deliveries, but they will only carry rectangular packages where the sum of length and girth is at most 150 cm. Find the dimensions of the package with the largest volume that they will carry. Assume that the critical point gives a maximum
A corporation produces packages of paper clips. The number of clips per package varies, as indicated...
A corporation produces packages of paper clips. The number of clips per package varies, as indicated below for a sample of 20 packages. 48 47 51 53 49 50 51 48 52 50 53 48 50 49 51 52 49 50 51 52 Create a probability density function. What is the probability that a randomly chosen package contains between 48 and 53 clips (inclusive) per package? Please specify your answer in decimal terms and round your answer to the nearest...
A package delivery service advertises that at least 90% of all packages brought in by 9:00...
A package delivery service advertises that at least 90% of all packages brought in by 9:00 a.m. for delivery in the same city will be delivered by noon. A random sample of 80 packages had 65 that were delivered by noon. a) Construct a 90% confidence interval for the proportion of packages delivered by noon. b) Construct a 99% lower confidence interval for the true proportion. c) What size sample is necessary to construct a 95% confidence interval with a...
You drop a package from a plane flying at constant speed in a straight line. Without...
You drop a package from a plane flying at constant speed in a straight line. Without air resistance, the package will. (Hint: think about the velocity along the x direction, think about what type of motion you have along x direction). A) quickly lag behind the plane while falling. B) remain vertically under the plane while falling. C) move ahead of the plane while falling. D) not fall at all.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT