hw14

sql

School

Tulsa Community College *

*We aren’t endorsed by this school

Course

2133

Subject

Information Systems

Date

Oct 30, 2023

Type

sql

Pages

3

Uploaded by CorporalChimpanzee344

Report
use F22_thazelr go CREATE PROCEDURE [dbo].[Create_eCommerce_Tables] AS IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='customer') CREATE TABLE Customer ( CustID INT NOT NULL, fname VARCHAR(20) NOT NULL, lname VARCHAR(20) NOT NULL, phone NUMERIC(15) NOT NULL, email VARCHAR(20) NOT NULL, DOB DATE NOT NULL, Gender CHAR(10) NOT NULL, PRIMARY KEY (CustID) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='orderitems') CREATE TABLE orderitems ( Oid INT NOT NULL, prodid INT NOT NULL, qty INT NOT NULL, price NUMERIC(15) NOT NULL, PRIMARY KEY (Oid, prodid) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='upsale') CREATE TABLE upsale ( prodid INT NOT NULL, percentage NUMERIC(5) NOT NULL, custid INT NOT NULL, PRIMARY KEY (prodid, custid) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='shiippingAddress') CREATE TABLE shiippingAddress ( sid INT NOT NULL, address1 VARCHAR(30) NOT NULL, address2 VARCHAR(30) NOT NULL, city VARCHAR(20) NOT NULL, state VARCHAR(20) NOT NULL, primary_YN CHAR(2) NOT NULL, CustID INT NOT NULL, PRIMARY KEY (sid), FOREIGN KEY (CustID) REFERENCES Customer(CustID) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='shippmentMethos') CREATE TABLE shippmentMethos ( shipid INT NOT NULL, company VARCHAR(20) NOT NULL, method VARCHAR(20) NOT NULL, frate NUMERIC(10) NOT NULL, vrate NUMERIC(10) NOT NULL, baseWeight NUMERIC(10) NOT NULL, PRIMARY KEY (shipid) );
IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='crossSell') CREATE TABLE crossSell ( prodid1 INT NOT NULL, prodid2 INT NOT NULL, percentage NUMERIC(10) NOT NULL, PRIMARY KEY (prodid1, prodid2) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='department') CREATE TABLE department ( deptid INT NOT NULL, name VARCHAR(20) NOT NULL, description VARCHAR(35) NOT NULL, PRIMARY KEY (deptid) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='paymentinfo') CREATE TABLE paymentinfo ( custid INT NOT NULL, pname VARCHAR(20) NOT NULL, cctype VARCHAR(20) NOT NULL, ccnumber INT NOT NULL, ccexpire DATE NOT NULL, billAddress VARCHAR(30) NOT NULL, city VARCHAR(20) NOT NULL, state CHAR(20) NOT NULL, zip VARCHAR(20) NOT NULL, PRIMARY KEY (custid, pname) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='Orders') CREATE TABLE Orders ( Oid INT NOT NULL, Orderdt DATE NOT NULL, ShipId INT NOT NULL, ShipCost NUMERIC(15) NOT NULL, CustID INT NOT NULL, shipid INT NOT NULL, FOREIGN KEY (CustID) REFERENCES Customer(CustID), FOREIGN KEY (shipid) REFERENCES shippmentMethos(shipid) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='category') CREATE TABLE category ( cid INT NOT NULL, name VARCHAR(20) NOT NULL, description VARCHAR(35) NOT NULL, deptid INT NOT NULL, PRIMARY KEY (cid), FOREIGN KEY (deptid) REFERENCES department(deptid) ); IF NOT EXISTS (SELECT * FROM sys.Tables WHERE name='product') CREATE TABLE product ( prodid INT NOT NULL, productname VARCHAR(20) NOT NULL, description VARCHAR(35) NOT NULL, rPrice NUMERIC(10) NOT NULL,
sPrice NUMERIC(10) NOT NULL, keywords VARCHAR(30) NOT NULL, cid INT NOT NULL, PRIMARY KEY (prodid), FOREIGN KEY (cid) REFERENCES category(cid) );
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Suppose that a disk drive has 100 cylinders, numbered from 0 to 99. The queue which is maintained is…
Q: solve the triangle 1) a=20 b=16 c=? A=? B=60 C=? 2) a=20 b=18 c=? A=? B=60 C=? 3) a=20 b=22 c=?…
Q: Let f(x) = (x – 3)2 Give the largest domain on which f is one-to-one and non-decreasing. Preview…
Q: What is the difference between commuting patterns for students and professors. 11 students and 14…
Q: 50. Find g(0) 51. Find g(-8) 52. Find g(5) 53. Find x when g(x) = 2 54. Find x when g(x) = -3 55.…
Q: A piston and cylinder machine contains 1 kg of air, initially the specific volume = 0.8m3/kg and T =…
Q: If a card is drawn at random from a pack of 52 cards,what is the chance of getting a spade or ace?
Q: The starter code does contain formatting mistakes .The output must match the sample output…
Q: Question 1: Write a program that includes a method that checks a number given to it as a parameter…
Q: Consider the following function and graph. f(x) = 4 %3D x² - 16 6 -10 -8 -6 4 -2 6. 10 Determine…
Q: Let f(x) 1 == +x. X 1. Find critical numbers of the function. Type your answer here to separate…
Q: Write the necessary code to initialize a numpy array (5,3,3) as follows: [[[6 2 6] [6 2 6] [6 2 6]]…
Q: Kepler's 3rd law is given as p2 = a3. If the orbital period of a space telescope at the second…
Q: Which of the following Enlightenment thinker was known for their phi- losophy of liberalism? A…
Q: Write a basic function that takes an input mass (any units) and returns that mass in solar masses
Q: Compute the angular velocity after a time of 0.197 s. Through how many revolutions has the blade…
Q: The center of gravity of a 5.00 kg irregular object is shown in (Figure 1). You need to move the…
Q: A researcher wants to know if the news station a person watches is a factor in the amount of time…
Q: Two 2.0-g aluminum foil balls hang from 1.0-m-long threads that are suspended from the same point at…
Q: #include   #include using namespace std;   class Fraction { public:   int numerator; int…
Q: Consider the malate dehydrogenase reaction, part of tricarboxylic acid cycle, shown below. malate +…
Q: Determine the probability of having 2 girls and 3 boys in a 5-child family. State any assumptions…