Refer to the given schema.Write a query to create the courier and courier status tables with the constraints mentioned. Assume that the customer and branch tables are already created.
Question
Refer to the given schema.Write a query to create the courier and courier status tables with the constraints mentioned. Assume that the customer and branch tables are already created.
Solution
Sure, here is the SQL query to create the courier and courier status tables with the constraints mentioned.
CREATE TABLE Courier (
CourierID INT PRIMARY KEY,
CourierName VARCHAR(255) NOT NULL,
BranchID INT,
FOREIGN KEY (BranchID) REFERENCES Branch(BranchID)
);
CREATE TABLE CourierStatus (
StatusID INT PRIMARY KEY,
CourierID INT,
CustomerID INT,
Status VARCHAR(255) NOT NULL,
FOREIGN KEY (CourierID) REFERENCES Courier(CourierID),
FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID)
);
In the above SQL query:
-
The
Couriertable has a primary keyCourierID, aCourierNamewhich cannot be null, and a foreign keyBranchIDwhich referencesBranchIDfrom theBranchtable. -
The
CourierStatustable has a primary keyStatusID, aStatuswhich cannot be null, and two foreign keysCourierIDandCustomerIDwhich referenceCourierIDfrom theCouriertable andCustomerIDfrom theCustomertable respectively.
Similar Questions
Refer to the given schema. Write a query to create customer and branch tables with the constraints mentioned.
Given the following table definition for the shipment table, sp:CREATE TABLE sp (spno VARCHAR(4) NOT NULL, sno VARCHAR(3) NOT NULL, pno VARCHAR(3) NOT NULL, qty SMALLINT NOT NULL CHECK (qty>=0), PRIMARY KEY (spno), FOREIGN KEY (sno) REFERENCES s ON DELETE RESTRICT ON UPDATE CASCADE, FOREIGN KEY (pno) REFERENCES p ON DELETE RESTRICT ON UPDATE CASCADE );And the following data on the supplier, s, part, p, and shipment, sp, tables: supplier (s)part (p)shipment (sp)The following update will be allowed on the supplier table, s: update sSET sno = 'S20'WHERE sno='S1';
Charles is developing a travel booking system to manage customers, bookings, and payments. The system needs to handle three main types of data: CUSTOMERS, BOOKINGS, and PAYMENTS. To perform this the user needs to create the following tables with the mentioned constraints:
can you give me the requirement identification for logistics delivery system?
For situation A (above) what is the transshipment constraint for the warehouse in Charleston (𝑥7)?Group of answer choices𝑥14+𝑥15+𝑥16−𝑥78−𝑥79−𝑥710
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.