I need to add constraints but I am unsure how. I also need FK in this script. Does that make sense.
CREATE TABLE Orders(OrderNumber INT (100) Primary Key,ProductId VARCHAR (25) NOT NULL,Quanity INT(100) NOT NULL,ShipDate DATE );
INSERT INTO Orders VALUES(2067980, '5678', '1' ,
'05-02-2019');
INSERT INTO Orders VALUES(2070369,'6867','2','09-06-2019');
INSERT INTO Orders VALUES(2039542, '4652', '10',
'11-30-2019');
CREATE TABLE Employee(EmployeeID INT(15) Primary
KEY,EmployeeFirstName VARCHAR (25) NOT NULL,EMployeeLastName
VARCHAR (25) NOT NULL,
EmployeeAddress VARCHAR (45) NOT NULL,EmployeeCity VARCHAR (25) NOT
NULL,EmployeeState VARCHAR (25) NOT NULL,Zipcode VARCHAR (25) NOT
NULL);
INSERT INTO `Employee` VALUES(2468, 'Jason', 'Harmon', '10 Western Court', 'Howell', 'NJ', '07731');
INSERT INTO `Employee` VALUES(2469, 'Gary', 'Hodgens', '1 Lewis Street', Secaucus', 'NJ', '07094');
INSERT INTO `Employee` VALUES(2461, 'Mayla', 'Slate', '18 Sand Road', 'Milltown', 'NJ', '08850');
CREATE TABLE Customer( CustomerID int (35) PRIMARY
KEY,CustomerFirstName varchar (25),CustomerLastName varchar (25)
NOT NULL,
CustomerAddress varchar (45) NOT NULL,CustomerState varchar
(25),CustomerZip int (20) NOT NULL) ;
INSERT INTO Customer VALUES(01234, 'John', 'Smith', '3
Evergreen Drive', 'NJ', '9950');
INSERT INTO Customer VALUES(01235, 'Dave', 'Tee', '6 Devry Road',
'IL', '9961');
INSERT INTO Customer VALUES(01236, 'Jane', 'White', '9 Conover
Avenue', 'VA', '9982');
CREATE TABLE Product(ProductNumber INT (10) PRIMARY
KEY,ProductName VARCHAR(50) NOT NULL,ProductModel VARCHAR
(25),ProductPrice Decimal (10),
Manufatcurer VARCHAR (25));
INSERT INTO Product VALUES(5678, 'TV', '60inch', '350',
'LG');
INSERT INTO Product VALUES(4652, 'Laptop', '17inch', '400',
'Toshiba');
INSERT INTO Product VALUES(6867, 'Radio', 'CDPlayer', '150',
'Bose');
CREATE TABLE InventoryReport(ItemNumber VARCHAR (25)
PRIMARY KEY,ItemSold int(25) NOT NULL,ItemsOnHand int (500) NOT
NULL,
BackOrdered varchar(500)) ;
INSERT INTO InventoryReport VALUES(5678, '1', '100',
'200');
INSERT INTO InventoryReport VALUES(6867, '2', '50', '150');
INSERT INTO InventoryReport VALUES(4652, '10', '300',
'400');
CREATE TABLE DistributionChannel( TrackingNumber VARCHAR (35) Primary Key,CarrierName VARCHAR (45) NOT NULL,CarrierType VARCHAR (45)) ;
INSERT INTO DistributionChannel VALUES(6694, 'Fedex',
'Truck');
INSERT INTO DistributionChannel VALUES(6695, 'UPS', 'Van');
INSERT INTO DistributionChannel VALUES(6696, 'USPS',
'Car');
CREATE TABLE Payment( CustomerAcountNumber INT(50) NOT NULL,PaymentType VARCHAR (25),Total Decimal (20));
INSERT INTO Payment VALUES(9950, 'Visa','100.00');
INSERT INTO Payment VALUES(9961, 'Echeck','25.00');
INSERT INTO Payment VALUES(9982, 'Mastercard',
'32.00');
TO ADD CONSTRAINT PLEASE FOLLOW THE BELOW SYNTAX:
The ADD CONSTRAINT command is used to create a constraint after a table is already created.
The following SQL adds a constraint named "PK_Person" that is a PRIMARY KEY constraint on multiple columns (ID and LastName):
Example:
ALTER TABLE Persons
ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName);
In this table I think its better for you to add a FK.
I need to add constraints but I am unsure how. I also need FK in this...
Hi I have the following Code and it Keeps giving me This Error in EDUPE: ERROR 1064 (42000) at line 1. Here is the Code I need to create a database with: DROP TABLE IF EXISTS Order; DROP TABLE IF EXISTS Customer; DROP TABLE IF EXISTS Employee; DROP TABLE IF EXISTS Payment; DROP TABLE IF EXISTS Product; DROP TABLE IF EXISTS InventoryReport; DROP TABLE IF EXISTS DistributionChannel; -- Table structure for table `Order` CREATE TABLE Order (Order_Number INT(100) PRIMARY KEY,...
NEED HELP IN INSERT STATEMENTS FOR THE TABLES CAN YOU PLEASE ADD SOME INSERT STATEMENTS FOR A COMPANY SCHEMA SCRIPT. PLEASE ADN THANK YOU DROP TABLE dependent; DROP TABLE works_on; DROP TABLE project; DROP TABLE dept_locations; DROP TABLE department; DROP TABLE employee; CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary numeric(10,2), superssn char(9), dno numeric, primary key (ssn), foreign key (superssn) references employee(ssn) ); CREATE...
MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects 2.List the project with the most hours SCRIPT TO BUILD DATABASE create table department ( dept_ID int not null , dept_name char(50) NOT NULL, manager_ID int not null, manager_start_date date not null, constraint Dept_PK primary key (dept_ID), constraint D_Name_AK unique (dept_name) ); insert into department values(1,'abc',1,'2019-01-08'); insert into department values(2,'abc2',2,'2019-01-08'); insert into department values(3,'abc3',2,'2019-01-08'); insert into department values(4,'abc4',2,'2019-01-08'); /*project table done*/ create table project...
Database Management
6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL, address VARCHAR(60), UNIQUE (cust name, address)); A. Run the following inserts and explain why both work and how will you prevent it INSERT INTO customer VALUES ('Alex Doe', NULL); INSERT INTO customer VALUES ('Alex Doe', NULL); 7. [5] Modify the following table definition to ensure that all employees have a minimum wage of $10 CREATE TABLE employee ( empId INT PRIMARY KEY, empName VARCHAR(40)...
SQL
I have a database
CREATE TABLE vendor
( vid CHAR(2) NOT NULL,
vname VARCHAR(25) NOT NULL,
PRIMARY KEY (vid) );
CREATE TABLE category
( catid CHAR(2) NOT NULL,
catname VARCHAR(25) NOT NULL,
PRIMARY KEY (catid) );
CREATE TABLE product
( pid CHAR(3) NOT NULL,
pname VARCHAR(25) NOT NULL,
price NUMERIC (7,2) NOT NULL,
vid CHAR(2) NOT NULL,
categoryid CHAR(2) NOT NULL,
PRIMARY KEY (pid));
CREATE TABLE region
( rid CHAR NOT NULL,
rname VARCHAR(25) NOT NULL,
PRIMARY KEY (rid)...
I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...
Someone Please Help Me modify this in PHP I'm in desperate need I cant figure this out ... Make the following modifications: For the vendors table: Comment out the table-level primary key Change the VendorIDcolumn to be a column-level primary key Add a VendorEmail column to the bottom of the table definition (define the data type for the column as variable character and set it to not exceed 45 characters) After the lineItems table, add code to create a table...
/* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...
I NEED TO WRITE THE FOLLOWING QUERIES IN MYSQL (13)Next, grant to a user admin the read privileges on the complete descriptions of the customers who submitted no orders. For example, these are the customers who registered themselves and submitted no orders so far. The granted privilege cannot be propagated to the other users. 0.3 (14)Next, grant to a user admin the read privileges on information about the total number of orders submitted by each customer. Note, that some customers...
Using Oracle database Need help getting the JAVA code for the queries and the rest of the instructions. Need the table provided converted and fulfil the requirements. . For this project - you will be writing a program (you may choose whatever programming language you want) to read in your database tables from Lab 5, and then print out the contents of each of the tables. Additionally, you must print at least one query each with the following clauses: *JOIN (any...