You are on page 1of 2

Eric Sharer Oracle DDL Project REM ****** Create MedicalWholesaler Table ****** Create Table MedicalWholesaler (Wholesaler_ID

smallint Primary Key Not Null, Wholesaler_Name varchar(20) not null, state varchar(2), zip_code varchar(5), city varchar(25), Phone# varchar(10) not null); REM ****** Create MedicineOrders Table ****** Create Table MedicineOrders (Order_ID smallint primary key, Wholesaler_ID smallint not null, Order_Price Number(10,2), Order_Cost Number(10,2), Order_Date Date, Foreign Key (Wholesaler_ID) References MedicalWholesaler(Wholesaler_ID)) ; REM ****** Create MedicineManuf Table ****** Create Table MedicineManuf (Medicine_ID smallint Primary Key Not Null, Medicine_Price Number(10,2), Medicine_Cost Number(10,2) , Medicine_Type char(1) Not Null Check(Medicine_Type in ('L', 'S', 'G')), Unique(Medicine_ID, Medicine_Type), Wholesaler_ID smallint, Foreign Key(Wholesaler_ID) References MedicalWholesaler(Wholesaler_ID)); REM ****** Create Shipping Table ****** Create Table Shipping (Ship_Date Date, Truck_ID varchar(8), Shipping_ID smallint not Medicine_ID Smallint Not Primary Key(shipping_ID, Foreign Key(Medicine_ID)

null, Null, Medicine_ID), References MedicineManuf(Medicine_ID));

REM ****** Create LiquidMedicine Table ****** Create Table LiquidMedicine (Medicine_ID smallint Primary Key Not Null, Medicine_Type Char(1) DEFAULT 'L' NOT Null Check(Medicine_Type = 'L'), Unique(Medicine_ID, Medicine_Type), Volume number(10,2), color varchar(20), Foreign Key(Medicine_ID, Medicine_Type) References MedicineManuf(Medicin e_ID, Medicine_Type)); Alter Table LiquidMedicine Rename Column Medicine_ID to LMedicine_ID; REM ****** Create SolidMedicine Table ****** Create Table SolidMedicine

(Medicine_ID smallint Primary Key Not Null, Medicine_Type Char(1) DEFAULT 'S' NOT Null Check(Medicine_Type = 'S'), Unique(Medicine_ID, Medicine_Type), Weight Number(10,2), Height Number(10,2), Width Number(10,2), Foreign Key(Medicine_ID, Medicine_Type) References MedicineManuf(Medicin e_ID, Medicine_Type)); Alter Table SolidMedicine Rename Column Medicine_ID to SMedicine_ID; REM ****** Create GasMedicine Table ****** Create Table GasMedicine (Medicine_ID smallint Primary Key Not Null, Medicine_Type Char(1) DEFAULT 'G' NOT Null Check(Medicine_Type = 'G'), Unique(Medicine_ID, Medicine_Type), Burn_Rate Number(10,2), Density number(10,2), Molarity number (10,2), Foreign Key(Medicine_ID, Medicine_Type) References MedicineManuf(Medicin e_ID, Medicine_Type)); Alter Table GasMedicine Rename Column Medicine_ID to GMedicine_ID; REM ****** Create MedicineOrderLine Table ****** Create Table MedicineOrderLine (Order_ID smallint, Medicine_ID smallint, Shipping_ID smallint, Medicine_Description varchar(30), Primary Key(Order_ID, Medicine_ID, Shipping_ID), Foreign Key(Order_ID) References MedicineOrders(Order_ID), Foreign Key(Medicine_ID, Shipping_ID) References Shipping(Medicine_ID, S hipping_ID));

You might also like