• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
199
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
9
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 0 Database Development2 Oracle 12c,DB2, MySQL & SQL Anywhere By Sunny U Okoro
  • 2. 1 Contents Database Systems.........................................................................................................................................7 Applications...................................................................................................................................................9 ERD..............................................................................................................................................................14 Oracle 12C R1..............................................................................................................................................17 TableSpace and User Accounts...............................................................................................................19 Tables......................................................................................................................................................22 Index........................................................................................................................................................36 Triggers....................................................................................................................................................38 Database Altration..................................................................................................................................79 DBA Database Dictionary......................................................................................................................105 Database Physical Model..................................................................................................................106 Database Directory ...........................................................................................................................107 Database Population.............................................................................................................................152 Modifying the Table Column.................................................................................................................166 Database Verifcation- Regular Tables...................................................................................................178 Database Verifcation- Audit Tables ......................................................................................................184 Data Population and Mainpulation.......................................................................................................192 User Account Creations and Privileges ................................................................................................211 DBA Works ............................................................................................................................................286 MYSQL 5.6.................................................................................................................................................294 Database Creation.................................................................................................................................295 Tables....................................................................................................................................................297 Indexes..................................................................................................................................................309 Triggers..................................................................................................................................................311 Database Altration................................................................................................................................316 Data Population ....................................................................................................................................320 Database Dictionary..............................................................................................................................328 Database Physical Diagram..............................................................................................................329 Database Dictinoary..........................................................................................................................330 Data Verification Regular Tables...........................................................................................................477 Data Verification Audit Tables ..............................................................................................................481
  • 3. 2 Data Mainpulation................................................................................................................................491 Revised Database Dictinoary ................................................................................................................563 Revised Database Diagram ...................................................................................................................565 DB2 10.......................................................................................................................................................567 Database Creation.................................................................................................................................569 Database Schema and Objecs Creations...............................................................................................579 Triggers..................................................................................................................................................594 Index......................................................................................................................................................601 Database Alteration..............................................................................................................................602 DBA Database Dictionary......................................................................................................................621 Database Physical Model..................................................................................................................623 Database Dictionary..........................................................................................................................624 Database Population.............................................................................................................................674 Database Verification-Regular Tables...................................................................................................685 Database Verification-Audit Tables ......................................................................................................691 Data Mainpulation................................................................................................................................697 Oracle PLSQL-DB2 .................................................................................................................................738 Revised Database Directinoary.............................................................................................................753 Revised Physical Database Diagram .....................................................................................................760 Sybase SQLAnywhere 16...........................................................................................................................762 Database Creation.....................................................................................................................................763 Tables....................................................................................................................................................770 Index......................................................................................................................................................778 Triggers..................................................................................................................................................779 Database Population.............................................................................................................................790 Database Altration....................................................................................................................................800 DBA Database Dictionary..........................................................................................................................802 Physical Database Diagram...................................................................................................................803 Database Dictinoary..............................................................................................................................804 Data Verification-Regular Tables ..........................................................................................................859 User Accounts Creation ........................................................................................................................871 Data Mainpulation................................................................................................................................877 Table Population and Data Mainpulation...........................................................................................887
  • 4. 3 Materialized View .................................................................................................................................914 Revised Physical Database Dictinoary.......................................................................................................944 Revised Database Physical Diagram .....................................................................................................945 Remote Servers.....................................................................................................................................947
  • 5. 4
  • 6. 5
  • 7. 6
  • 8. 7 Database Systems Oracle 12c DB2 MySQL
  • 9. 8 Sybase SQL Anywhere16
  • 10. 9 Applications Microsoft Visio Microsoft Visual Studios 2010
  • 11. 10 Sybase Central Quest Toad Data Point
  • 12. 11 Oracle SQL Developer Oracle JDeveloper
  • 13. 12 IBM DataStudio MySQL Workbench Quest TOAD forMYSQL
  • 14. 13 Oracle SQL Developer Data Modeler
  • 15. 14 ERD Store PK Store_ID PK,FK1 Employee_ID PK,FK2 Store_State_ID PK,FK1 Store_ManagerID Store_Name Store_Type Store_Address Store_City Store_Phone Store_Status Management PK Manager_ID PK,FK1 Employee_ID Hire_Date Hire_EndDate StateCodes PK State_ID PK,FK1 Country_Code State_Name State_Abbrv State_TaxRate CountryCode PK Country_Code Country_Name Country_Abbrv Employee PK Employee_ID PK,FK1 State_ID First_Name Middle_Name Last_Name Adress City Phone Gender HRRecords PK HR_ID PK,FK1,FK2 Employee_ID PK,FK2 Store_ID PK,FK3 Role_ID DOB SSN Hire_Date End_Date Pay_Rate Education Ethnicity Race Customer PK Customer_ID PK,FK1 State_ID First_Name Middle_Name Last_Name Address City Phone DOB Gender Education Job_Type Income_Level HRRoles PK Role_ID Role_Title Role_Status Product PK Product_ID PK,FK1 Product_CategoryID Product_Name Product_Color Product_Size Poduct_Weighit Product_Description ProductCategory PK Product_CategoryID Category_Name Category_Description Receipt PK Receipt_ID PK,FK1 State_ID PK,FK1,FK3 Employee_ID PK,FK2 Customer_ID PK,FK3 Store_ID PK,FK4 Receipt_StateCode PK,FK5 Product_ID Receipt_Amount Receipt_Tax Receipt_Date Receipt_FinalAmt QTY FK6 Transaction_ID Transaction PK,FK1 Payment_ID PK Transaction_ID Transaction_Date Transaction_Status Transaction_Amount Transaction_Tax Transaction_FinalAmt Shipment PK Shippingg_ID PK,FK1 Shipper_ID PK,FK2 Receipt_ID Ship_Date Ship_EndDate Receive_Date Name Address City FK2 State_ID Shippment_Amount Shiippment_Type FK2 Product_ID ShippingCo PK Shipper_ID Shipper_Name Status Created_Date PaymentCop PK Payment_ID Payment_Cop_Name Payment_Type Payment_Created_Date Payment_Status Howard Retails Conceptual Diagram
  • 16. 15
  • 17. 16 Customer PK Customer_ID PK,FK1 Country_Code PK,FK1 State_ID First_Name Middle_Name Last_Name Address City Phone DOB Employee PK Employee_ID PK,FK1 Country_Code PK,FK1 State_ID First_Name Middle_Name Last_Name Address City Phone Statecodes PK State_ID PK,FK1 Country_Code State_Name State_Abbrv State_TaxRate CountryCode PK Country_Code Country_Name Country_Abbrv HRRecords PK,FK4 Employee_ID PK HR_ID PK,FK2 Role_ID PK,FK3,FK4 Store_ID PK,FK4 Manager_ID DOB Social_SecurityNum Hire_Date End_Date PayRate Employement_Status HRROLES PK Role_iD Role_Title Role_Status Store PK Store_ID Store_StateID Store_Name Store_Type Store_Address Store_City Store_City Store_Phone Store_Status Management PK Manager_ID PK,FK1 Store_ID PK,FK2 Employee_ID Hire_Date Hire_Enddate Receipt PK Receipt_ID PK,FK1 Product_ID PK,FK2 Employee_ID PK,FK3 Customer_ID PK,FK4 Store_ID Receipt_Amount Receipt_Tax QTY Receipt_FinalAmt Receipt_Date Product PK Product_ID PK,FK1 Product_CategoryID Product_Name Product_Color Product_Size Product_Weight Product_Description ProductCategory PK Product_CategoryID Category_Name Category_Description ShippingCo PK Shipper_ID Shipper_Name Status Created_Date Shipment PK Ship_Date PK,FK1 Receipt_ID PK,FK2 Shipper_ID PK,FK3 Store_ID PK,FK4 Employee_ID PK,FK5 State_ID Shipping_ID Ship_EndDate Receive_Date Name Address City Shipping_Amount Shipping_Type Ship_QTY PaymentCop PK Payment_ID PK,FK1 Receipt_ID PK,FK2 Store_ID Payment_CopName Payment_Type Payment_CreatedDate Payment_Status PaymentCard_Number Payment_ExpDate Authorized_Amount Howard Retail Logical Database Diagram
  • 18. 17 Oracle 12C R1
  • 19. 18
  • 20. 19 Note This development part for oracle has not been completed due to database failure but will be updated later in future relases. TableSpace and User Accounts SQL> show user; USER is "SYSTEM" SQL> create tablespace HowardRetail 2 datafile'C:Oracle12coradataUwaRetail' size 1G Online; Tablespace created. SQL> create temporary tablespace HowardRetail_Temp 2 tempfile 'C:Oracle12coradataUwaRetail_Temp' SIZE 80M autoextend on; Tablespace created. SQL> SQL> create user HowardDBA 2 Identified by howard 3 default tablespace HowardRetail; User created. SQL> SQL> Alter user HowardDBA 2 temporary tablespace HowardRetail_Temp; User altered. SQL> SQL> grant create session to HowardDBA; Grant succeeded. SQL> Grant resource to HowardDBA; Grant succeeded.
  • 21. 20 Applications User Account Creations Oracle SQLDevelopern User Account Creation Oracle JDeveloper User Account Creation
  • 22. 21 Microsoft Visual Studio User Account Creation
  • 23. 22 Tables SQL> Alter table countrycode 2 modify Country_Name constraint country_coname_nn not null; Table altered. SQL> Alter table countrycode 2 modify Country_Abbrv constraint country_coabbrv_nn not null; Table altered. SQL> SQL> create table CountryCodesAudit 2 (Country_Code Integer, 3 Country_Name Varchar2(60), 4 Country_Abbrv Varchar2(12), 5 Audit_Date timestamp, 6 Audit_User varchar2(50), 7 old_countrycode integer, 8 old_countryname Varchar2(60), 9 old_countryabbrv Varchar2(12), 10 Audit_ID integer GENERATED ALWAYS AS IDENTITY 11 (START WITH 110 INCREMENT BY 1), 12 Action_Type char(20) 13 ); Table created. SQL> SQL> SQL> Create table statecodes 2 (State_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 220 INCREMENT BY 15) , 4 Country_Code integer, 5 State_Name varchar2(45) ,
  • 24. 23 6 State_Abbrv varchar2(10) , 7 State_TaxRate integer , 8 constraint statecodes_statecode_pk primary key(State_ID, Country_Code), 9 constraint statecodes_statecode_uk unique (State_ID), 10 constraint Statecode_countrycode_fk foreign key (Country_Code) references 11 CountryCode(Country_Code) 12 ); Table created. SQL> Alter table statecodes 2 modify State_Name constraint statecode_statename_nn not null 3 modify State_Abbrv constraint statecode_stateabrv_nn not null 4 modify State_TaxRate constraint statecode_statetxrt_nn not null; Table altered. SQL> Create table StateCodesAudit 2 (State_ID integer, 3 Country_Code integer, 4 State_Name Varchar2(45), 5 State_Abbrv Varchar2(10), 6 State_TaxRate integer, 7 Audit_Date timestamp, 8 Audit_User varchar2(50), 9 Audit_ID integer GENERATED ALWAYS AS IDENTITY 10 (START WITH 200 INCREMENT BY 1), 11 Action_Type char(20), 12 Old_State_ID integer, 13 Old_Country_Code integer, 14 Old_State_Name Varchar2(45), 15 Old_State_Abbrv Varchar2(10), 16 Old_State_TaxRate integer ); Table created. SQL> SQL> SQL> SQL> create table Employee 2 (Employee_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0443 INCREMENT BY 25) , 4 First_Name varchar2(55) , 5 Middle_Name varchar2(55), 6 Last_Name varchar2(55) , 7 Address varchar2(55) , 8 City varchar2(45) , 9 State_ID Integer , 10 Phone varchar2(45) , 11 constraint employee_empid_pk primary key(Employee_ID,State_ID), 12 constraint employee_empid_uk unique (Employee_ID), 13 constraint employee_stateid_fk foreign key(state_id) references statecodes(state_id)
  • 25. 24 14 ); Table created. SQL> show user USER is "HOWARDDBA" SQL> SQL> SQL> SQL> SQL> SQL> Alter table Employee 2 modify First_Name constraint employee_firstname_nn not null 3 modify Last_Name constraint employee_lastname_nn not null 4 modify Address constraint employee_address_nn not null 5 modify city constraint employee_city_nn not null 6 modify phone constraint employee_phone_nn not null; Table altered. SQL> SQL> create table EmployeeAudit 2 (Employee_ID integer, 3 First_Name varchar2(55), 4 Middle_Name varchar2(55), 5 Last_Name Varchar2(55), 6 Address varchar2(55), 7 City Varchar2(45), 8 State_ID Integer, 9 Phone Varchar2(45), 10 Audit_Date timestamp, 11 Audit_User varchar2(50), 12 Audit_ID integer GENERATED ALWAYS AS IDENTITY 13 (START WITH 300 INCREMENT BY 1) , 14 Action_Type char(20), 15 Old_Employee_ID integer, 16 Old_First_Name varchar2(55), 17 Old_Middle_Name varchar2(55), 18 Old_Last_Name Varchar2(55), 19 Old_Address varchar2(55), 20 Old_City Varchar2(45), 21 Old_State_ID Integer, 22 Old_Phone Varchar2(45) 23 ); Table created. SQL> create table HRRoles 2 (Role_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0421 INCREMENT BY 25) , 4 Role_Title varchar2(45), 5 Role_status varchar2(45), 6 constraint HRRoles_roleid_pk primary key(Role_ID) 7 );
  • 26. 25 Table created. SQL> Alter table HRRoles 2 modify Role_Title constraint Hrroles_RoleTitle_nn not null 3 modify Role_status constraint Hrroles_Rolestatus_nn not null; Table altered. SQL> SQL> create table HRRolesAudit 2 (Role_ID integer, 3 Role_Title varchar2(45), 4 Role_status varchar2(45), 5 Old_RoleID integer, 6 Old_RoleTitle varchar2(45), 7 Old_Role_status varchar2(45), 8 Audit_Date timestamp, 9 Audit_User varchar2(50), 10 Audit_ID integer GENERATED ALWAYS AS IDENTITY 11 (START WITH 330 INCREMENT BY 1) , 12 Action_Type char(20) 13 ); Table created. SQL> SQL> Create table HRRecords 2 (Employee_ID Integer , 3 HR_ID Integer GENERATED ALWAYS AS IDENTITY (START WITH 0323 INCREMENT BY 20) , 4 Role_ID Integer , 5 Store_ID integer , 6 DOB Date not null, 7 Social_SecurityNum Integer , 8 Hire_Date Date , 9 End_Date Date, 10 PayRate numeric(15,2) , 11 Employement_Status varchar2(45), 12 constraint HrRecord_hrid_pk primary key(Employee_ID,HR_ID,Role_ID,Store_ID), 13 constraint HrRecord_hri_uk unique (HR_ID), 14 constraint HrRecord_empid_fk foreign key(Employee_ID) references Employee(Employee_ID) , 15 constraint HrRecord_roleid_fk foreign key(Role_ID) references HRRoles(Role_ID) 16 ); Table created. SQL> SQL> SQL> Create table HRRecordsAudit 2 (Employee_ID Integer, 3 HR_ID Integer, 4 Role_ID Integer, 5 Store_ID integer,
  • 27. 26 6 DOB Date, 7 Social_SecurityNum Integer, 8 Hire_Date Date, 9 End_Date Date, 10 PayRate numeric(15,2), 11 Employement_Status varchar2(45), 12 Old_EmployeeID Integer, 13 Old_HRID Integer, 14 Old_RoleID Integer, 15 Old_StoreID integer, 16 Old_DOB Date, 17 Old_SocialSecurityNum Integer, 18 Old_HireDate Date, 19 Old_EndDate Date, 20 Old_PayRate numeric(15,2), 21 Old_EmployementStatus varchar2(45), 22 Audit_Date timestamp, 23 Audit_User varchar2(50), 24 Audit_ID integer GENERATED ALWAYS AS IDENTITY 25 (START WITH 400 INCREMENT BY 1) , 26 Action_Type char(20) 27 ); Table created. SQL> create table Management 2 (Manager_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0123 INCREMENT BY 21) , 4 Employee_ID integer , 5 Hire_Date Date , 6 Hire_EndDate Date, 7 constraint Management_Magerid_pk primary key(Manager_ID,Employee_ID), 8 constraint Management_Magerid_uk unique(Manager_ID), 9 constraint Management_empid_fk foreign key(Employee_ID) references Employee(Employee_ID) 10 ); Table created. SQL> SQL> Alter table Management 2 modify Hire_Date constraint HireDate_nn not null; Table altered. SQL> SQL> create table ManagementAudit 2 (Manager_ID integer, 3 Employee_ID integer, 4 Hire_Date Date, 5 Hire_EndDate Date, 6 Old_ManagerID integer, 7 Old_EmployeeID integer, 8 Old_HireDate Date,
  • 28. 27 9 Old_HireEndDate Date, 10 Audit_Date timestamp, 11 Audit_User varchar2(50), 12 Audit_ID integer GENERATED ALWAYS AS IDENTITY 13 (START WITH 500 INCREMENT BY 1) , 14 Action_Type char(20) 15 ); Table created. SQL> SQL> SQL> create table store 2 (Store_ID Integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 025 INCREMENT BY 22) , 4 Store_StateID Integer, 5 Store_ManagerID Integer , 6 Store_Name varchar2(65) , 7 Store_Type varchar2(34) , 8 Store_Address varchar2(65) , 9 Store_City varchar2(45) , 10 Store_Phone varchar2(45), 11 Store_Status varchar2(30) , 12 constraint store_storeid_pk primary key(Store_ID,Store_StateID,Store_ManagerID), 13 constraint store_storeiid_uk unique(Store_ID), 14 constraint store_stateid_fk foreign key(Store_StateID) references statecodes 15 (State_ID), 16 constraint store_storeMagerID_FK Foreign key (Store_ManagerID) references Management(Manager_ID) 17 ); Table created. SQL> SQL> Alter table HRRecords 2 add constraint HrRecord_storeid_fk foreign key(Store_ID) references store(store_id); Table altered. SQL> SQL> Alter table store 2 modify Store_Name constraint store_storename_nn not null 3 modify Store_Type constraint store_storetype_nn not null 4 modify store_address constraint store_storeadd_nn not null 5 modify store_city constraint store_storecity_nn not null 6 modify store_phone constraint store_storephone_nn not null 7 modify store_status constraint store_storestatus_nn not null; Table altered. SQL> SQL> create table storeAudit
  • 29. 28 2 (Store_ID Integer, 3 Store_StateID Integer, 4 Store_ManagerID Integer, 5 Store_Name Varchar2(65), 6 Store_Type Varchar2(34), 7 Store_Address Varchar2(65), 8 Store_City Varchar2(45), 9 Store_Phone Varchar2(45), 10 Store_Status Varchar2(30), 11 Old_StoreID Integer, 12 Old_StorStateID Integer, 13 Old_StorManagerID Integer, 14 Old_StorName Varchar2(65), 15 Old_StorType Varchar2(34), 16 Old_StorAddress Varchar2(65), 17 Old_StorCity Varchar2(45), 18 old_StorPhone Varchar2(45), 19 old_StorStatus Varchar2(30), 20 Audit_Date timestamp, 21 Audit_User varchar2(50), 22 Audit_ID integer GENERATED ALWAYS AS IDENTITY 23 (START WITH 600 INCREMENT BY 1) , 24 Action_Type char(20) 25 ); Table created. SQL> SQL> create table customer 2 (Customer_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0643, INCREMENT BY 15) , 4 State_ID integer , 5 First_Name varchar2(50), 6 Middle_Name varchar2(50), 7 Last_Name varchar2(50), 8 Address varchar2(50), 9 City varchar2(45) , 10 Phone varchar2(45) , 11 DOB Date , 12 constraint customer_Customerid_pk primary key(customer_id,state_id), 13 constraint customer_customerid_uk unique (customer_id), 14 constraint customer_custstateid_fk foreign key(State_ID) references statecodes(State_ID) 15 ); (START WITH 0643, INCREMENT BY 15) , * ERROR at line 3: ORA-02000: missing ) keyword SQL> SQL> SQL> SQL>
  • 30. 29 SQL> create table customer 2 (Customer_ID integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0643 INCREMENT BY 15) , 4 State_ID integer , 5 First_Name varchar2(50), 6 Middle_Name varchar2(50), 7 Last_Name varchar2(50), 8 Address varchar2(50), 9 City varchar2(45) , 10 Phone varchar2(45) , 11 DOB Date , 12 constraint customer_Customerid_pk primary key(customer_id,state_id), 13 constraint customer_customerid_uk unique (customer_id), 14 constraint customer_custstateid_fk foreign key(State_ID) references statecodes(State_ID) 15 ); Table created. SQL> SQL> Alter table customer 2 modify First_Name constraint customer_firstname_nn not null 3 modify last_Name constraint customer_lastname_nn not null 4 modify address constraint customer_address_nn not null 5 modify city constraint customer_city_nn not null 6 modify phone constraint customer_phone_nn not null 7 modify DOB constraint customer_dob_nn not null; Table altered. SQL> SQL> create table CustomerAudit 2 (Customer_ID integer, 3 State_ID integer, 4 First_Name Varchar2(50), 5 Middle_Name Varchar2(50), 6 Last_Name Varchar2(50), 7 Address Varchar2(50), 8 City Varchar2(45), 9 Phone Varchar2(45), 10 DOB Date, 11 Old_CustomerID integer, 12 Old_StateID integer, 13 Old_FirstName Varchar2(50), 14 Old_MiddleName Varchar2(50), 15 Old_LastName Varchar2(50), 16 Old_Address Varchar2(50), 17 Old_City Varchar2(45), 18 Old_Phone Varchar2(45), 19 Old_DOB Date, 20 Audit_Date timestamp, 21 Audit_User varchar2(50), 22 Audit_ID integer GENERATED ALWAYS AS IDENTITY 23 (START WITH 700 INCREMENT BY 1) , 24 Action_Type char(20)
  • 31. 30 25 ); Table created. SQL> SQL> SQL> create table ProductCategory 2 (Product_CategoryID Integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0192 INCREMENT BY 19), 4 Category_Name varchar2(45) , 5 Category_Description clob, 6 constraint Prodcategory_prodcategory_pk primary key(Product_CategoryID) 7 ); Table created. SQL> SQL> Alter table ProductCategory 2 modify Category_Name constraint categoryName_nn not null; Table altered. SQL> SQL> SQL> create table ProductCategoryAudit 2 (Product_CategoryID Integer, 3 Category_Name Varchar2(45), 4 Category_Description clob, 5 Old_ProdCategoryID Integer, 6 Old_CategoryName Varchar2(45), 7 Old_CategoryDescription clob, 8 Audit_Date timestamp, 9 Audit_User varchar2(50), 10 Audit_ID integer GENERATED ALWAYS AS IDENTITY 11 (START WITH 800 INCREMENT BY 1), 12 Action_Type char(20) 13 ); Table created. SQL> SQL> create table product 2 (Product_ID Integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0292 INCREMENT BY 15), 4 Product_CategoryID Integer , 5 Product_Name varchar2(50), 6 Product_Color varchar2(35), 7 Product_Size varchar2(35), 8 Product_Weight varchar2(45), 9 Product_Description Clob, 10 constraint Product_Prodid_pk primary key(Product_ID,Product_CategoryID) 11 ,constraint product_prodid_uk unique (Product_ID),
  • 32. 31 12 constraint product_prodcategoid_fk foreign key(Product_CategoryID) references 13 ProductCategory(Product_CategoryID) 14 ); Table created. SQL> Alter table Product 2 modify Product_Name constraint product_prodname_nn not null; Table altered. SQL> SQL> SQL> create table productAudit 2 (Product_ID Integer, 3 Product_CategoryID Integer, 4 Product_Name Varchar2(50), 5 Product_Color Varchar2(35), 6 Product_Size Varchar2(35), 7 Product_Weight Varchar2(45), 8 Product_Description Clob, 9 Old_ProductID Integer, 10 Old_ProdCategoryID Integer, 11 Old_ProdName Varchar2(50), 12 Old_ProdColor Varchar2(35), 13 Old_ProdSize Varchar2(35), 14 Old_ProdWeight Varchar2(45), 15 Old_ProdDescription Clob, 16 Audit_Date timestamp, 17 Audit_User varchar2(50), 18 Audit_ID integer GENERATED ALWAYS AS IDENTITY 19 (START WITH 900 INCREMENT BY 1) , 20 Action_Type char(20) 21 ); Table created. SQL> SQL> create table PaymentCop 2 (Payment_id integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0242 INCREMENT BY 14) , 4 Payment_CopName varchar2(50), 5 Payment_Type varchar2(45), 6 Payment_CreatedDare Date, 7 Payment_Status varchar2(25), 8 PaymentCard_Number integer, 9 Payment_ExpDate Date, 10 constraint PaymentCop_paymentid_pk primary key(Payment_id), 11 constraint Paymentcop_PaymentType_ck check (Payment_Type in('VISA','MasterCard', 'Discovery','American Express','NA', 12 'visa','mastercard','discovery','american express')) 13 ); Table created.
  • 33. 32 SQL> SQL> SQL> Alter table PaymentCop 2 modify PaymentCard_Number constraint Paymentcop_Paycardnum_nn not null 3 modify Payment_CopName constraint Paymentcop_PayCopName_nn not null 4 modify Payment_Type constraint Paymentcop_PaycopType_nn not null; Table altered. SQL> SQL> create table PaymentCopAudit 2 (Payment_id integer, 3 Payment_CopName Varchar2(50), 4 Payment_Type Varchar2(45), 5 Payment_CreatedDare Date, 6 Payment_Status varchar2(25), 7 PaymentCard_Number integer, 8 Old_Payid integer, 9 Old_PayCopName Varchar2(50), 10 old_PayType Varchar2(45), 11 Old_PayCreatedDare Date, 12 Old_PayStatus varchar2(25), 13 Old_PayCard_Number integer, 14 Audit_Date timestamp, 15 Audit_User varchar2(50), 16 Audit_ID integer GENERATED ALWAYS AS IDENTITY 17 (START WITH 1000 INCREMENT BY 1) , 18 Action_Type char(20) 19 ); Table created. SQL> SQL> create table Receipt 2 (Receipt_ID Integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0232 INCREMENT BY 20), 4 State_ID integer , 5 Employee_ID integer , 6 Customer_ID integer , 7 Store_ID integer , 8 Receipt_StateCode Integer, 9 Product_ID Integer , 10 Receipt_Amount decimal (8,2), 11 Receipt_Tax decimal (8,2) , 12 QTY Integer , 13 Receipt_FinalAmt decimal (8,2), 14 Payment_ID integer , 15 constraint Receipt_Receipid_pk primary key(Receipt_ID,State_ID,Employee_ID,Customer_ID,Store_ID 16 ,Receipt_StateCode,Product_ID, Payment_ID), 17 constraint Receipt_Receiptid_uk unique (Receipt_ID), 18 constraint Receipt_customerid_fk foreign key(Customer_ID) references Customer(Customer_ID), 19 constraint Receipt_Employeeid_fk foreign key(Employee_ID) references Employee (Employee_ID),
  • 34. 33 20 constraint Receipt_Stateid_fk foreign key(State_ID) references statecodes(state_id), 21 constraint Receipt_storeid_fk foreign key(Store_id) references store(Store_id), 22 constraint Receipt_Productid_fk foreign key(Product_ID) references Product (Product_ID), 23 constraint Receipt_paymentid_fk foreign key(Payment_ID) references PaymentCOP(Payment_ID) 24 ); Table created. SQL> SQL> Alter table Receipt 2 add Receipt_Date DATE; Table altered. SQL> Alter table Receipt 2 modify Receipt_Amount constraint receipt_ReceiptAmount_nn not null 3 modify Receipt_Tax constraint receipt_ReceiptTax_nn not null 4 modify QTY constraint receipt_qty_nn not null 5 modify Receipt_Date constraint Receipt_Date_nn not null 6 modify Receipt_FinalAmt constraint Receipt_FinalAmt_nn not null; Table altered. SQL> SQL> SQL> create table ReceiptAudit 2 (Receipt_ID Integer, 3 State_ID integer, 4 Employee_ID integer, 5 Customer_ID integer, 6 Store_ID integer, 7 Receipt_StateCode Integer, 8 Product_ID Integer, 9 Receipt_Amount numeric , 10 Receipt_Tax decimal (8,2), 11 QTY Integer, 12 Receipt_FinalAmt numeric, 13 old_ReceiptID Integer, 14 old_StateID integer, 15 old_EmployeeID integer, 16 Old_CustomerID integer, 17 old_StoreID integer, 18 Old_RecptStatecd integer, 19 Old_Prodid integer, 20 Old_RecptAmt numeric, 21 Old_Recepttax decimal(8,2), 22 Old_QTY Integer, 23 old_recptFinalAmt numeric, 24 Audit_Date timestamp, 25 Audit_User varchar2(50), 26 Audit_ID integer GENERATED ALWAYS AS IDENTITY 27 (START WITH 1200 INCREMENT BY 1) ,
  • 35. 34 28 Action_Type char(20) 29 ); Table created. SQL> Alter table ReceiptAudit 2 add Receipt_Date DATE; Table altered. SQL> SQL> Alter table ReceiptAudit 2 add Old_ReceiptDate DATE; Table altered. SQL> SQL> SQL> create table shippingco 2 (shipper_id integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0242 INCREMENT BY 25), 4 Shipper_Name varchar2(50) , 5 status char(25) , 6 Create_date date, 7 constraint shippingco_shipperid_pk primary key(shipper_id) 8 ); Table created. SQL> SQL> Alter table shippingco 2 modify Shipper_Name constraint shipco_shippername_nn not null 3 modify status constraint shipco_status_nn not null; Table altered. SQL> SQL> SQL> SQL> create table shippingcoAudit 2 (shipper_id integer, 3 Shipper_Name Varchar2(50), 4 status char(25), 5 Create_date date, 6 Old_shipperid integer, 7 old_ShipperName Varchar2(50), 8 old_status char(25), 9 old_Create_date date, 10 Audit_Date timestamp, 11 Audit_User varchar2(50), 12 Audit_ID integer GENERATED ALWAYS AS IDENTITY 13 (START WITH 1300 INCREMENT BY 1), 14 Action_Type char(20) 15 );
  • 36. 35 Table created. SQL> SQL> create table shipment 2 (shipping_id integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0235 INCREMENT BY 26), 4 shipper_id integer , 5 state_id integer , 6 Receipt_ID integer , 7 ship_date date, 8 ship_enddate date, 9 receive_date date, 10 Name varchar2(55), 11 Address varchar2(55), 12 City varchar2(55), 13 shipping_amount numeric, 14 shipping_type char(35), 15 constraint shipment_shipmentid_pk primary key(shipping_id,shipper_id,RECEIPT_ID ), 16 constraint shipment_shipermid_uk unique (shipping_id), 17 constraint shipment_shipperid_fk foreign key(shipper_id) references shippingco(shipper_id), 18 CONSTRAINT SHIPMENT_RECEIPTID_FK FOREIGN KEY(RECEIPT_ID) REFERENCES RECEIPT(RECEIPT_ID) 19 ); Table created. SQL> SQL> SQL> SQL> create table shippmentAudit 2 (shipping_id integer, 3 shipper_id integer, 4 state_id integer, 5 Receipt_ID integer, 6 ship_date date, 7 ship_enddate date, 8 receive_date date, 9 Name varchar2(55), 10 Address Varchar2(55), 11 City varchar2(55), 12 shipping_amount number, 13 shipping_type char(35), 14 old_shippingid integer, 15 old_shipperid integer, 16 old_stateid integer, 17 old_ReceiptID integer, 18 old_shipdate date, 19 old_shipenddate date, 20 old_receivedate date, 21 old_Name varchar2(55), 22 old_Address Varchar2(55), 23 old_City varchar2(55), 24 old_shippingamt number,
  • 37. 36 25 old_shippingtype char(35), 26 Audit_Date timestamp, 27 Audit_User varchar2(50), 28 Audit_ID integer GENERATED ALWAYS AS IDENTITY 29 (START WITH 2000 INCREMENT BY 26), 30 Action_Type char(20) 31 ); Table created. Index SQL> SQL> create index Management_HireDate_indx on Management (Hire_Date); Index created. SQL> create index shippment_shippmentname_indx on shipment (Name); Index created. SQL> create index country_countryname_idx on countrycode (Country_Name); Index created. SQL> create index country_countryabbrv_indx on countrycode (Country_Abbrv) ; Index created. SQL> create index statecodes_statename_indx on statecodes (State_Name); Index created. SQL> create index statecodes_StateAbbrv_indx on statecodes (State_Abbrv); Index created. SQL> create index statecodes_TaxRate_indx on statecodes (State_TaxRate); Index created. SQL> create index Employee_FirstName_indx on Employee (First_Name); Index created. SQL> set echo off SQL> spool off
  • 38. 37
  • 39. 38 Triggers SQL> SQL> --This trigger will populate the audit date using the date from oracle date automatically-- SQL> SQL> SQL> create or replace trigger concodeAudit_auditdate_trgg 2 before insert on CountryCodesAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end concodeAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> --This trigger will populate the CountryCodesAudit table automatically by selecting the user-- SQL> SQL> create or replace trigger concodeAudit_audituser_trgg 2 before insert on CountryCodesAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end concodeAudit_audituser_trgg ; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> create or replace trigger CountryCodesAudit_del_trigg 2 after delete on countrycode 3 for each row 4 DECLARE 5 OCCD INTEGER; 6 OCCN Varchar2(60); 7 OCAB Varchar2(12); 8 ACT char(20); 9 begin 10 SELECT :OLD.Country_Code INTO OCCD FROM DUAL; 11 SELECT :OLD.Country_Name INTO OCCN FROM DUAL; 12 SELECT :OLD.Country_Abbrv INTO OCAB FROM DUAL; 13 SELECT 'Delete' INTO ACT FROM DUAL; 14 15 INSERT INTO CountryCodesAudit(old_countrycode, old_countryname,old_countryabbrv, Action_Type ) 16 SELECT OCCD, OCCN, OCAB, ACT FROM DUAL; 17 18 end CountryCodesAudit_del_trigg;
  • 40. 39 19 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger CountryCodesAudit_inst_trigg 2 after insert on countrycode 3 for each row 4 5 DECLARE 6 NCCD INTEGER; 7 NCCN Varchar2(60); 8 NCAB Varchar2(12); 9 ACT char(20); 10 11 begin 12 13 SELECT :NEW.Country_Code INTO NCCD FROM DUAL; 14 SELECT :NEW.Country_Name INTO NCCN FROM DUAL; 15 SELECT :NEW.Country_Abbrv INTO NCAB FROM DUAL; 16 SELECT 'Insert' INTO ACT FROM DUAL; 17 18 19 INSERT INTO CountryCodesAudit(Country_Code, Country_Name,Country_Abbrv, Action_Type ) 20 SELECT NCCD, NCCN, NCAB, ACT FROM DUAL; 21 22 23 end CountryCodesAudit_inst_trigg; 24 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger CountryCodesAudit_upd_trigg 2 after update on countrycode 3 for each row 4 DECLARE 5 NCCD INTEGER; 6 NCCN Varchar2(60); 7 NCAB Varchar2(12); 8 OCCD INTEGER; 9 OCCN Varchar2(60); 10 OCAB Varchar2(12); 11 ACT char(20); 12 13 begin 14
  • 41. 40 15 SELECT :NEW.Country_Code INTO NCCD FROM DUAL; 16 SELECT :NEW.Country_Name INTO NCCN FROM DUAL; 17 SELECT :NEW.Country_Abbrv INTO NCAB FROM DUAL; 18 SELECT :OLD.Country_Code INTO OCCD FROM DUAL; 19 SELECT :OLD.Country_Name INTO OCCN FROM DUAL; 20 SELECT :OLD.Country_Abbrv INTO OCAB FROM DUAL; 21 SELECT 'Update' INTO ACT FROM DUAL; 22 23 24 INSERT INTO CountryCodesAudit(Country_Code, Country_Name,Country_Abbrv,old_countrycode, old_countryname, 25 old_countryabbrv, Action_Type ) 26 SELECT NCCD, NCCN, NCAB,OCCD, OCCN, OCAB, ACT FROM DUAL; 27 28 29 end CountryCodesAudit_upd_trigg; 30 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger statecodesAudit_auditdate_trgg 2 before insert on StateCodesAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end statecodesAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger statecodesAudit_audituser_trgg 2 before insert on StateCodesAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end statecodesAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL>
  • 42. 41 SQL> CREATE OR REPLACE TRIGGER statecodesAdut_del_trigg 2 AFTER DELETE on STATECODES 3 FOR EACH ROW 4 DECLARE 5 OSTID INTEGER; 6 OCCD INTEGER; 7 OSTN Varchar2(45); 8 OSTAB Varchar2(10); 9 OSTRT Integer; 10 ACT char(20); 11 BEGIN 12 SELECT :OLD.State_ID INTO OSTID FROM DUAL; 13 SELECT :OLD.Country_Code INTO OCCD FROM DUAL; 14 SELECT :OLD.State_Name INTO OSTN FROM DUAL; 15 SELECT :OLD.State_Abbrv INTO OSTAB FROM DUAL; 16 SELECT :OLD.State_TaxRate INTO OSTRT FROM DUAL; 17 SELECT 'Delete' INTO ACT FROM DUAL; 18 19 INSERT INTO STATECODESAUDIT( Old_State_ID ,Old_Country_Code,Old_State_Name,Old_State_Abbrv,Old_State_TaxRate, 20 Action_Type) 21 SELECT OSTID, OCCD, OSTN,OSTAB,OSTRT,ACT FROM DUAL; 22 23 24 END statecodesAdut_del_trigg; 25 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER statecodesAdut_inst_trigg 2 AFTER INSERT on STATECODES 3 FOR EACH ROW 4 DECLARE 5 NSTID INTEGER; 6 NCCD INTEGER; 7 NSTN Varchar2(45); 8 NSTAB Varchar2(10); 9 NSTRT Integer; 10 ACT char(20); 11 BEGIN 12 SELECT :NEW.State_ID INTO NSTID FROM DUAL; 13 SELECT :NEW.Country_Code INTO NCCD FROM DUAL; 14 SELECT :NEW.State_Name INTO NSTN FROM DUAL; 15 SELECT :NEW.State_Abbrv INTO NSTAB FROM DUAL; 16 SELECT :NEW.State_TaxRate INTO NSTRT FROM DUAL; 17 SELECT 'INSERT' INTO ACT FROM DUAL; 18 19 INSERT INTO STATECODESAUDIT( State_ID ,Country_Code,State_Name,State_Abbrv,State_TaxRate, 20 Action_Type) 21 SELECT NSTID, NCCD, NSTN,NSTAB,NSTRT,ACT FROM DUAL; 22 23 24 25 END statecodesAdut_inst_trigg;
  • 43. 42 26 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER statecodesAdut_upd_trigg 2 AFTER UPDATE on STATECODES 3 FOR EACH ROW 4 DECLARE 5 NSTID INTEGER; 6 NCCD INTEGER; 7 NSTN Varchar2(45); 8 NSTAB Varchar2(10); 9 NSTRT Integer; 10 OSTID INTEGER; 11 OCCD INTEGER; 12 OSTN Varchar2(45); 13 OSTAB Varchar2(10); 14 OSTRT Integer; 15 ACT char(20); 16 BEGIN 17 SELECT :NEW.State_ID INTO NSTID FROM DUAL; 18 SELECT :NEW.Country_Code INTO NCCD FROM DUAL; 19 SELECT :NEW.State_Name INTO NSTN FROM DUAL; 20 SELECT :NEW.State_Abbrv INTO NSTAB FROM DUAL; 21 SELECT :NEW.State_TaxRate INTO NSTRT FROM DUAL; 22 SELECT :OLD.State_ID INTO OSTID FROM DUAL; 23 SELECT :OLD.Country_Code INTO OCCD FROM DUAL; 24 SELECT :OLD.State_Name INTO OSTN FROM DUAL; 25 SELECT :OLD.State_Abbrv INTO OSTAB FROM DUAL; 26 SELECT :OLD.State_TaxRate INTO OSTRT FROM DUAL; 27 SELECT 'Update' INTO ACT FROM DUAL; 28 29 INSERT INTO STATECODESAUDIT( State_ID ,Country_Code,State_Name,State_Abbrv,State_TaxRate, 30 Old_State_ID ,Old_Country_Code,Old_State_Name,Old_State_Abbrv,Old_State_TaxRate, Action_Type) 31 SELECT NSTID, NCCD, NSTN,NSTAB,NSTRT,OSTID, OCCD, OSTN,OSTAB,OSTRT ,ACT FROM DUAL; 32 33 34 35 END statecodesAdut_upd_trigg; 36 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL>
  • 44. 43 SQL> SQL> SQL> create or replace trigger EmployeeAudit_auditdate_trgg 2 before insert on EmployeeAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end EmployeeAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGEr EmployeeAudit_audituser_trgg 2 BEFORE INSERT ON EMPLOYEEAUDIT 3 FOR EACH ROW 4 BEGIN 5 SELECT USER INTO :NEW.AUDIT_USER FROM DUAL; 6 END EMPLOYEEAUDIT_AUDITUSER_TRGG; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER EmployeeAudit_del_trigg 2 AFTER DELETE ON EMPLOYEE 3 FOR EACH ROW 4 5 DECLARE 6 7 OEMP INTEGER; 8 OFN varchar2(55); 9 OMN varchar2(55) ; 10 OLN Varchar2(55); 11 OAD varchar2(55); 12 OCIT Varchar2(45); 13 OSTD Integer; 14 OPN Varchar2(45); 15 ACT char(20); 16 BEGIN 17 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 18 SELECT :OLD.First_Name INTO OFN FROM DUAL; 19 SELECT :OLD.Middle_Name INTO OMN FROM DUAL; 20 SELECT :OLD.Last_Name INTO OLN FROM DUAL; 21 SELECT :OLD.Address INTO OAD FROM DUAL; 22 SELECT :OLD.City INTO OCIT FROM DUAL; 23 SELECT :OLD.State_ID INTO OSTD FROM DUAL; 24 SELECT :OLD.Phone INTO OPN FROM DUAL; 25 SELECT 'Delete' INTO ACT FROM DUAL; 26 27
  • 45. 44 28 29 INSERT INTO EMPLOYEEAUDIT( Old_Employee_ID ,Old_First_Name,Old_Middle_Name,Old_Last_Name,Old_Address,Old_City, Old_State_ID, 30 Old_Phone , Action_Type) 31 SELECT OEMP,OFN, OMN, OLN ,OAD, OCIT ,OSTD ,OPN ,ACT FROM DUAL; 32 33 34 end EmployeeAudit_del_trigg; 35 / Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER EmployeeAudit_inst_trigg 2 AFTER INSERT ON EMPLOYEE 3 FOR EACH ROW 4 DECLARE 5 NEMP INTEGER; 6 NFN varchar2(55); 7 NMN varchar2(55) ; 8 NLN Varchar2(55); 9 NAD varchar2(55); 10 NCIT Varchar2(45); 11 NSTD Integer; 12 NPN Varchar2(45); 13 ACT char(20); 14 BEGIN 15 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 16 SELECT :NEW.First_Name INTO NFN FROM DUAL; 17 SELECT :NEW.Middle_Name INTO NMN FROM DUAL; 18 SELECT :NEW.Last_Name INTO NLN FROM DUAL; 19 SELECT :NEW.Address INTO NAD FROM DUAL; 20 SELECT :NEW.City INTO NCIT FROM DUAL; 21 SELECT :NEW.State_ID INTO NSTD FROM DUAL; 22 SELECT :NEW.Phone INTO NPN FROM DUAL; 23 SELECT 'Insert' INTO ACT FROM DUAL; 24 25 INSERT INTO EMPLOYEEAUDIT( Employee_ID ,First_Name,Middle_Name,Last_Name,Address,City, State_ID, 26 Phone , Action_Type) 27 SELECT NEMP,NFN, NMN, NLN ,NAD, NCIT ,NSTD ,NPN ,ACT FROM DUAL; 28 29 30 end EmployeeAudit_inst_trigg; 31 / Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER EmployeeAudit_updt_trigg
  • 46. 45 2 AFTER UPDATE ON EMPLOYEE 3 FOR EACH ROW 4 DECLARE 5 NEMP INTEGER; 6 NFN varchar2(55); 7 NMN varchar2(55) ; 8 NLN Varchar2(55); 9 NAD varchar2(55); 10 NCIT Varchar2(45); 11 NSTD Integer; 12 NPN Varchar2(45); 13 OEMP INTEGER; 14 OFN varchar2(55); 15 OMN varchar2(55) ; 16 OLN Varchar2(55); 17 OAD varchar2(55); 18 OCIT Varchar2(45); 19 OSTD Integer; 20 OPN Varchar2(45); 21 ACT char(20); 22 BEGIN 23 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 24 SELECT :NEW.First_Name INTO NFN FROM DUAL; 25 SELECT :NEW.Middle_Name INTO NMN FROM DUAL; 26 SELECT :NEW.Last_Name INTO NLN FROM DUAL; 27 SELECT :NEW.Address INTO NAD FROM DUAL; 28 SELECT :NEW.City INTO NCIT FROM DUAL; 29 SELECT :NEW.State_ID INTO NSTD FROM DUAL; 30 SELECT :NEW.Phone INTO NPN FROM DUAL; 31 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 32 SELECT :OLD.First_Name INTO OFN FROM DUAL; 33 SELECT :OLD.Middle_Name INTO OMN FROM DUAL; 34 SELECT :OLD.Last_Name INTO OLN FROM DUAL; 35 SELECT :OLD.Address INTO OAD FROM DUAL; 36 SELECT :OLD.City INTO OCIT FROM DUAL; 37 SELECT :OLD.State_ID INTO OSTD FROM DUAL; 38 SELECT :OLD.Phone INTO OPN FROM DUAL; 39 SELECT 'Update' INTO ACT FROM DUAL; 40 41 42 43 INSERT INTO EMPLOYEEAUDIT( Employee_ID ,First_Name,Middle_Name,Last_Name,Address,City, State_ID, 44 Phone , Old_Employee_ID ,Old_First_Name,Old_Middle_Name,Old_Last_Name,Old_Address,Old_City, Old_State_ID, 45 Old_Phone, Action_Type) 46 SELECT NEMP,NFN, NMN, NLN ,NAD, NCIT ,NSTD ,NPN ,OEMP,OFN, OMN, OLN ,OAD, OCIT ,OSTD ,OPN , ACT FROM DUAL; 47 48 end EmployeeAudit_updt_trigg; 49 / Trigger created. SQL> SQL>
  • 47. 46 SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRolesAudit_auditdate_trgg 2 BEFORE INSERT ON HRROLESAUDIT 3 FOR EACH ROW 4 BEGIN 5 SELECT SYSDATE INTO :NEW.AUDIT_DATE FROM DUAL; 6 END HRROLESAUDIT_AUDITDATE_TRGG; 7 / Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGEr HRRolesAudit_audituser_trgg 2 BEFORE INSERT ON HRROLESAUDIT 3 FOR EACH ROW 4 BEGIN 5 select user into :New.Audit_User from dual; 6 end HRRolesAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRolesAudit_del_trigg 2 AFTER DELETE ON HRRoles 3 FOR EACH ROW 4 5 DECLARE 6 ORID INTEGER; 7 ORTL varchar2(45); 8 ORST varchar2(45) ; 9 ACT char(20); 10 BEGIN 11 SELECT :OLD.Role_ID INTO ORID FROM DUAL; 12 SELECT :OLD.Role_Title INTO ORTL FROM DUAL; 13 SELECT :OLD.Role_status INTO ORST FROM DUAL; 14 SELECT 'Delete' INTO ACT FROM DUAL; 15 16 17 INSERT INTO HRRolesAudit(Old_RoleID,Old_RoleTitle ,Old_Role_status 18 ,Action_Type) 19 SELECT ORID,ORTL, ORST , ACT FROM DUAL; 20
  • 48. 47 21 END HRRolesAudit_del_trigg; 22 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRolesAudit_inst_trigg 2 AFTER INSERT ON HRRoles 3 FOR EACH ROW 4 5 DECLARE 6 NRID INTEGER; 7 NRTL varchar2(45); 8 NRST varchar2(45) ; 9 ACT char(20); 10 BEGIN 11 SELECT :NEW.Role_ID INTO NRID FROM DUAL; 12 SELECT :NEW.Role_Title INTO NRTL FROM DUAL; 13 SELECT :NEW.Role_status INTO NRST FROM DUAL; 14 SELECT 'Insert' INTO ACT FROM DUAL; 15 16 17 INSERT INTO HRRolesAudit(Role_ID,Role_Title ,Role_status 18 ,Action_Type) 19 SELECT NRID,NRTL, NRST , ACT FROM DUAL; 20 21 END HRRolesAudit_inst_trigg; 22 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRolesAudit_upd_trigg 2 AFTER UPDATE ON HRRoles 3 FOR EACH ROW 4 5 DECLARE 6 NRID INTEGER; 7 NRTL varchar2(45); 8 NRST varchar2(45) ; 9 ORID INTEGER; 10 ORTL varchar2(45); 11 ORST varchar2(45) ; 12 ACT char(20); 13 BEGIN 14 SELECT :NEW.Role_ID INTO NRID FROM DUAL; 15 SELECT :NEW.Role_Title INTO NRTL FROM DUAL; 16 SELECT :NEW.Role_status INTO NRST FROM DUAL; 17 SELECT :OLD.Role_ID INTO ORID FROM DUAL; 18 SELECT :OLD.Role_Title INTO ORTL FROM DUAL; 19 SELECT :OLD.Role_status INTO ORST FROM DUAL; 20 SELECT 'Update' INTO ACT FROM DUAL; 21 22
  • 49. 48 23 INSERT INTO HRRolesAudit(Role_ID,Role_Title ,Role_status,Old_RoleID,Old_RoleTitle ,Old_Role_status 24 ,Action_Type) 25 SELECT NRID,NRTL, NRST ,ORID,ORTL, ORST, ACT FROM DUAL; 26 27 END HRRolesAudit_upd_trigg; 28 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRecordsAudit_auditdate_trgg 2 BEFORE INSERT ON HRRECORDSAUDIT 3 FOR EACH ROW 4 BEGIN 5 SELECT SYSDATE INTO :NEW.AUDIT_DATE FROM DUAL; 6 end HRRecordsAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRecordsAudit_audituser_trgg 2 BEFORE INSERT ON HRRecordsAudit 3 FOR EACH ROW 4 BEGIN 5 SELECT USER INTO :NEW.AUDIT_USER FROM DUAL; 6 end HRRecordsAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRecordsAudit_del_trigg 2 AFTER DELETE ON HRRecords 3 FOR EACH ROW 4 DECLARE 5 OEMP INTEGER; 6 OHRD INTEGER; 7 ORID INTEGER ; 8 OSTD INTEGER; 9 ODB DATE; 10 OSSN INTEGER; 11 OHD Date; 12 OEND Date; 13 OPR numeric(15,2); 14 OEMS varchar2(45); 15 ACT char(20);
  • 50. 49 16 17 BEGIN 18 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 19 SELECT :OLD.HR_ID INTO OHRD FROM DUAL; 20 SELECT :OLD.Role_ID INTO ORID FROM DUAL; 21 SELECT :OLD.Store_ID INTO OSTD FROM DUAL; 22 SELECT :OLD.DOB INTO ODB FROM DUAL; 23 SELECT :OLD.Social_SecurityNum INTO OSSN FROM DUAL; 24 SELECT :OLD.Hire_Date INTO OHD FROM DUAL; 25 SELECT :OLD.End_Date INTO OEND FROM DUAL; 26 SELECT :OLD.PayRate INTO OPR FROM DUAL; 27 SELECT :OLD.Employement_Status INTO OEMS FROM DUAL; 28 SELECT 'Delete' INTO ACT FROM DUAL; 29 30 INSERT INTO HRRecordsAudit(Old_EmployeeID,Old_HRID,Old_RoleID,Old_StoreID,Old_DOB , 31 Old_SocialSecurityNum,Old_HireDate, Old_EndDate,Old_PayRate,Old_EmployementStatus,Action_Type) 32 SELECT OEMP, OHRD, ORID, OSTD, ODB,OSSN,OHD, OEND, OPR,OEMS,ACT FROM DUAL; 33 end HRRecordsAudit_del_trigg; 34 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRecordsAudit_inst_trigg 2 AFTER INSERT ON HRRecords 3 FOR EACH ROW 4 DECLARE 5 NEMP INTEGER; 6 NHRD INTEGER; 7 NRID INTEGER ; 8 NSTD INTEGER; 9 NDB DATE; 10 NSSN INTEGER; 11 NHD Date; 12 NEND Date; 13 NPR numeric(15,2); 14 NEMS varchar2(45); 15 ACT char(20); 16 17 BEGIN 18 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 19 SELECT :NEW.HR_ID INTO NHRD FROM DUAL; 20 SELECT :NEW.Role_ID INTO NRID FROM DUAL; 21 SELECT :NEW.Store_ID INTO NSTD FROM DUAL; 22 SELECT :NEW.DOB INTO NDB FROM DUAL; 23 SELECT :NEW.Social_SecurityNum INTO NSSN FROM DUAL; 24 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 25 SELECT :NEW.End_Date INTO NEND FROM DUAL; 26 SELECT :NEW.PayRate INTO NPR FROM DUAL; 27 SELECT :NEW.Employement_Status INTO NEMS FROM DUAL;
  • 51. 50 28 SELECT 'Insert' INTO ACT FROM DUAL; 29 30 INSERT INTO HRRecordsAudit(Employee_ID,HR_ID,Role_ID,Store_ID,DOB,Social_SecurityNum,H ire_Date, End_Date,PayRate, 31 Employement_Status,Action_Type) 32 SELECT NEMP, NHRD, NRID, NSTD, NDB,NSSN,NHD, NEND, NPR,NEMS,ACT FROM DUAL; 33 34 end HRRecordsAudit_inst_trigg; 35 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER HRRecordsAudit_upd_trigg 2 AFTER Update ON HRRecords 3 FOR EACH ROW 4 DECLARE 5 NEMP INTEGER; 6 NHRD INTEGER; 7 NRID INTEGER ; 8 NSTD INTEGER; 9 NDB DATE; 10 NSSN INTEGER; 11 NHD Date; 12 NEND Date; 13 NPR numeric(15,2); 14 NEMS varchar2(45); 15 OEMP INTEGER; 16 OHRD INTEGER; 17 ORID INTEGER ; 18 OSTD INTEGER; 19 ODB DATE; 20 OSSN INTEGER; 21 OHD Date; 22 OEND Date; 23 OPR numeric(15,2); 24 OEMS varchar2(45); 25 ACT char(20); 26 27 BEGIN 28 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 29 SELECT :NEW.HR_ID INTO NHRD FROM DUAL; 30 SELECT :NEW.Role_ID INTO NRID FROM DUAL; 31 SELECT :NEW.Store_ID INTO NSTD FROM DUAL; 32 SELECT :NEW.DOB INTO NDB FROM DUAL; 33 SELECT :NEW.Social_SecurityNum INTO NSSN FROM DUAL; 34 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 35 SELECT :NEW.End_Date INTO NEND FROM DUAL; 36 SELECT :NEW.PayRate INTO NPR FROM DUAL; 37 SELECT :NEW.Employement_Status INTO NEMS FROM DUAL; 38 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL;
  • 52. 51 39 SELECT :OLD.HR_ID INTO OHRD FROM DUAL; 40 SELECT :OLD.Role_ID INTO ORID FROM DUAL; 41 SELECT :OLD.Store_ID INTO OSTD FROM DUAL; 42 SELECT :OLD.DOB INTO ODB FROM DUAL; 43 SELECT :OLD.Social_SecurityNum INTO OSSN FROM DUAL; 44 SELECT :OLD.Hire_Date INTO OHD FROM DUAL; 45 SELECT :OLD.End_Date INTO OEND FROM DUAL; 46 SELECT :OLD.PayRate INTO OPR FROM DUAL; 47 SELECT :OLD.Employement_Status INTO OEMS FROM DUAL; 48 SELECT 'Update' INTO ACT FROM DUAL; 49 50 INSERT INTO HRRecordsAudit(Employee_ID,HR_ID,Role_ID,Store_ID,DOB,Social_SecurityNum,H ire_Date, End_Date,PayRate, 51 Employement_Status,Old_EmployeeID,Old_HRID,Old_RoleID,Old_StoreID,Old_DOB , 52 Old_SocialSecurityNum,Old_HireDate, Old_EndDate,Old_PayRate,Old_EmployementStatus,Action_Type) 53 SELECT NEMP, NHRD, NRID, NSTD, NDB,NSSN,NHD, NEND, NPR,NEMS,OEMP, OHRD, ORID, OSTD, ODB,OSSN,OHD, OEND, OPR,OEMS, 54 ACT FROM DUAL; 55 56 end HRRecordsAudit_upd_trigg; 57 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ManagementAudit_auditdate_trgg 2 BEFORE INSERT ON MANAGEMENTAUDIT 3 FOR EACH ROW 4 BEGIN 5 select sysdate into :New.Audit_Date from dual; 6 end HRRecordsAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> create or replace trigger ManagementAudit_audituser_trgg 2 before insert on ManagementAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end ManagementAudit_audituser_trgg; 7 / Trigger created. SQL> SQL>
  • 53. 52 SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_del_trigg 2 AFTER DELETE ON Management 3 for each row 4 DECLARE 5 OMID Integer; 6 OEMP Integer; 7 OHD DATE; 8 OEND DATE; 9 ACT char(20); 10 BEGIN 11 12 SELECT :OLD.Manager_ID INTO OMID FROM DUAL; 13 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 14 SELECT :OLD.Hire_Date INTO OHD FROM DUAL; 15 SELECT :OLD.Hire_EndDate INTO OEND FROM DUAL; 16 SELECT 'Delete' INTO ACT FROM DUAL; 17 18 INSERT INTO ManagementAudit(Old_ManagerID,Old_EmployeeID ,Old_HireDate, Old_HireEndDate ,Action_Type) 19 SELECT OMID, OEMP, OHD,OEND,ACT FROM DUAL; 20 21 22 end ManagementAuditt_del_trigg; 23 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_inst_trigg 2 AFTER INSERT ON Management 3 for each row 4 DECLARE 5 NMID Integer; 6 NEMP Integer; 7 NHD DATE; 8 NEND DATE; 9 ACT char(20); 10 BEGIN 11 12 SELECT :NEW.Manager_ID INTO NMID FROM DUAL; 13 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 14 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 15 SELECT :NEW.Hire_EndDate INTO NEND FROM DUAL; 16 SELECT 'Insert' INTO ACT FROM DUAL; 17 18 INSERT INTO ManagementAudit(Manager_ID,Employee_ID ,Hire_Date, Hire_EndDate ,Action_Type)
  • 54. 53 19 SELECT NMID, NEMP, NHD,NEND,ACT FROM DUAL; 20 21 22 end ManagementAuditt_inst_trigg; 23 / Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_updt_trigg 2 AFTER UPDATE ON Management 3 for each row 4 DECLARE 5 NMID Integer; 6 NEMP Integer; 7 NHD DATE; 8 NEND DATE; 9 OMID Integer; 10 OEMP Integer; 11 OHD DATE; 12 OEND DATE; 13 ACT char(20); 14 BEGIN 15 16 SELECT :NEW.Manager_ID INTO NMID FROM DUAL; 17 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 18 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 19 SELECT :NEW.Hire_EndDate INTO NEND FROM DUAL; 20 SELECT :OLD.Manager_ID INTO OMID FROM DUAL; 21 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 22 SELECT :OLD.Hire_Date INTO OHD FROM DUAL; 23 SELECT :OLD.Hire_EndDate INTO OEND FROM DUAL; 24 SELECT 'Update' INTO ACT FROM DUAL; 25 26 INSERT INTO ManagementAudit(Manager_ID,Employee_ID ,Hire_Date, Hire_EndDate ,Old_ManagerID,Old_EmployeeID ,Old_HireDate, Old_HireEndDate, 27 Action_Type) 28 SELECT NMID, NEMP, NHD,NEND,OMID, OEMP, OHD,OEND,ACT FROM DUAL; 29 30 end ManagementAuditt_updt_trigg; 31 32 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger storeAudit_auditdate_trgg 2 before insert on storeAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end storeAudit_auditdate_trgg;
  • 55. 54 7 / Trigger created. SQL> SQL> SQL> create or replace trigger storeAudit_audituser_trgg 2 before insert on storeAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end storeAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER storeAudit_del_trigg 2 AFTER DELETE ON STORE 3 FOR EACH ROW 4 DECLARE 5 OSTID Integer; 6 OSSTID Integer; 7 OSMID Integer; 8 OSTN Varchar2(65); 9 OSTY Varchar2(34); 10 OSTA Varchar2(65); 11 OSTC Varchar2(45); 12 OSP Varchar2(45); 13 OSTS Varchar2(30); 14 ACT char(20); 15 BEGIN 16 SELECT :OLD.Store_ID INTO OSTID FROM DUAL; 17 SELECT :OLD.Store_StateID INTO OSSTID FROM DUAL; 18 SELECT :OLD.Store_ManagerID INTO OSMID FROM DUAL; 19 SELECT :OLD.Store_Name INTO OSTN FROM DUAL; 20 SELECT :OLD.Store_Type INTO OSTY FROM DUAL; 21 SELECT :OLD.Store_Address INTO OSTA FROM DUAL; 22 SELECT :OLD.Store_City INTO OSTC FROM DUAL; 23 SELECT :OLD.Store_Phone INTO OSP FROM DUAL; 24 SELECT :OLD.Store_Status INTO OSTS FROM DUAL; 25 SELECT 'Delete' INTO ACT FROM DUAL; 26 27 28 29 insert into storeAudit(Old_StoreID,Old_StorStateID,Old_StorManagerID,Old_StorName,Old_ StorType,Old_StorAddress,Old_StorCity,old_StorPhone,old_StorStatus, Action_Type) 30 select OSTID, OSSTID, OSMID, OSTN, OSTY,OSTA,OSTC,OSP,OSTS, ACT FROM DUAL; 31 end storeAudit_del_trigg; 32 /
  • 56. 55 Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER storeAudit_inst_trigg 2 AFTER INSERT ON STORE 3 FOR EACH ROW 4 DECLARE 5 NSTID Integer; 6 NSSTID Integer; 7 NSMID Integer; 8 NSTN Varchar2(65); 9 NSTY Varchar2(34); 10 NSTA Varchar2(65); 11 NSTC Varchar2(45); 12 NSP Varchar2(45); 13 NSTS Varchar2(30); 14 ACT char(20); 15 BEGIN 16 SELECT :NEW.Store_ID INTO NSTID FROM DUAL; 17 SELECT :NEW.Store_StateID INTO NSSTID FROM DUAL; 18 SELECT :NEW.Store_ManagerID INTO NSMID FROM DUAL; 19 SELECT :NEW.Store_Name INTO NSTN FROM DUAL; 20 SELECT :NEW.Store_Type INTO NSTY FROM DUAL; 21 SELECT :NEW.Store_Address INTO NSTA FROM DUAL; 22 SELECT :NEW.Store_City INTO NSTC FROM DUAL; 23 SELECT :NEW.Store_Phone INTO NSP FROM DUAL; 24 SELECT :NEW.Store_Status INTO NSTS FROM DUAL; 25 SELECT 'Insert' INTO ACT FROM DUAL; 26 27 28 29 insert into storeAudit(Store_ID,Store_StateID,Store_ManagerID,Store_Name,Store_Type,St ore_Address,Store_City,Store_Phone,Store_Status, Action_Type) 30 select NSTID, NSSTID, NSMID, NSTN, NSTY,NSTA,NSTC,NSP,NSTS, ACT FROM DUAL; 31 end storeAudit_del_trigg; 32 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER storeAudit_upd_trigg 2 AFTER update ON STORE 3 FOR EACH ROW 4 DECLARE 5 NSTID Integer;
  • 57. 56 6 NSSTID Integer; 7 NSMID Integer; 8 NSTN Varchar2(65); 9 NSTY Varchar2(34); 10 NSTA Varchar2(65); 11 NSTC Varchar2(45); 12 NSP Varchar2(45); 13 NSTS Varchar2(30); 14 OSTID Integer; 15 OSSTID Integer; 16 OSMID Integer; 17 OSTN Varchar2(65); 18 OSTY Varchar2(34); 19 OSTA Varchar2(65); 20 OSTC Varchar2(45); 21 OSP Varchar2(45); 22 OSTS Varchar2(30); 23 ACT char(20); 24 BEGIN 25 SELECT :NEW.Store_ID INTO NSTID FROM DUAL; 26 SELECT :NEW.Store_StateID INTO NSSTID FROM DUAL; 27 SELECT :NEW.Store_ManagerID INTO NSMID FROM DUAL; 28 SELECT :NEW.Store_Name INTO NSTN FROM DUAL; 29 SELECT :NEW.Store_Type INTO NSTY FROM DUAL; 30 SELECT :NEW.Store_Address INTO NSTA FROM DUAL; 31 SELECT :NEW.Store_City INTO NSTC FROM DUAL; 32 SELECT :NEW.Store_Phone INTO NSP FROM DUAL; 33 SELECT :NEW.Store_Status INTO NSTS FROM DUAL; 34 SELECT :OLD.Store_ID INTO OSTID FROM DUAL; 35 SELECT :OLD.Store_StateID INTO OSSTID FROM DUAL; 36 SELECT :OLD.Store_ManagerID INTO OSMID FROM DUAL; 37 SELECT :OLD.Store_Name INTO OSTN FROM DUAL; 38 SELECT :OLD.Store_Type INTO OSTY FROM DUAL; 39 SELECT :OLD.Store_Address INTO OSTA FROM DUAL; 40 SELECT :OLD.Store_City INTO OSTC FROM DUAL; 41 SELECT :OLD.Store_Phone INTO OSP FROM DUAL; 42 SELECT :OLD.Store_Status INTO OSTS FROM DUAL; 43 SELECT 'Update' INTO ACT FROM DUAL; 44 45 insert into storeAudit(Store_ID,Store_StateID,Store_ManagerID,Store_Name,Store_Type,St ore_Address,Store_City,Store_Phone,Store_Status, 46 Old_StoreID,Old_StorStateID,Old_StorManagerID,Old_StorName,Old_StorType,Ol d_StorAddress,Old_StorCity,old_StorPhone,old_StorStatus, 47 Action_Type) 48 select NSTID, NSSTID, NSMID, NSTN, NSTY,NSTA,NSTC,NSP,NSTS, OSTID, OSSTID, OSMID, OSTN, OSTY,OSTA,OSTC,OSP,OSTS, ACT FROM DUAL; 49 end storeAudit_upd_trigg; 50 / Trigger created. SQL> SQL> SQL> SQL>
  • 58. 57 SQL> set echo off SQL> spool off; SQL> SQL> SQL> SQL> SQL> SQL> show user USER is "HOWARDDBA" SQL> SQL> SQL> SQL> ---This trigger will populate the CustomerAudit table audit date column SQL> SQL> create or replace trigger CustomerAudit_auditdate_trgg 2 before insert on CustomerAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end CustomerAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> /*This trigger will populate the storeAudit table audit user column automatically */ Trigger created. SQL> SQL> create or replace trigger CustomerAudit_audituser_trgg 2 before insert on CustomerAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end CustomerAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER CustomerAudit_del_trigg 2 AFTER DELETE ON Customer 3 FOR EACH ROW 4 DECLARE 5 OCID integer;
  • 59. 58 6 OSTID Integer; 7 OFN Varchar2(50); 8 OMDN Varchar2(50); 9 OLN Varchar2(50); 10 OAD Varchar2(50); 11 OCIT Varchar2(45); 12 OPN Varchar2(45); 13 ODB DATE; 14 ACT CHAR(20); 15 BEGIN 16 SELECT :OLD.Customer_ID INTO OCID FROM DUAL; 17 SELECT :OLD.State_ID INTO OSTID FROM DUAL; 18 SELECT :OLD.First_Name INTO OFN FROM DUAL; 19 SELECT :OLD.Middle_Name INTO OMDN FROM DUAL; 20 SELECT :OLD.Last_Name INTO OLN FROM DUAL; 21 SELECT :OLD.Address INTO OAD FROM DUAL; 22 SELECT :OLD.City INTO OCIT FROM DUAL; 23 SELECT :OLD.Phone INTO OPN FROM DUAL; 24 SELECT :OLD.DOB INTO ODB FROM DUAL; 25 SELECT 'Delete' INTO ACT FROM DUAL; 26 27 INSERT INTO CUSTOMERAUDIT 28 (Old_CustomerID, Old_StateID ,Old_FirstName , Old_MiddleName, Old_LastName, Old_Address ,Old_City, Old_Phone, Old_DOB , Action_Type) 29 SELECT OCID,OSTID,OFN,OMDN,OLN,OAD,OCIT,OPN,ODB ,ACT FROM DUAL; 30 31 END CustomerAudit_del_trigg; 32 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER CustomerAudit_Inst_trigg 2 AFTER INSERT ON Customer 3 FOR EACH ROW 4 DECLARE 5 NCID integer; 6 NSTID Integer; 7 NFN Varchar2(50); 8 NMDN Varchar2(50); 9 NLN Varchar2(50); 10 NAD Varchar2(50); 11 NCIT Varchar2(45); 12 NPN Varchar2(45); 13 NDB DATE; 14 ACT CHAR(20); 15 BEGIN 16 SELECT :NEW.Customer_ID INTO NCID FROM DUAL; 17 SELECT :NEW.State_ID INTO NSTID FROM DUAL; 18 SELECT :NEW.First_Name INTO NFN FROM DUAL; 19 SELECT :NEW.Middle_Name INTO NMDN FROM DUAL; 20 SELECT :NEW.Last_Name INTO NLN FROM DUAL; 21 SELECT :NEW.Address INTO NAD FROM DUAL; 22 SELECT :NEW.City INTO NCIT FROM DUAL;
  • 60. 59 23 SELECT :NEW.Phone INTO NPN FROM DUAL; 24 SELECT :NEW.DOB INTO NDB FROM DUAL; 25 SELECT 'Insert' INTO ACT FROM DUAL; 26 27 INSERT INTO CUSTOMERAUDIT 28 (Customer_ID, State_ID ,First_Name , Middle_Name, Last_Name, Address ,City, Phone, DOB , Action_Type) 29 SELECT NCID,NSTID,NFN,NMDN,NLN,NAD,NCIT,NPN,NDB ,ACT FROM DUAL; 30 31 END CustomerAudit_Inst_trigg; 32 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER CustomerAudit_Updt_trigg 2 AFTER UPDATE ON Customer 3 FOR EACH ROW 4 DECLARE 5 NCID integer; 6 NSTID Integer; 7 NFN Varchar2(50); 8 NMDN Varchar2(50); 9 NLN Varchar2(50); 10 NAD Varchar2(50); 11 NCIT Varchar2(45); 12 NPN Varchar2(45); 13 NDB DATE; 14 OCID integer; 15 OSTID Integer; 16 OFN Varchar2(50); 17 OMDN Varchar2(50); 18 OLN Varchar2(50); 19 OAD Varchar2(50); 20 OCIT Varchar2(45); 21 OPN Varchar2(45); 22 ODB DATE; 23 ACT CHAR(20); 24 BEGIN 25 SELECT :NEW.Customer_ID INTO NCID FROM DUAL; 26 SELECT :NEW.State_ID INTO NSTID FROM DUAL; 27 SELECT :NEW.First_Name INTO NFN FROM DUAL; 28 SELECT :NEW.Middle_Name INTO NMDN FROM DUAL; 29 SELECT :NEW.Last_Name INTO NLN FROM DUAL; 30 SELECT :NEW.Address INTO NAD FROM DUAL; 31 SELECT :NEW.City INTO NCIT FROM DUAL; 32 SELECT :NEW.Phone INTO NPN FROM DUAL; 33 SELECT :NEW.DOB INTO NDB FROM DUAL; 34 SELECT :OLD.Customer_ID INTO OCID FROM DUAL; 35 SELECT :OLD.State_ID INTO OSTID FROM DUAL; 36 SELECT :OLD.First_Name INTO OFN FROM DUAL; 37 SELECT :OLD.Middle_Name INTO OMDN FROM DUAL; 38 SELECT :OLD.Last_Name INTO OLN FROM DUAL;
  • 61. 60 39 SELECT :OLD.Address INTO OAD FROM DUAL; 40 SELECT :OLD.City INTO OCIT FROM DUAL; 41 SELECT :OLD.Phone INTO OPN FROM DUAL; 42 SELECT :OLD.DOB INTO ODB FROM DUAL; 43 SELECT 'Update' INTO ACT FROM DUAL; 44 45 INSERT INTO CUSTOMERAUDIT 46 (Customer_ID, State_ID ,First_Name , Middle_Name, Last_Name, Address ,City, Phone, DOB , Old_CustomerID, Old_StateID ,Old_FirstName , Old_MiddleName, Old_LastName, 47 Old_Address ,Old_City, Old_Phone, Old_DOB ,Action_Type) 48 SELECT NCID,NSTID,NFN,NMDN,NLN,NAD,NCIT,NPN,NDB ,OCID,OSTID,OFN,OMDN,OLN,OAD,OCIT,OPN,ODB,ACT FROM DUAL; 49 50 END CustomerAudit_Updt_trigg; 51 / Trigger created. SQL> create or replace trigger ProdCatAudit_auddate_trgg 2 before insert on ProductCategoryAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end ProdCatAudit_auddate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger ProdCatAudit_audituser_trgg 2 before insert on ProductCategoryAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end ProdCatAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ProductCategoryAudit_del_trigg 2 AFTER DELETE ON ProductCategory 3 FOR EACH ROW 4 DECLARE 5 OPCID Integer; 6 OPCN Varchar2(45);
  • 62. 61 7 OPCD CLOB; 8 ACT Char(20); 9 BEGIN 10 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 11 SELECT :OLD.Category_Name INTO OPCN FROM DUAL; 12 SELECT :OLD.Category_Description INTO OPCD FROM DUAL; 13 SELECT 'Delete' Into ACT FROM DUAL; 14 15 16 INSERT INTO ProductCategoryAudit (Old_ProdCategoryID,Old_CategoryName,Old_CategoryDescription , Action_Type ) 17 SELECT OPCID,OPCN,OPCD, ACT 18 19 FROM DUAL; 20 END ProductCategoryAudit_del_trigg; 21 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ProdCategoryAudit_inst_trigg 2 AFTER INSERT ON ProductCategory 3 FOR EACH ROW 4 DECLARE 5 NPCID Integer; 6 NPCN Varchar2(45); 7 NPCD CLOB; 8 ACT Char(20); 9 BEGIN 10 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 11 SELECT :NEW.Category_Name INTO NPCN FROM DUAL; 12 SELECT :NEW.Category_Description INTO NPCD FROM DUAL; 13 SELECT 'Insert' Into ACT FROM DUAL; 14 15 16 INSERT INTO ProductCategoryAudit (Product_CategoryID,Category_Name,Category_Description , Action_Type ) 17 SELECT NPCID,NPCN,NPCD, ACT 18 19 FROM DUAL; 20 END ProdCategoryAudit_inst_trigg; 21 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ProdCategoryAudit_upt_trigg 2 AFTER update ON ProductCategory 3 FOR EACH ROW
  • 63. 62 4 DECLARE 5 NPCID Integer; 6 NPCN Varchar2(45); 7 NPCD CLOB; 8 ACT Char(20); 9 OPCID Integer; 10 OPCN Varchar2(45); 11 OPCD CLOB; 12 BEGIN 13 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 14 SELECT :NEW.Category_Name INTO NPCN FROM DUAL; 15 SELECT :NEW.Category_Description INTO NPCD FROM DUAL; 16 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 17 SELECT :OLD.Category_Name INTO OPCN FROM DUAL; 18 SELECT :OLD.Category_Description INTO OPCD FROM DUAL; 19 SELECT 'Update' Into ACT FROM DUAL; 20 21 22 INSERT INTO ProductCategoryAudit (Product_CategoryID,Category_Name,Category_Description , 23 Old_ProdCategoryID,Old_CategoryName,Old_CategoryDescription, 24 Action_Type ) 25 SELECT NPCID,NPCN,NPCD,OPCID,OPCN,OPCD, ACT 26 27 FROM DUAL; 28 END ProdCategoryAudit_upt_trigg; 29 / Trigger created. SQL> SQL> SQL> create or replace trigger productAudit_auditdate_trgg 2 before insert on productAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end productAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger productAudit_audituser_trgg 2 before insert on productAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end productAudit_audituser_trgg; 7 / Trigger created. SQL> SQL>
  • 64. 63 SQL> SQL> SQL> CREATE OR REPLACE TRIGGER productAudit_del_trigg 2 AFTER DELETE ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 OPID Integer; 6 OPCID Integer; 7 OPN Varchar2(50); 8 OPC Varchar2(35); 9 OPS Varchar2(35); 10 OPW Varchar2(45); 11 OPD CLOB; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :OLD.Product_ID INTO OPID FROM DUAL; 16 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 17 SELECT :OLD.Product_Name INTO OPN FROM DUAL; 18 SELECT :OLD.Product_Color INTO OPC FROM DUAL; 19 SELECT :OLD.Product_Size INTO OPS FROM DUAL; 20 SELECT :OLD.Product_Weight INTO OPW FROM DUAL; 21 SELECT :OLD.Product_Description INTO OPD FROM DUAL; 22 SELECT 'Delete' INTO ACT FROM DUAL; 23 24 25 INSERT INTO productAudit 26 (Old_ProductID,Old_ProdCategoryID,Old_ProdName,Old_ProdColor,Old_ProdSize, Old_ProdWeight,Old_ProdDescription, Action_Type) 27 SELECT OPID,OPCID, OPN, OPC,OPS,OPW,OPD, ACT FROM DUAL; 28 END productAudit_del_trigg; 29 / Trigger created. SQL> SQL> SQL> CREATE OR REPLACE TRIGGER productAudit_Inst_trigg 2 AFTER INSERT ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCID Integer; 7 NPN Varchar2(50); 8 NPC Varchar2(35); 9 NPS Varchar2(35); 10 NPW Varchar2(45); 11 NPD CLOB; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :NEW.Product_ID INTO NPID FROM DUAL; 16 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 17 SELECT :NEW.Product_Name INTO NPN FROM DUAL; 18 SELECT :NEW.Product_Color INTO NPC FROM DUAL; 19 SELECT :NEW.Product_Size INTO NPS FROM DUAL;
  • 65. 64 20 SELECT :NEW.Product_Weight INTO NPW FROM DUAL; 21 SELECT :NEW.Product_Description INTO NPD FROM DUAL; 22 SELECT 'Insert' INTO ACT FROM DUAL; 23 24 25 INSERT INTO productAudit 26 (Product_ID,Product_CategoryID,Product_Name,Product_Color,Product_Size,Pro duct_Weight,Product_Description, Action_Type) 27 SELECT NPID,NPCID, NPN, NPC,NPS,NPW,NPD, ACT FROM DUAL; 28 END productAudit_Inst_trigg; 29 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER productAudit_updt_trigg 2 AFTER update ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCID Integer; 7 NPN Varchar2(50); 8 NPC Varchar2(35); 9 NPS Varchar2(35); 10 NPW Varchar2(45); 11 NPD CLOB; 12 OPID Integer; 13 OPCID Integer; 14 OPN Varchar2(50); 15 OPC Varchar2(35); 16 OPS Varchar2(35); 17 OPW Varchar2(45); 18 OPD CLOB; 19 ACT Char(20); 20 21 BEGIN 22 SELECT :NEW.Product_ID INTO NPID FROM DUAL; 23 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 24 SELECT :NEW.Product_Name INTO NPN FROM DUAL; 25 SELECT :NEW.Product_Color INTO NPC FROM DUAL; 26 SELECT :NEW.Product_Size INTO NPS FROM DUAL; 27 SELECT :NEW.Product_Weight INTO NPW FROM DUAL; 28 SELECT :NEW.Product_Description INTO NPD FROM DUAL; 29 SELECT :OLD.Product_ID INTO OPID FROM DUAL; 30 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 31 SELECT :OLD.Product_Name INTO OPN FROM DUAL; 32 SELECT :OLD.Product_Color INTO OPC FROM DUAL; 33 SELECT :OLD.Product_Size INTO OPS FROM DUAL; 34 SELECT :OLD.Product_Weight INTO OPW FROM DUAL; 35 SELECT :OLD.Product_Description INTO OPD FROM DUAL; 36 SELECT 'Update' INTO ACT FROM DUAL; 37
  • 66. 65 38 39 INSERT INTO productAudit 40 (Product_ID,Product_CategoryID,Product_Name,Product_Color,Product_Size,Pro duct_Weight,Product_Description, 41 Old_ProductID,Old_ProdCategoryID,Old_ProdName,Old_ProdColor,Old_ProdSize,O ld_ProdWeight,Old_ProdDescription, 42 Action_Type) 43 SELECT NPID,NPCID, NPN, NPC,NPS,NPW,NPD, OPID,OPCID, OPN, OPC,OPS,OPW,OPD, 44 ACT FROM DUAL; 45 END productAudit_updt_trigg; 46 / Trigger created. SQL> set echo off; SQL> spool off; SQL> SQL> SQL> SQL> create or replace trigger PaymentCopAudit_auditdate_trgg 2 before insert on PaymentCopAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end PaymentCopAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> create or replace trigger PaymentCopAudit_audituser_trgg 2 before insert on PaymentCopAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end PaymentCopAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER PayCopAudit_del_trigg
  • 67. 66 2 AFTER DELETE ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 OPID Integer; 6 OPCNE Varchar2(50); 7 OPPT Varchar2(45); 8 OPCD Date; 9 OPST varchar2(25); 10 OPCN Integer; 11 OPCE Date; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :OLD.PAYMENT_ID INTO OPID FROM DUAL; 16 SELECT :OLD.PAYMENT_COPNAME INTO OPCNE FROM DUAL; 17 SELECT :OLD.PAYMENT_TYPE INTO OPPT FROM DUAL; 18 SELECT :OLD.PAYMENT_CREATEDDATE INTO OPCD FROM DUAL; 19 SELECT :OLD.PAYMENT_STATUS INTO OPST FROM DUAL; 20 SELECT :OLD.PAYMENTCARD_NUMBER INTO OPCN FROM DUAL; 21 SELECT :OLD.PAYMENT_EXPDATE INTO OPCE FROM DUAL; 22 SELECT 'Delete' INTO ACT From DUAL; 23 24 INSERT INTO PaymentCopAudit(Old_Payid,Old_PayCopName,old_PayType,Old_PayCreatedDate,Ol d_PayStatus,Old_PayCard_Number,OLD_PCARD_EXPDATE 25 , Action_Type) 26 SELECT OPID,OPCNE,OPPT,OPCD,OPST, OPCN,OPCE, ACT 27 28 FROM DUAL; 29 end PayCopAudit_del_trigg; 30 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER PayCopAudit_Inst_trigg 2 AFTER INSERT ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCNE Varchar2(50); 7 NPPT Varchar2(45); 8 NPCD Date; 9 NPST varchar2(25); 10 NPCN Integer; 11 NPCE Date; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :NEW.PAYMENT_ID INTO NPID FROM DUAL; 16 SELECT :NEW.PAYMENT_COPNAME INTO NPCNE FROM DUAL; 17 SELECT :NEW.PAYMENT_TYPE INTO NPPT FROM DUAL; 18 SELECT :NEW.PAYMENT_CREATEDDATE INTO NPCD FROM DUAL; 19 SELECT :NEW.PAYMENT_STATUS INTO NPST FROM DUAL;
  • 68. 67 20 SELECT :NEW.PAYMENTCARD_NUMBER INTO NPCN FROM DUAL; 21 SELECT :NEW.PAYMENT_EXPDATE INTO NPCE FROM DUAL; 22 SELECT 'Insert' INTO ACT From DUAL; 23 24 INSERT INTO PaymentCopAudit(Payment_id,Payment_CopName,Payment_Type,Payment_CreatedDat e,Payment_Status,PaymentCard_Number,PAYMENT_EXPDATE 25 , Action_Type) 26 SELECT NPID,NPCNE,NPPT,NPCD,NPST, NPCN,NPCE, ACT 27 28 FROM DUAL; 29 end PayCopAudit_Inst_trigg; 30 / Trigger created. SQL> SQL> CREATE OR REPLACE TRIGGER PayCopAudit_upd_trigg 2 AFTER UPDATE ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCNE Varchar2(50); 7 NPPT Varchar2(45); 8 NPCD Date; 9 NPST varchar2(25); 10 NPCN Integer; 11 NPCE Date; 12 OPID Integer; 13 OPCNE Varchar2(50); 14 OPPT Varchar2(45); 15 OPCD Date; 16 OPST varchar2(25); 17 OPCN Integer; 18 OPCE Date; 19 ACT Char(20); 20 21 BEGIN 22 SELECT :NEW.PAYMENT_ID INTO NPID FROM DUAL; 23 SELECT :NEW.PAYMENT_COPNAME INTO NPCNE FROM DUAL; 24 SELECT :NEW.PAYMENT_TYPE INTO NPPT FROM DUAL; 25 SELECT :NEW.PAYMENT_CREATEDDATE INTO NPCD FROM DUAL; 26 SELECT :NEW.PAYMENT_STATUS INTO NPST FROM DUAL; 27 SELECT :NEW.PAYMENTCARD_NUMBER INTO NPCN FROM DUAL; 28 SELECT :NEW.PAYMENT_EXPDATE INTO NPCE FROM DUAL; 29 SELECT :OLD.PAYMENT_ID INTO OPID FROM DUAL; 30 SELECT :OLD.PAYMENT_COPNAME INTO OPCNE FROM DUAL; 31 SELECT :OLD.PAYMENT_TYPE INTO OPPT FROM DUAL; 32 SELECT :OLD.PAYMENT_CREATEDDATE INTO OPCD FROM DUAL; 33 SELECT :OLD.PAYMENT_STATUS INTO OPST FROM DUAL; 34 SELECT :OLD.PAYMENTCARD_NUMBER INTO OPCN FROM DUAL; 35 SELECT :OLD.PAYMENT_EXPDATE INTO OPCE FROM DUAL; 36 SELECT 'Update' INTO ACT From DUAL; 37 38 INSERT INTO PaymentCopAudit(Payment_id,Payment_CopName,Payment_Type,Payment_CreatedDat e,Payment_Status,PaymentCard_Number,PAYMENT_EXPDATE ,
  • 69. 68 39 Old_Payid,Old_PayCopName,old_PayType,Old_PayCreatedDate,Old_PayStatus,Old_ PayCard_Number,OLD_PCARD_EXPDATE 40 , Action_Type) 41 SELECT NPID,NPCNE,NPPT,NPCD,NPST, NPCN,NPCE, OPID,OPCNE,OPPT,OPCD,OPST, OPCN,OPCE, ACT 42 43 FROM DUAL; 44 end PayCopAudit_upd_trigg; 45 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger ReceiptAudit_auditdate_trgg 2 before insert on ReceiptAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end ReceiptAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger ReceiptAudit_audituser_trgg 2 before insert on ReceiptAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end ReceiptAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ReceiptAudit_delt_trigg 2 AFTER DELETE ON Receipt 3 FOR EACH ROW 4 DECLARE 5 ORCIPD INTEGER; 6 OSTID INTEGER; 7 OEMPD INTEGER; 8 OCUID INTEGER; 9 OSTRID INTEGER; 10 ORPID INTEGER; 11 ORPTX DECIMAL(8,2); 12 OQT INTEGER; 13 OPID Integer; 14 ORFMT DECIMAL(8,2);
  • 70. 69 15 ORAMT DECIMAL(8,2); 16 ORIDT DATE; 17 ORPYID INTEGER; 18 ACT Char(20); 19 20 BEGIN 21 SELECT :OLD.RECEIPT_ID INTO ORCIPD FROM DUAL; 22 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 23 SELECT :OLD.EMPLOYEE_ID INTO OEMPD FROM DUAL; 24 SELECT :OLD.CUSTOMER_ID INTO OCUID FROM DUAL; 25 SELECT :OLD.STORE_ID INTO OSTRID FROM DUAL; 26 SELECT :OLD.PRODUCT_ID INTO ORPID FROM DUAL; 27 SELECT :OLD.RECEIPT_TAX INTO ORPTX FROM DUAL; 28 SELECT :OLD.QTY INTO OQT FROM DUAL; 29 SELECT :OLD.RECEIPT_FINALAMT INTO ORFMT FROM DUAL; 30 SELECT :OLD.RECEIPT_AMOUNT INTO ORAMT FROM DUAL; 31 SELECT :OLD.RECEIPT_DATE INTO ORIDT FROM DUAL; 32 SELECT :OLD.Payment_ID INTO ORPYID FROM DUAL; 33 SELECT 'Delete' INTO ACT From DUAL; 34 35 insert into ReceiptAudit 36 (OLD_RECEIPTID , OLD_STATEID ,OLD_EMPLOYEEID,OLD_CUSTOMERID,OLD_STOREID, OLD_PRODID , OLD_RECEPTTAX, 37 OLD_QTY, OLD_RECEIPTDATE, OLD_RECPTFINALAMT ,OLD_RECPTAMT,OLD_PAYMENTID, 38 Action_Type) 39 SELECT ORCIPD, OSTID, OEMPD, OCUID, OSTRID,ORPID,ORPTX, OQT, ORIDT, ORFMT, ORAMT, ORPYID,ACT 40 41 42 from dual; 43 44 45 end ReceiptAudit_delt_trigg; 46 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ReceiptAudit_inst_trigg 2 AFTER insert ON Receipt 3 FOR EACH ROW 4 DECLARE 5 NRCIPD INTEGER; 6 NSTID INTEGER; 7 NEMPD INTEGER; 8 NCUID INTEGER; 9 NSTRID INTEGER; 10 NRPID INTEGER; 11 NRPTX DECIMAL(8,2); 12 NQT INTEGER; 13 NPID Integer;
  • 71. 70 14 NRFMT DECIMAL(8,2); 15 NRAMT DECIMAL(8,2); 16 NRIDT DATE; 17 NRPYID INTEGER; 18 ACT Char(20); 19 20 BEGIN 21 SELECT :NEW.RECEIPT_ID INTO NRCIPD FROM DUAL; 22 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 23 SELECT :NEW.EMPLOYEE_ID INTO NEMPD FROM DUAL; 24 SELECT :NEW.CUSTOMER_ID INTO NCUID FROM DUAL; 25 SELECT :NEW.STORE_ID INTO NSTRID FROM DUAL; 26 SELECT :NEW.PRODUCT_ID INTO NRPID FROM DUAL; 27 SELECT :NEW.RECEIPT_TAX INTO NRPTX FROM DUAL; 28 SELECT :NEW.QTY INTO NQT FROM DUAL; 29 SELECT :NEW.RECEIPT_FINALAMT INTO NRFMT FROM DUAL; 30 SELECT :NEW.RECEIPT_AMOUNT INTO NRAMT FROM DUAL; 31 SELECT :NEW.RECEIPT_DATE INTO NRIDT FROM DUAL; 32 SELECT :NEW.Payment_ID INTO NRPYID FROM DUAL; 33 SELECT 'Insert' INTO ACT From DUAL; 34 35 insert into ReceiptAudit 36 (RECEIPT_ID , STATE_ID ,EMPLOYEE_ID,CUSTOMER_ID,STORE_ID, PRODUCT_ID , RECEIPT_TAX, 37 QTY, RECEIPT_DATE, RECEIPT_FINALAMT ,RECEIPT_AMOUNT,Payment_ID, 38 Action_Type) 39 SELECT NRCIPD, NSTID, NEMPD, NCUID, NSTRID,NRPID,NRPTX, NQT, NRIDT, NRFMT, NRAMT, NRPYID,ACT 40 41 42 from dual; 43 44 45 end ReceiptAudit_inst_trigg; 46 / Trigger created. SQL> SQL> SQL> SQL> CREATE OR REPLACE TRIGGER ReceiptAudit_updt_trigg 2 AFTER update ON Receipt 3 FOR EACH ROW 4 DECLARE 5 NRCIPD INTEGER; 6 NSTID INTEGER; 7 NEMPD INTEGER; 8 NCUID INTEGER; 9 NSTRID INTEGER; 10 NRPID INTEGER; 11 NRPTX DECIMAL(8,2); 12 NQT INTEGER; 13 NPID Integer; 14 NRFMT DECIMAL(8,2); 15 NRAMT DECIMAL(8,2); 16 NRIDT DATE;
  • 72. 71 17 NRPYID INTEGER; 18 ORCIPD INTEGER; 19 OSTID INTEGER; 20 OEMPD INTEGER; 21 OCUID INTEGER; 22 OSTRID INTEGER; 23 ORPID INTEGER; 24 ORPTX DECIMAL(8,2); 25 OQT INTEGER; 26 OPID Integer; 27 ORFMT DECIMAL(8,2); 28 ORAMT DECIMAL(8,2); 29 ORIDT DATE; 30 ORPYID INTEGER; 31 ACT Char(20); 32 33 BEGIN 34 SELECT :NEW.RECEIPT_ID INTO NRCIPD FROM DUAL; 35 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 36 SELECT :NEW.EMPLOYEE_ID INTO NEMPD FROM DUAL; 37 SELECT :NEW.CUSTOMER_ID INTO NCUID FROM DUAL; 38 SELECT :NEW.STORE_ID INTO NSTRID FROM DUAL; 39 SELECT :NEW.PRODUCT_ID INTO NRPID FROM DUAL; 40 SELECT :NEW.RECEIPT_TAX INTO NRPTX FROM DUAL; 41 SELECT :NEW.QTY INTO NQT FROM DUAL; 42 SELECT :NEW.RECEIPT_FINALAMT INTO NRFMT FROM DUAL; 43 SELECT :NEW.RECEIPT_AMOUNT INTO NRAMT FROM DUAL; 44 SELECT :NEW.RECEIPT_DATE INTO NRIDT FROM DUAL; 45 SELECT :NEW.Payment_ID INTO NRPYID FROM DUAL; 46 SELECT :OLD.RECEIPT_ID INTO ORCIPD FROM DUAL; 47 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 48 SELECT :OLD.EMPLOYEE_ID INTO OEMPD FROM DUAL; 49 SELECT :OLD.CUSTOMER_ID INTO OCUID FROM DUAL; 50 SELECT :OLD.STORE_ID INTO OSTRID FROM DUAL; 51 SELECT :OLD.PRODUCT_ID INTO ORPID FROM DUAL; 52 SELECT :OLD.RECEIPT_TAX INTO ORPTX FROM DUAL; 53 SELECT :OLD.QTY INTO OQT FROM DUAL; 54 SELECT :OLD.RECEIPT_FINALAMT INTO ORFMT FROM DUAL; 55 SELECT :OLD.RECEIPT_AMOUNT INTO ORAMT FROM DUAL; 56 SELECT :OLD.RECEIPT_DATE INTO ORIDT FROM DUAL; 57 SELECT :OLD.Payment_ID INTO ORPYID FROM DUAL; 58 SELECT 'Update' INTO ACT From DUAL; 59 60 insert into ReceiptAudit 61 (RECEIPT_ID , STATE_ID ,EMPLOYEE_ID,CUSTOMER_ID,STORE_ID, PRODUCT_ID , RECEIPT_TAX, 62 QTY, RECEIPT_DATE, RECEIPT_FINALAMT ,RECEIPT_AMOUNT,Payment_ID, 63 OLD_RECEIPTID , OLD_STATEID ,OLD_EMPLOYEEID,OLD_CUSTOMERID,OLD_STOREID, OLD_PRODID , OLD_RECEPTTAX, 64 OLD_QTY, OLD_RECEIPTDATE, OLD_RECPTFINALAMT ,OLD_RECPTAMT,OLD_PAYMENTID, 65 Action_Type) 66 SELECT NRCIPD, NSTID, NEMPD, NCUID, NSTRID,NRPID,NRPTX, NQT, NRIDT, NRFMT, NRAMT, NRPYID, 67 ORCIPD, OSTID, OEMPD, OCUID, OSTRID,ORPID,ORPTX, OQT, ORIDT, ORFMT, ORAMT, ORPYID, 68 ACT
  • 73. 72 69 70 71 from dual; 72 73 74 end ReceiptAudit_updt_trigg; 75 / Trigger created. SQL> SQL> SQL> SQL> SQL> create or replace trigger shippingcoAudit_auditdate_trgg 2 before insert on shippingcoAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end shippingcoAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger shippingcoAudit_audituser_trgg 2 before insert on shippingcoAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end shippingcoAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> create or replace trigger shipcoAudit_del_trigg 2 after delete on shippingco 3 for each row 4 DECLARE 5 OSID integer; 6 OSNM Varchar2(50); 7 OSTU char(25); 8 OCRDT date; 9 ACT CHAR(20); 10 BEGIN 11 SELECT :OLD.SHIPPER_ID INTO OSID FROM DUAL; 12 SELECT :OLD.SHIPPER_NAME INTO OSNM FROM DUAL; 13 SELECT :OLD.STATUS INTO OSTU FROM DUAL; 14 SELECT :OLD.CREATE_DATE INTO OCRDT FROM DUAL; 15 SELECT 'Delete' INTO ACT FROM DUAL; 16
  • 74. 73 17 INSERT INTO shippingcoAudit(Old_shipperid,old_ShipperName,old_status,old_Create_date,A ction_Type) 18 SELECT OSID, OSNM, OSTU, OCRDT, ACT FROM DUAL; 19 END shipcoAudit_del_trigg; 20 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger shipcoAudit_inst_trigg 2 after insert on shippingco 3 for each row 4 DECLARE 5 NSID integer; 6 NSNM Varchar2(50); 7 NSTU char(25); 8 NCRDT date; 9 ACT CHAR(20); 10 BEGIN 11 SELECT :NEW.SHIPPER_ID INTO NSID FROM DUAL; 12 SELECT :NEW.SHIPPER_NAME INTO NSNM FROM DUAL; 13 SELECT :NEW.STATUS INTO NSTU FROM DUAL; 14 SELECT :NEW.CREATE_DATE INTO NCRDT FROM DUAL; 15 SELECT 'Insert' INTO ACT FROM DUAL; 16 17 INSERT INTO shippingcoAudit(SHIPPER_ID,SHIPPER_NAME,STATUS,CREATE_DATE,Action_Type) 18 SELECT NSID, NSNM, NSTU, NCRDT, ACT FROM DUAL; 19 END shipcoAudit_inst_trigg; 20 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger shipcoAudit_updt_trigg 2 after update on shippingco 3 for each row 4 DECLARE 5 NSID integer; 6 NSNM Varchar2(50); 7 NSTU char(25); 8 NCRDT date; 9 OSID integer; 10 OSNM Varchar2(50); 11 OSTU char(25); 12 OCRDT date; 13 ACT CHAR(20); 14 BEGIN 15 SELECT :NEW.SHIPPER_ID INTO NSID FROM DUAL; 16 SELECT :NEW.SHIPPER_NAME INTO NSNM FROM DUAL;
  • 75. 74 17 SELECT :NEW.STATUS INTO NSTU FROM DUAL; 18 SELECT :NEW.CREATE_DATE INTO NCRDT FROM DUAL; 19 SELECT 'Update' INTO ACT FROM DUAL; 20 SELECT :OLD.SHIPPER_ID INTO OSID FROM DUAL; 21 SELECT :OLD.SHIPPER_NAME INTO OSNM FROM DUAL; 22 SELECT :OLD.STATUS INTO OSTU FROM DUAL; 23 SELECT :OLD.CREATE_DATE INTO OCRDT FROM DUAL; 24 INSERT INTO shippingcoAudit(SHIPPER_ID,SHIPPER_NAME,STATUS,CREATE_DATE, 25 Old_shipperid,old_ShipperName,old_status,old_Create_date, 26 Action_Type) 27 SELECT NSID, NSNM, NSTU, NCRDT, OSID, OSNM, OSTU, OCRDT, 28 ACT FROM DUAL; 29 END shipcoAudit_updt_trigg; 30 / Trigger created. SQL> SQL> create or replace trigger shippmentAudit_auditdate_trgg 2 before insert on shipmentaudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end shippmentAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_audituser_trgg 2 before insert on shipmentaudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end shippmentAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_del_trigg 2 after delete on shipment 3 for each row 4 DECLARE 5 6 OLSHIPID NUMBER(38); 7 OSHIPPERID NUMBER(38);
  • 76. 75 8 OSTID NUMBER(38); 9 ORPID NUMBER(38); 10 OSHIPDATE DATE; 11 OSHIPENDDATE DATE; 12 ORVEDATE DATE; 13 ONAME VARCHAR2(55); 14 OADSS VARCHAR2(55) ; 15 OCIT VARCHAR2(55) ; 16 OLDSHIPPINGAMT NUMBER(38); 17 OSHIPPINGTYPE CHAR(35) ; 18 ACT CHAR(20); 19 20 begin 21 22 SELECT :OLD.SHIPPING_ID INTO OLSHIPID FROM DUAL; 23 SELECT :OLD.SHIPPER_ID INTO OSHIPPERID FROM DUAL; 24 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 25 SELECT :OLD.RECEIPT_ID INTO ORPID FROM DUAL; 26 SELECT :OLD.SHIP_DATE INTO OSHIPDATE FROM DUAL; 27 SELECT :OLD.SHIP_ENDDATE INTO OSHIPENDDATE FROM DUAL; 28 SELECT :OLD.RECEIVE_DATE INTO ORVEDATE FROM DUAL; 29 SELECT :OLD.NAME INTO ONAME FROM DUAL; 30 SELECT :OLD.ADDRESS INTO OADSS FROM DUAL; 31 SELECT :OLD.CITY INTO OCIT FROM DUAL; 32 SELECT :OLD.SHIPPING_AMOUNT INTO OLDSHIPPINGAMT FROM DUAL; 33 SELECT :OLD.SHIPPING_TYPE INTO OSHIPPINGTYPE FROM DUAL; 34 SELECT 'Delete' INTO ACT From Dual; 35 36 37 insert into shipmentaudit 38 (old_shippingid,old_shipperid, old_stateid, old_ReceiptID, old_shipdate ,old_shipenddate, old_receivedate, 39 old_Name, old_Address, old_City, old_shippingamt,old_shippingtype,Action_Type) 40 select OLSHIPID, OSHIPPERID, OSTID, ORPID, OSHIPDATE, OSHIPENDDATE,ORVEDATE,ONAME, OADSS, OCIT,OLDSHIPPINGAMT, 41 OSHIPPINGTYPE, ACT 42 from dual; 43 end shippmentAudit_del_trigg; 44 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_inst_trigg 2 after insert on shipment 3 for each row 4 DECLARE 5 6 NLSHIPID NUMBER(38); 7 NSHIPPERID NUMBER(38); 8 NSTID NUMBER(38);
  • 77. 76 9 NRPID NUMBER(38); 10 NSHIPDATE DATE; 11 NSHIPENDDATE DATE; 12 NRVEDATE DATE; 13 NNAME VARCHAR2(55); 14 NADSS VARCHAR2(55) ; 15 NCIT VARCHAR2(55) ; 16 NLDSHIPPINGAMT NUMBER(38); 17 NSHIPPINGTYPE CHAR(35) ; 18 ACT CHAR(20); 19 20 begin 21 22 SELECT :NEW.SHIPPING_ID INTO NLSHIPID FROM DUAL; 23 SELECT :NEW.SHIPPER_ID INTO NSHIPPERID FROM DUAL; 24 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 25 SELECT :NEW.RECEIPT_ID INTO NRPID FROM DUAL; 26 SELECT :NEW.SHIP_DATE INTO NSHIPDATE FROM DUAL; 27 SELECT :NEW.SHIP_ENDDATE INTO NSHIPENDDATE FROM DUAL; 28 SELECT :NEW.RECEIVE_DATE INTO NRVEDATE FROM DUAL; 29 SELECT :NEW.NAME INTO NNAME FROM DUAL; 30 SELECT :NEW.ADDRESS INTO NADSS FROM DUAL; 31 SELECT :NEW.CITY INTO NCIT FROM DUAL; 32 SELECT :NEW.SHIPPING_AMOUNT INTO NLDSHIPPINGAMT FROM DUAL; 33 SELECT :NEW.SHIPPING_TYPE INTO NSHIPPINGTYPE FROM DUAL; 34 SELECT 'Insert' INTO ACT From Dual; 35 36 37 insert into shipmentaudit 38 (SHIPPING_ID,SHIPPER_ID, STATE_ID, RECEIPT_ID, SHIP_DATE ,SHIP_ENDDATE, RECEIVE_DATE, 39 NAME, ADDRESS, CITY, SHIPPING_AMOUNT,SHIPPING_TYPE,Action_Type) 40 select NLSHIPID, NSHIPPERID, NSTID, NRPID, NSHIPDATE, NSHIPENDDATE,NRVEDATE,NNAME, NADSS, NCIT,NLDSHIPPINGAMT, 41 NSHIPPINGTYPE, ACT 42 from dual; 43 end shippmentAudit_inst_trigg; 44 / Trigger created. SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_upt_trigg 2 after insert on shipment 3 for each row 4 DECLARE 5 6 NLSHIPID NUMBER(38); 7 NSHIPPERID NUMBER(38); 8 NSTID NUMBER(38);
  • 78. 77 9 NRPID NUMBER(38); 10 NSHIPDATE DATE; 11 NSHIPENDDATE DATE; 12 NRVEDATE DATE; 13 NNAME VARCHAR2(55); 14 NADSS VARCHAR2(55) ; 15 NCIT VARCHAR2(55) ; 16 NLDSHIPPINGAMT NUMBER(38); 17 NSHIPPINGTYPE CHAR(35) ; 18 OLSHIPID NUMBER(38); 19 OSHIPPERID NUMBER(38); 20 OSTID NUMBER(38); 21 ORPID NUMBER(38); 22 OSHIPDATE DATE; 23 OSHIPENDDATE DATE; 24 ORVEDATE DATE; 25 ONAME VARCHAR2(55); 26 OADSS VARCHAR2(55) ; 27 OCIT VARCHAR2(55) ; 28 OLDSHIPPINGAMT NUMBER(38); 29 OSHIPPINGTYPE CHAR(35) ; 30 ACT CHAR(20); 31 32 begin 33 34 SELECT :NEW.SHIPPING_ID INTO NLSHIPID FROM DUAL; 35 SELECT :NEW.SHIPPER_ID INTO NSHIPPERID FROM DUAL; 36 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 37 SELECT :NEW.RECEIPT_ID INTO NRPID FROM DUAL; 38 SELECT :NEW.SHIP_DATE INTO NSHIPDATE FROM DUAL; 39 SELECT :NEW.SHIP_ENDDATE INTO NSHIPENDDATE FROM DUAL; 40 SELECT :NEW.RECEIVE_DATE INTO NRVEDATE FROM DUAL; 41 SELECT :NEW.NAME INTO NNAME FROM DUAL; 42 SELECT :NEW.ADDRESS INTO NADSS FROM DUAL; 43 SELECT :NEW.CITY INTO NCIT FROM DUAL; 44 SELECT :NEW.SHIPPING_AMOUNT INTO NLDSHIPPINGAMT FROM DUAL; 45 SELECT :NEW.SHIPPING_TYPE INTO NSHIPPINGTYPE FROM DUAL; 46 47 SELECT :OLD.SHIPPING_ID INTO OLSHIPID FROM DUAL; 48 SELECT :OLD.SHIPPER_ID INTO OSHIPPERID FROM DUAL; 49 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 50 SELECT :OLD.RECEIPT_ID INTO ORPID FROM DUAL; 51 SELECT :OLD.SHIP_DATE INTO OSHIPDATE FROM DUAL; 52 SELECT :OLD.SHIP_ENDDATE INTO OSHIPENDDATE FROM DUAL; 53 SELECT :OLD.RECEIVE_DATE INTO ORVEDATE FROM DUAL; 54 SELECT :OLD.NAME INTO ONAME FROM DUAL; 55 SELECT :OLD.ADDRESS INTO OADSS FROM DUAL; 56 SELECT :OLD.CITY INTO OCIT FROM DUAL; 57 SELECT :OLD.SHIPPING_AMOUNT INTO OLDSHIPPINGAMT FROM DUAL; 58 SELECT :OLD.SHIPPING_TYPE INTO OSHIPPINGTYPE FROM DUAL; 59 60 61 62 SELECT 'Update' INTO ACT From Dual; 63 64 65 insert into shipmentaudit
  • 79. 78 66 (SHIPPING_ID,SHIPPER_ID, STATE_ID, RECEIPT_ID, SHIP_DATE ,SHIP_ENDDATE, RECEIVE_DATE, 67 NAME, ADDRESS, CITY, SHIPPING_AMOUNT,SHIPPING_TYPE,old_shippingid,old_shipperid, old_stateid, old_ReceiptID, 68 old_shipdate ,old_shipenddate, old_receivedate, 69 old_Name, old_Address, old_City, old_shippingamt,old_shippingtype, 70 Action_Type) 71 select NLSHIPID, NSHIPPERID, NSTID, NRPID, NSHIPDATE, NSHIPENDDATE,NRVEDATE,NNAME, NADSS, NCIT,NLDSHIPPINGAMT, 72 NSHIPPINGTYPE,OLSHIPID, OSHIPPERID, OSTID, ORPID, OSHIPDATE, OSHIPENDDATE,ORVEDATE,ONAME, OADSS, 73 OCIT,OLDSHIPPINGAMT,OSHIPPINGTYPE,ACT 74 from dual; 75 end shippmentAudit_upt_trigg; 76 / Trigger created. SQL> set echo off SQL> spool off;
  • 80. 79 Database Altration
  • 81. 80
  • 82. 81
  • 83. 82
  • 84. 83
  • 85. 84
  • 86. 85 SQL> Alter table receipt 2 drop primary key; Table altered. SQL> Alter table receipt 2 drop constraint Receipt_Receiptid_uk cascade; Table altered. SQL> Alter table receipt drop column state_id; Table altered. SQL> Alter table receipt drop column payment_id; Table altered. SQL> Alter table receipt drop constraint Receipt_customerid_fk ; Table altered. SQL> Alter table receipt drop constraint Receipt_storeid_fk ; Table altered. SQL> Alter table receipt drop constraint Receipt_Productid_fk ; Table altered. SQL> SQL> SQL> SQL> SQL> Alter table receipt 2 modify receipt_finalamt constraint receipt_repfinamt_nn not null 3 modify receipt_amount constraint receipt_repamount_nn not null; Table altered. SQL> SQL> SQL> SQL> Alter table receipt 2 add constraint Receipt_Receipid_pk primary key(Receipt_ID,Employee_ID,Customer_ID,Store_ID 3 ,Product_ID); Table altered.
  • 87. 86 SQL> Alter table receipt 2 drop constraint Receipt_Receipid_pk; Table altered. SQL> alter table receipt 2 add constraint receipt_receiptid_pk primary key(receipt_id, employee_id, customer_id, product_id, store_id); Table altered. SQL> SQL> alter table receipt 2 add constraint receipt_receiptid_uk unique (receipt_id); Table altered. SQL> SQL> SQL> SQL> alter table receipt 2 add constraint Receipt_customerid_fk foreign key(Customer_ID) references Customer(Customer_ID); Table altered. SQL> Alter table receipt 2 drop constraint Receipt_Employeeid_fk; Table altered. SQL> alter table receipt 2 add constraint Receipt_Employeeid_fk foreign key(Employee_ID) references Employee (Employee_ID); Table altered. SQL> alter table receipt 2 add constraint Receipt_storeid_fk foreign key(Store_id) references store(Store_id); Table altered. SQL> SQL> alter table receipt 2 add constraint Receipt_Productid_fk foreign key(Product_ID) references Product (Product_ID); Table altered. SQL> SQL> alter table receipt drop constraint receipt_repfinamt_nn; Table altered.
  • 88. 87 SQL> alter table receipt drop constraint receipt_ReceiptTax_nn; Table altered. SQL> commit; Commit complete. SQL> alter table receiptaudit drop column state_id; Table altered. SQL> alter table receiptaudit drop column old_stateid; Table altered. SQL> alter table receiptaudit drop column old_paymentid; Table altered. SQL> alter table receiptaudit drop column payment_id; Table altered. SQL> ALTER TABLE PAYMENTCOP 2 ADD RECEIPT_ID INTEGER; Table altered. SQL> ALTER TABLE PAYMENTCOP 2 ADD Authorized_Amt decimal(8,2); Table altered. SQL> Alter table PaymentCop 2 modify payment_createddate constraint paymentcop_createdate_nn not null 3 modify payment_status constraint paymentcop_paymentstatus_nn not null 4 modify payment_expdate constraint paymentcop_payexpdate_nn not null; Table altered. SQL> Alter table PAYMENTCOP 2 drop constraint PaymentCop_paymentid_pk; Table altered. SQL> ALTER TABLE PAYMENTCOP 2 ADD CONSTRAINT PAYMENTCOP_PAYMENTID_PK PRIMARY KEY(PAYMENT_ID, RECEIPT_ID);
  • 89. 88 Table altered. SQL> ALTER TABLE PAYMENTCOP 2 ADD CONSTRAINT PAYMENTCOP_PAYMENTID_UK UNIQUE(PAYMENT_ID); Table altered. SQL> ALTER TABLE PAYMENTCOP 2 ADD CONSTRAINT PAYMENTCOP_RECEIPTID_FK FOREIGN KEY(RECEIPT_ID) REFERENCES RECEIPT(RECEIPT_ID); Table altered. SQL> Alter table PaymentCop 2 modify Authorized_Amt constraint paymentcop_authorizedamt_nn not null; Table altered. SQL> alter table paymentcopaudit add receipt_id integer 2 ; Table altered. SQL> alter table paymentcopaudit add old_receiptid integer; Table altered. SQL> alter table paymentcopaudit add authorized_amt decimal(8,2); Table altered. SQL> alter table paymentcopaudit add Old_AuthorizedAmt decimal(8,2); Table altered. SQL> commit; Commit complete. SQL> drop table shipment; SQL> create table shipment 2 (shipping_id integer GENERATED ALWAYS AS IDENTITY 3 (START WITH 0235 INCREMENT BY 26), 4 shipper_id integer , 5 state_id integer , 6 Receipt_ID integer , 7 ship_date date, 8 ship_enddate date, 9 receive_date date,
  • 90. 89 10 Name varchar2(55), 11 Address varchar2(55), 12 City varchar2(55), 13 shipping_amount numeric, 14 shipping_type char(35), 15 constraint shipment_shipmentid_pk primary key(shipping_id,shipper_id,RECEIPT_ID ), 16 constraint shipment_shipermid_uk unique (shipping_id), 17 constraint shipment_shipperid_fk foreign key(shipper_id) references shippingco(shipper_id), 18 CONSTRAINT SHIPMENT_RECEIPTID_FK FOREIGN KEY(RECEIPT_ID) REFERENCES RECEIPT(RECEIPT_ID) 19 ); Table created. SQL> SQL> alter table shipment 2 modify Name constraint shipment_shipname_nn not null 3 modify Address constraint shipment_address_nn not null 4 modify city constraint shipment_city_nn not null 5 modify shipping_amount constraint shipment_shipamount_nn not null 6 modify shipping_type constraint shipment_shippingtype_nn not null; Table altered. SQL> spool off; SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_del_trigg 2 AFTER DELETE ON Management 3 for each row 4 DECLARE 5 OMID Integer; 6 OEMP Integer; 7 OHD DATE; 8 OEND DATE; 9 OSTID integer; 10 ACT char(20); 11 BEGIN 12 13 SELECT :OLD.Manager_ID INTO OMID FROM DUAL; 14 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 15 SELECT :OLD.Hire_Date INTO OHD FROM DUAL; 16 SELECT :OLD.Hire_EndDate INTO OEND FROM DUAL; 17 SELECT 'Delete' INTO ACT FROM DUAL; 18 SELECT :OLD.STORE_ID INTO OSTID FROM DUAL; 19 20 INSERT INTO ManagementAudit(Old_ManagerID,Old_EmployeeID ,Old_HireDate, Old_HireEndDate ,Action_Type, old_storeid) 21 SELECT OMID, OEMP, OHD,OEND,ACT, OSTID 22 FROM DUAL; 23 24 25 end ManagementAuditt_del_trigg; 26 /
  • 91. 90 Trigger created. SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_inst_trigg 2 AFTER INSERT ON Management 3 for each row 4 DECLARE 5 NMID Integer; 6 NEMP Integer; 7 NHD DATE; 8 NEND DATE; 9 ACT char(20); 10 NTSID Integer; 11 BEGIN 12 13 SELECT :NEW.Manager_ID INTO NMID FROM DUAL; 14 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 15 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 16 SELECT :NEW.Hire_EndDate INTO NEND FROM DUAL; 17 SELECT 'Insert' INTO ACT FROM DUAL; 18 SELECT :NEW.STORE_ID INTO NTSID from DUAL; 19 20 INSERT INTO ManagementAudit(Manager_ID,Employee_ID ,Hire_Date, Hire_EndDate ,Action_Type, Store_ID) 21 SELECT NMID, NEMP, NHD,NEND,ACT, NTSID FROM DUAL; 22 23 24 end ManagementAuditt_inst_trigg; 25 / Trigger created. SQL> SQL> CREATE OR REPLACE TRIGGER ManagementAuditt_updt_trigg 2 AFTER UPDATE ON Management 3 for each row 4 DECLARE 5 NMID Integer; 6 NEMP Integer; 7 NHD DATE; 8 NEND DATE; 9 OMID Integer; 10 OEMP Integer; 11 OHD DATE; 12 OEND DATE; 13 ACT char(20); 14 OSTID integer; 15 NTSID Integer; 16 BEGIN 17 18 SELECT :NEW.Manager_ID INTO NMID FROM DUAL; 19 SELECT :NEW.Employee_ID INTO NEMP FROM DUAL; 20 SELECT :NEW.Hire_Date INTO NHD FROM DUAL; 21 SELECT :NEW.Hire_EndDate INTO NEND FROM DUAL; 22 SELECT :OLD.Manager_ID INTO OMID FROM DUAL; 23 SELECT :OLD.Employee_ID INTO OEMP FROM DUAL; 24 SELECT :OLD.Hire_Date INTO OHD FROM DUAL;
  • 92. 91 25 SELECT :OLD.Hire_EndDate INTO OEND FROM DUAL; 26 SELECT 'Update' INTO ACT FROM DUAL; 27 SELECT :OLD.STORE_ID INTO OSTID FROM DUAL; 28 SELECT :NEW.STORE_ID INTO NTSID from DUAL; 29 30 INSERT INTO ManagementAudit(Manager_ID,Employee_ID ,Hire_Date, Hire_EndDate ,Old_ManagerID,Old_EmployeeID ,Old_HireDate, Old_HireEndDate, 31 Action_Type, Store_ID, old_storeid ) 32 SELECT NMID, NEMP, NHD,NEND,OMID, OEMP, OHD,OEND,ACT , NTSID, OSTID 33 FROM DUAL; 34 35 end ManagementAuditt_updt_trigg; 36 37 / Trigger created. SQL> CREATE OR REPLACE TRIGGER storeAudit_del_trigg 2 AFTER DELETE ON STORE 3 FOR EACH ROW 4 DECLARE 5 OSTID Integer; 6 OSSTID Integer; 7 8 OSTN Varchar2(65); 9 OSTY Varchar2(34); 10 OSTA Varchar2(65); 11 OSTC Varchar2(45); 12 OSP Varchar2(45); 13 OSTS Varchar2(30); 14 ACT char(20); 15 BEGIN 16 SELECT :OLD.Store_ID INTO OSTID FROM DUAL; 17 SELECT :OLD.Store_StateID INTO OSSTID FROM DUAL; 18 SELECT :OLD.Store_Name INTO OSTN FROM DUAL; 19 SELECT :OLD.Store_Type INTO OSTY FROM DUAL; 20 SELECT :OLD.Store_Address INTO OSTA FROM DUAL; 21 SELECT :OLD.Store_City INTO OSTC FROM DUAL; 22 SELECT :OLD.Store_Phone INTO OSP FROM DUAL; 23 SELECT :OLD.Store_Status INTO OSTS FROM DUAL; 24 SELECT 'Delete' INTO ACT FROM DUAL; 25 26 27 28 insert into storeAudit(Old_StoreID,Old_StorStateID,Old_StorName,Old_StorType,Old_StorA ddress,Old_StorCity,old_StorPhone,old_StorStatus, Action_Type) 29 select OSTID, OSSTID, OSTN, OSTY,OSTA,OSTC,OSP,OSTS, ACT FROM DUAL; 30 end storeAudit_del_trigg; 31 / Trigger created. SQL> CREATE OR REPLACE TRIGGER storeAudit_inst_trigg 2 AFTER INSERT ON STORE
  • 93. 92 3 FOR EACH ROW 4 DECLARE 5 NSTID Integer; 6 NSSTID Integer; 7 NSTN Varchar2(65); 8 NSTY Varchar2(34); 9 NSTA Varchar2(65); 10 NSTC Varchar2(45); 11 NSP Varchar2(45); 12 NSTS Varchar2(30); 13 ACT char(20); 14 BEGIN 15 SELECT :NEW.Store_ID INTO NSTID FROM DUAL; 16 SELECT :NEW.Store_StateID INTO NSSTID FROM DUAL; 17 SELECT :NEW.Store_Name INTO NSTN FROM DUAL; 18 SELECT :NEW.Store_Type INTO NSTY FROM DUAL; 19 SELECT :NEW.Store_Address INTO NSTA FROM DUAL; 20 SELECT :NEW.Store_City INTO NSTC FROM DUAL; 21 SELECT :NEW.Store_Phone INTO NSP FROM DUAL; 22 SELECT :NEW.Store_Status INTO NSTS FROM DUAL; 23 SELECT 'Insert' INTO ACT FROM DUAL; 24 25 26 27 insert into storeAudit(Store_ID,Store_StateID,Store_Name,Store_Type,Store_Address,Stor e_City,Store_Phone,Store_Status, Action_Type) 28 select NSTID, NSSTID, NSTN, NSTY,NSTA,NSTC,NSP,NSTS, ACT FROM DUAL; 29 end storeAudit_del_trigg; 30 / Trigger created. SQL> CREATE OR REPLACE TRIGGER storeAudit_upd_trigg 2 AFTER update ON STORE 3 FOR EACH ROW 4 DECLARE 5 NSTID Integer; 6 NSSTID Integer; 7 NSTN Varchar2(65); 8 NSTY Varchar2(34); 9 NSTA Varchar2(65); 10 NSTC Varchar2(45); 11 NSP Varchar2(45); 12 NSTS Varchar2(30); 13 OSTID Integer; 14 OSSTID Integer; 15 OSTN Varchar2(65); 16 OSTY Varchar2(34); 17 OSTA Varchar2(65); 18 OSTC Varchar2(45); 19 OSP Varchar2(45); 20 OSTS Varchar2(30); 21 ACT char(20); 22 BEGIN 23 SELECT :NEW.Store_ID INTO NSTID FROM DUAL;
  • 94. 93 24 SELECT :NEW.Store_StateID INTO NSSTID FROM DUAL; 25 SELECT :NEW.Store_Name INTO NSTN FROM DUAL; 26 SELECT :NEW.Store_Type INTO NSTY FROM DUAL; 27 SELECT :NEW.Store_Address INTO NSTA FROM DUAL; 28 SELECT :NEW.Store_City INTO NSTC FROM DUAL; 29 SELECT :NEW.Store_Phone INTO NSP FROM DUAL; 30 SELECT :NEW.Store_Status INTO NSTS FROM DUAL; 31 SELECT :OLD.Store_ID INTO OSTID FROM DUAL; 32 SELECT :OLD.Store_StateID INTO OSSTID FROM DUAL; 33 SELECT :OLD.Store_Name INTO OSTN FROM DUAL; 34 SELECT :OLD.Store_Type INTO OSTY FROM DUAL; 35 SELECT :OLD.Store_Address INTO OSTA FROM DUAL; 36 SELECT :OLD.Store_City INTO OSTC FROM DUAL; 37 SELECT :OLD.Store_Phone INTO OSP FROM DUAL; 38 SELECT :OLD.Store_Status INTO OSTS FROM DUAL; 39 SELECT 'Update' INTO ACT FROM DUAL; 40 41 insert into storeAudit(Store_ID,Store_StateID,Store_Name,Store_Type,Store_Address,Stor e_City,Store_Phone,Store_Status, 42 Old_StoreID,Old_StorStateID,Old_StorName,Old_StorType,Old_StorAddress,Old_ StorCity,old_StorPhone,old_StorStatus, 43 Action_Type) 44 select NSTID, NSSTID, NSTN, NSTY,NSTA,NSTC,NSP,NSTS, OSTID, OSSTID, OSTN, OSTY,OSTA,OSTC,OSP,OSTS, ACT FROM DUAL; 45 end storeAudit_upd_trigg; 46 / Trigger created. SQL> commit; Commit complete. SQL> set echo off; SQL> spool off; create or replace trigger PaymentCopAudit_auditdate_trgg 2 before insert on PaymentCopAudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end PaymentCopAudit_auditdate_trgg; 7 / Trigger created. SQL> SQL> SQL> create or replace trigger PaymentCopAudit_audituser_trgg 2 before insert on PaymentCopAudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end PaymentCopAudit_audituser_trgg;
  • 95. 94 7 / Trigger created. SQL> create or replace TRIGGER PayCopAudit_del_trigg 2 AFTER DELETE ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 OPID Integer; 6 OPCNE Varchar2(50); 7 OPPT Varchar2(45); 8 OPCD Date; 9 OPST varchar2(25); 10 OPCN Integer; 11 OPCE Date; 12 ACT Char(20); 13 ORID INTEGER; 14 OAUT DECIMAL (8,2); 15 16 17 BEGIN 18 SELECT :OLD.PAYMENT_ID INTO OPID FROM DUAL; 19 SELECT :OLD.PAYMENT_COPNAME INTO OPCNE FROM DUAL; 20 SELECT :OLD.PAYMENT_TYPE INTO OPPT FROM DUAL; 21 SELECT :OLD.PAYMENT_CREATEDDATE INTO OPCD FROM DUAL; 22 SELECT :OLD.PAYMENT_STATUS INTO OPST FROM DUAL; 23 SELECT :OLD.PAYMENTCARD_NUMBER INTO OPCN FROM DUAL; 24 SELECT :OLD.PAYMENT_EXPDATE INTO OPCE FROM DUAL; 25 SELECT :OLD.Receipt_id INTO ORID FROM DUAL; 26 SELECT :OLD.Authorized_Amount INTO OAUT FROM DUAL; 27 28 SELECT 'Delete' INTO ACT From DUAL; 29 30 INSERT INTO PaymentCopAudit(Old_Payid,Old_PayCopName,old_PayType,Old_PayCreatedDate,Ol d_PayStatus,Old_PayCard_Number,OLD_PCARD_EXPDATE, OLD_RECEIPTID,OLD_AUTHAMT, ACTION_TYPE 31 ) 32 SELECT OPID,OPCNE,OPPT,OPCD,OPST, OPCN,OPCE, ORID, OAUT,ACT 33 34 35 36 FROM DUAL; 37 38 end PayCopAudit_del_trigg; 39 / Trigger created. SQL> SQL> create or replace TRIGGER PayCopAudit_updt_trigg 2 AFTER update ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCNE Varchar2(50); 7 NPPT Varchar2(45);
  • 96. 95 8 NPCD Date; 9 NPST varchar2(25); 10 NPCN Integer; 11 NPCE Date; 12 ACT Char(20); 13 NRID INTEGER; 14 NAUT DECIMAL (8,2); 15 OPID Integer; 16 OPCNE Varchar2(50); 17 OPPT Varchar2(45); 18 OPCD Date; 19 OPST varchar2(25); 20 OPCN Integer; 21 OPCE Date; 22 ORID INTEGER; 23 OAUT DECIMAL (8,2); 24 25 BEGIN 26 SELECT :NEW.PAYMENT_ID INTO NPID FROM DUAL; 27 SELECT :NEW.PAYMENT_COPNAME INTO NPCNE FROM DUAL; 28 SELECT :NEW.PAYMENT_TYPE INTO NPPT FROM DUAL; 29 SELECT :NEW.PAYMENT_CREATEDDATE INTO NPCD FROM DUAL; 30 SELECT :NEW.PAYMENT_STATUS INTO NPST FROM DUAL; 31 SELECT :NEW.PAYMENTCARD_NUMBER INTO NPCN FROM DUAL; 32 SELECT :NEW.PAYMENT_EXPDATE INTO NPCE FROM DUAL; 33 SELECT :NEW.Receipt_id INTO NRID FROM DUAL; 34 SELECT :NEW.Authorized_Amount INTO NAUT FROM DUAL; 35 SELECT :OLD.PAYMENT_ID INTO OPID FROM DUAL; 36 SELECT :OLD.PAYMENT_COPNAME INTO OPCNE FROM DUAL; 37 SELECT :OLD.PAYMENT_TYPE INTO OPPT FROM DUAL; 38 SELECT :OLD.PAYMENT_CREATEDDATE INTO OPCD FROM DUAL; 39 SELECT :OLD.PAYMENT_STATUS INTO OPST FROM DUAL; 40 SELECT :OLD.PAYMENTCARD_NUMBER INTO OPCN FROM DUAL; 41 SELECT :OLD.PAYMENT_EXPDATE INTO OPCE FROM DUAL; 42 SELECT :OLD.Receipt_id INTO ORID FROM DUAL; 43 SELECT :OLD.Authorized_Amount INTO OAUT FROM DUAL; 44 SELECT 'update' INTO ACT From DUAL; 45 46 INSERT INTO PaymentCopAudit(PAYMENT_ID,PAYMENT_COPNAME,PAYMENT_TYPE,PAYMENT_CREATEDDAT E,PAYMENT_STATUS,PAYMENTCARD_NUMBER,PAYMENT_EXPDATE, Receipt_id,Authorized_AmT, ACTION_TYPE, 47 Old_Payid,Old_PayCopName,old_PayType,Old_PayCreatedDate,Old_PayStatus,Old_ PayCard_Number,OLD_PCARD_EXPDATE, OLD_RECEIPTID,OLD_AUTHAMT 48 49 ) 50 SELECT NPID,NPCNE,NPPT,NPCD,NPST, NPCN,NPCE, NRID, NAUT,ACT, OPID,OPCNE,OPPT,OPCD,OPST, OPCN,OPCE, ORID, OAUT 51 52 53 54 FROM DUAL; 55 56 end PayCopAudit_updt_trigg; 57 /
  • 97. 96 Trigger created. SQL> SQL> create or replace TRIGGER PayCopAudit_inst_trigg 2 AFTER INSERT ON PaymentCop 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCNE Varchar2(50); 7 NPPT Varchar2(45); 8 NPCD Date; 9 NPST varchar2(25); 10 NPCN Integer; 11 NPCE Date; 12 ACT Char(20); 13 NRID INTEGER; 14 NAUT DECIMAL (8,2); 15 16 17 BEGIN 18 SELECT :NEW.PAYMENT_ID INTO NPID FROM DUAL; 19 SELECT :NEW.PAYMENT_COPNAME INTO NPCNE FROM DUAL; 20 SELECT :NEW.PAYMENT_TYPE INTO NPPT FROM DUAL; 21 SELECT :NEW.PAYMENT_CREATEDDATE INTO NPCD FROM DUAL; 22 SELECT :NEW.PAYMENT_STATUS INTO NPST FROM DUAL; 23 SELECT :NEW.PAYMENTCARD_NUMBER INTO NPCN FROM DUAL; 24 SELECT :NEW.PAYMENT_EXPDATE INTO NPCE FROM DUAL; 25 SELECT :NEW.Receipt_id INTO NRID FROM DUAL; 26 SELECT :NEW.Authorized_Amount INTO NAUT FROM DUAL; 27 28 SELECT 'Insert' INTO ACT From DUAL; 29 30 INSERT INTO PaymentCopAudit(PAYMENT_ID,PAYMENT_COPNAME,PAYMENT_TYPE,PAYMENT_CREATEDDAT E,PAYMENT_STATUS,PAYMENTCARD_NUMBER,PAYMENT_EXPDATE, Receipt_id,Authorized_AmT, ACTION_TYPE 31 ) 32 SELECT NPID,NPCNE,NPPT,NPCD,NPST, NPCN,NPCE, NRID, NAUT,ACT 33 34 35 36 FROM DUAL; 37 38 end PayCopAudit_inst_trigg; 39 / Trigger created. SQL> SQL> create or replace trigger shippmentAudit_auditdate_trgg 2 before insert on shipmentaudit 3 for each row 4 begin 5 select sysdate into :New.Audit_Date from dual; 6 end shippmentAudit_auditdate_trgg; 7 /
  • 98. 97 Trigger created. SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_audituser_trgg 2 before insert on shipmentaudit 3 for each row 4 begin 5 select user into :New.Audit_User from dual; 6 end shippmentAudit_audituser_trgg; 7 / Trigger created. SQL> SQL> SQL> SQL> SQL> create or replace trigger shippmentAudit_del_trigg 2 after delete on shipment 3 for each row 4 DECLARE 5 6 OLSHIPID NUMBER(38); 7 OSHIPPERID NUMBER(38); 8 OSTID NUMBER(38); 9 ORPID NUMBER(38); 10 OSHIPDATE DATE; 11 OSHIPENDDATE DATE; 12 ORVEDATE DATE; 13 ONAME VARCHAR2(55); 14 OADSS VARCHAR2(55) ; 15 OCIT VARCHAR2(55) ; 16 OLDSHIPPINGAMT NUMBER(38); 17 OSHIPPINGTYPE CHAR(35) ; 18 ACT CHAR(20); 19 20 begin 21 22 SELECT :OLD.SHIPPING_ID INTO OLSHIPID FROM DUAL; 23 SELECT :OLD.SHIPPER_ID INTO OSHIPPERID FROM DUAL; 24 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 25 SELECT :OLD.RECEIPT_ID INTO ORPID FROM DUAL; 26 SELECT :OLD.SHIP_DATE INTO OSHIPDATE FROM DUAL; 27 SELECT :OLD.SHIP_ENDDATE INTO OSHIPENDDATE FROM DUAL; 28 SELECT :OLD.RECEIVE_DATE INTO ORVEDATE FROM DUAL; 29 SELECT :OLD.NAME INTO ONAME FROM DUAL; 30 SELECT :OLD.ADDRESS INTO OADSS FROM DUAL; 31 SELECT :OLD.CITY INTO OCIT FROM DUAL; 32 SELECT :OLD.SHIPPING_AMOUNT INTO OLDSHIPPINGAMT FROM DUAL; 33 SELECT :OLD.SHIPPING_TYPE INTO OSHIPPINGTYPE FROM DUAL; 34 SELECT 'Delete' INTO ACT From Dual; 35 36 37 insert into shipmentaudit
  • 99. 98 38 (old_shippingid,old_shipperid, old_stateid, old_ReceiptID, old_shipdate ,old_shipenddate, old_receivedate, 39 old_Name, old_Address, old_City, old_shippingamt,old_shippingtype,Action_Type) 40 select OLSHIPID, OSHIPPERID, OSTID, ORPID, OSHIPDATE, OSHIPENDDATE,ORVEDATE,ONAME, OADSS, OCIT,OLDSHIPPINGAMT, 41 OSHIPPINGTYPE, ACT 42 from dual; 43 end shippmentAudit_del_trigg; 44 / Trigger created. SQL> SQL> create or replace trigger shippmentAudit_inst_trigg 2 after insert on shipment 3 for each row 4 DECLARE 5 6 NLSHIPID NUMBER(38); 7 NSHIPPERID NUMBER(38); 8 NSTID NUMBER(38); 9 NRPID NUMBER(38); 10 NSHIPDATE DATE; 11 NSHIPENDDATE DATE; 12 NRVEDATE DATE; 13 NNAME VARCHAR2(55); 14 NADSS VARCHAR2(55) ; 15 NCIT VARCHAR2(55) ; 16 NLDSHIPPINGAMT NUMBER(38); 17 NSHIPPINGTYPE CHAR(35) ; 18 ACT CHAR(20); 19 20 begin 21 22 SELECT :NEW.SHIPPING_ID INTO NLSHIPID FROM DUAL; 23 SELECT :NEW.SHIPPER_ID INTO NSHIPPERID FROM DUAL; 24 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 25 SELECT :NEW.RECEIPT_ID INTO NRPID FROM DUAL; 26 SELECT :NEW.SHIP_DATE INTO NSHIPDATE FROM DUAL; 27 SELECT :NEW.SHIP_ENDDATE INTO NSHIPENDDATE FROM DUAL; 28 SELECT :NEW.RECEIVE_DATE INTO NRVEDATE FROM DUAL; 29 SELECT :NEW.NAME INTO NNAME FROM DUAL; 30 SELECT :NEW.ADDRESS INTO NADSS FROM DUAL; 31 SELECT :NEW.CITY INTO NCIT FROM DUAL; 32 SELECT :NEW.SHIPPING_AMOUNT INTO NLDSHIPPINGAMT FROM DUAL; 33 SELECT :NEW.SHIPPING_TYPE INTO NSHIPPINGTYPE FROM DUAL; 34 SELECT 'Insert' INTO ACT From Dual; 35 36 37 insert into shipmentaudit 38 (SHIPPING_ID,SHIPPER_ID, STATE_ID, RECEIPT_ID, SHIP_DATE ,SHIP_ENDDATE, RECEIVE_DATE, 39 NAME, ADDRESS, CITY, SHIPPING_AMOUNT,SHIPPING_TYPE,Action_Type) 40 select NLSHIPID, NSHIPPERID, NSTID, NRPID, NSHIPDATE, NSHIPENDDATE,NRVEDATE,NNAME, NADSS, NCIT,NLDSHIPPINGAMT, 41 NSHIPPINGTYPE, ACT
  • 100. 99 42 from dual; 43 end shippmentAudit_inst_trigg; 44 / Trigger created. SQL> SQL> create or replace trigger shippmentAudit_upt_trigg 2 after UPDATE on shipment 3 for each row 4 DECLARE 5 6 NLSHIPID NUMBER(38); 7 NSHIPPERID NUMBER(38); 8 NSTID NUMBER(38); 9 NRPID NUMBER(38); 10 NSHIPDATE DATE; 11 NSHIPENDDATE DATE; 12 NRVEDATE DATE; 13 NNAME VARCHAR2(55); 14 NADSS VARCHAR2(55) ; 15 NCIT VARCHAR2(55) ; 16 NLDSHIPPINGAMT NUMBER(38); 17 NSHIPPINGTYPE CHAR(35) ; 18 OLSHIPID NUMBER(38); 19 OSHIPPERID NUMBER(38); 20 OSTID NUMBER(38); 21 ORPID NUMBER(38); 22 OSHIPDATE DATE; 23 OSHIPENDDATE DATE; 24 ORVEDATE DATE; 25 ONAME VARCHAR2(55); 26 OADSS VARCHAR2(55) ; 27 OCIT VARCHAR2(55) ; 28 OLDSHIPPINGAMT NUMBER(38); 29 OSHIPPINGTYPE CHAR(35) ; 30 ACT CHAR(20); 31 32 begin 33 34 SELECT :NEW.SHIPPING_ID INTO NLSHIPID FROM DUAL; 35 SELECT :NEW.SHIPPER_ID INTO NSHIPPERID FROM DUAL; 36 SELECT :NEW.STATE_ID INTO NSTID FROM DUAL; 37 SELECT :NEW.RECEIPT_ID INTO NRPID FROM DUAL; 38 SELECT :NEW.SHIP_DATE INTO NSHIPDATE FROM DUAL; 39 SELECT :NEW.SHIP_ENDDATE INTO NSHIPENDDATE FROM DUAL; 40 SELECT :NEW.RECEIVE_DATE INTO NRVEDATE FROM DUAL; 41 SELECT :NEW.NAME INTO NNAME FROM DUAL; 42 SELECT :NEW.ADDRESS INTO NADSS FROM DUAL; 43 SELECT :NEW.CITY INTO NCIT FROM DUAL; 44 SELECT :NEW.SHIPPING_AMOUNT INTO NLDSHIPPINGAMT FROM DUAL; 45 SELECT :NEW.SHIPPING_TYPE INTO NSHIPPINGTYPE FROM DUAL; 46 47 SELECT :OLD.SHIPPING_ID INTO OLSHIPID FROM DUAL; 48 SELECT :OLD.SHIPPER_ID INTO OSHIPPERID FROM DUAL; 49 SELECT :OLD.STATE_ID INTO OSTID FROM DUAL; 50 SELECT :OLD.RECEIPT_ID INTO ORPID FROM DUAL;
  • 101. 100 51 SELECT :OLD.SHIP_DATE INTO OSHIPDATE FROM DUAL; 52 SELECT :OLD.SHIP_ENDDATE INTO OSHIPENDDATE FROM DUAL; 53 SELECT :OLD.RECEIVE_DATE INTO ORVEDATE FROM DUAL; 54 SELECT :OLD.NAME INTO ONAME FROM DUAL; 55 SELECT :OLD.ADDRESS INTO OADSS FROM DUAL; 56 SELECT :OLD.CITY INTO OCIT FROM DUAL; 57 SELECT :OLD.SHIPPING_AMOUNT INTO OLDSHIPPINGAMT FROM DUAL; 58 SELECT :OLD.SHIPPING_TYPE INTO OSHIPPINGTYPE FROM DUAL; 59 60 61 62 SELECT 'Update' INTO ACT From Dual; 63 64 65 insert into shipmentaudit 66 (SHIPPING_ID,SHIPPER_ID, STATE_ID, RECEIPT_ID, SHIP_DATE ,SHIP_ENDDATE, RECEIVE_DATE, 67 NAME, ADDRESS, CITY, SHIPPING_AMOUNT,SHIPPING_TYPE,old_shippingid,old_shipperid, old_stateid, old_ReceiptID, 68 old_shipdate ,old_shipenddate, old_receivedate, 69 old_Name, old_Address, old_City, old_shippingamt,old_shippingtype, 70 Action_Type) 71 select NLSHIPID, NSHIPPERID, NSTID, NRPID, NSHIPDATE, NSHIPENDDATE,NRVEDATE,NNAME, NADSS, NCIT,NLDSHIPPINGAMT, 72 NSHIPPINGTYPE,OLSHIPID, OSHIPPERID, OSTID, ORPID, OSHIPDATE, OSHIPENDDATE,ORVEDATE,ONAME, OADSS, 73 OCIT,OLDSHIPPINGAMT,OSHIPPINGTYPE,ACT 74 from dual; 75 end shippmentAudit_upt_trigg; 76 / Trigger created. SQL> create or replace TRIGGER ReceiptAudit_delt_trigg 2 AFTER DELETE ON Receipt 3 FOR EACH ROW 4 DECLARE 5 ORCIPD INTEGER; 6 OEMPD INTEGER; 7 OCUID INTEGER; 8 OSTRID INTEGER; 9 ORPID INTEGER; 10 ORPTX DECIMAL(8,2); 11 OQT INTEGER; 12 OPID Integer; 13 ORFMT DECIMAL(8,2); 14 ORAMT DECIMAL(8,2); 15 ORIDT DATE; 16 ACT Char(20); 17 18 BEGIN 19 SELECT :OLD.RECEIPT_ID INTO ORCIPD FROM DUAL; 20 SELECT :OLD.EMPLOYEE_ID INTO OEMPD FROM DUAL; 21 SELECT :OLD.CUSTOMER_ID INTO OCUID FROM DUAL; 22 SELECT :OLD.STORE_ID INTO OSTRID FROM DUAL; 23 SELECT :OLD.PRODUCT_ID INTO ORPID FROM DUAL;
  • 102. 101 24 SELECT :OLD.RECEIPT_TAX INTO ORPTX FROM DUAL; 25 SELECT :OLD.QTY INTO OQT FROM DUAL; 26 SELECT :OLD.RECEIPT_FINALAMT INTO ORFMT FROM DUAL; 27 SELECT :OLD.RECEIPT_AMOUNT INTO ORAMT FROM DUAL; 28 SELECT :OLD.RECEIPT_DATE INTO ORIDT FROM DUAL; 29 SELECT 'Delete' INTO ACT From DUAL; 30 31 insert into ReceiptAudit 32 (OLD_RECEIPTID ,OLD_EMPLOYEEID,OLD_CUSTOMERID,OLD_STOREID, OLD_PRODID , OLD_RECEPTTAX, 33 OLD_QTY, OLD_RECEIPTDATE, OLD_RECPTFINALAMT ,OLD_RECPTAMT, 34 Action_Type) 35 SELECT ORCIPD, OEMPD, OCUID, OSTRID,ORPID,ORPTX, OQT, ORIDT, ORFMT, ORAMT,ACT 36 37 38 from dual; 39 40 41 end ReceiptAudit_delt_trigg; 42 43 / Trigger created. SQL> create or replace TRIGGER ReceiptAudit_inst_trigg 2 AFTER insert ON Receipt 3 FOR EACH ROW 4 DECLARE 5 NRCIPD INTEGER; 6 NEMPD INTEGER; 7 NCUID INTEGER; 8 NSTRID INTEGER; 9 NRPID INTEGER; 10 NRPTX DECIMAL(8,2); 11 NQT INTEGER; 12 NPID Integer; 13 NRFMT DECIMAL(8,2); 14 NRAMT DECIMAL(8,2); 15 NRIDT DATE; 16 ACT Char(20); 17 18 BEGIN 19 20 21 SELECT :NEW.RECEIPT_ID INTO NRCIPD FROM DUAL; 22 SELECT :NEW.EMPLOYEE_ID INTO NEMPD FROM DUAL; 23 SELECT :NEW.CUSTOMER_ID INTO NCUID FROM DUAL; 24 SELECT :NEW.STORE_ID INTO NSTRID FROM DUAL; 25 SELECT :NEW.PRODUCT_ID INTO NRPID FROM DUAL; 26 SELECT :NEW.RECEIPT_TAX INTO NRPTX FROM DUAL; 27 SELECT :NEW.QTY INTO NQT FROM DUAL; 28 SELECT :NEW.RECEIPT_FINALAMT INTO NRFMT FROM DUAL; 29 SELECT :NEW.RECEIPT_AMOUNT INTO NRAMT FROM DUAL; 30 SELECT :NEW.RECEIPT_DATE INTO NRIDT FROM DUAL; 31 SELECT 'Insert' INTO ACT From DUAL; 32
  • 103. 102 33 insert into ReceiptAudit 34 (RECEIPT_ID ,EMPLOYEE_ID,CUSTOMER_ID,STORE_ID, PRODUCT_ID , RECEIPT_TAX, 35 QTY, RECEIPT_DATE, RECEIPT_FINALAMT ,RECEIPT_AMOUNT, 36 Action_Type) 37 SELECT NRCIPD, NEMPD, NCUID, NSTRID,NRPID,NRPTX, NQT, NRIDT, NRFMT, NRAMT,ACT 38 39 40 from dual; 41 42 end ReceiptAudit_inst_trigg; 43 44 / Trigger created. SQL> create or replace TRIGGER ReceiptAudit_updt_trigg 2 AFTER UPDATE ON Receipt 3 FOR EACH ROW 4 DECLARE 5 ORCIPD INTEGER; 6 OEMPD INTEGER; 7 OCUID INTEGER; 8 OSTRID INTEGER; 9 ORPID INTEGER; 10 ORPTX DECIMAL(8,2); 11 OQT INTEGER; 12 OPID Integer; 13 ORFMT DECIMAL(8,2); 14 ORAMT DECIMAL(8,2); 15 ORIDT DATE; 16 17 NRCIPD INTEGER; 18 NEMPD INTEGER; 19 NCUID INTEGER; 20 NSTRID INTEGER; 21 NRPID INTEGER; 22 NRPTX DECIMAL(8,2); 23 NQT INTEGER; 24 NPID Integer; 25 NRFMT DECIMAL(8,2); 26 NRAMT DECIMAL(8,2); 27 NRIDT DATE; 28 29 30 ACT Char(20); 31 32 BEGIN 33 SELECT :OLD.RECEIPT_ID INTO ORCIPD FROM DUAL; 34 SELECT :OLD.EMPLOYEE_ID INTO OEMPD FROM DUAL; 35 SELECT :OLD.CUSTOMER_ID INTO OCUID FROM DUAL; 36 SELECT :OLD.STORE_ID INTO OSTRID FROM DUAL; 37 SELECT :OLD.PRODUCT_ID INTO ORPID FROM DUAL; 38 SELECT :OLD.RECEIPT_TAX INTO ORPTX FROM DUAL; 39 SELECT :OLD.QTY INTO OQT FROM DUAL; 40 SELECT :OLD.RECEIPT_FINALAMT INTO ORFMT FROM DUAL;
  • 104. 103 41 SELECT :OLD.RECEIPT_AMOUNT INTO ORAMT FROM DUAL; 42 SELECT :OLD.RECEIPT_DATE INTO ORIDT FROM DUAL; 43 44 SELECT :NEW.RECEIPT_ID INTO NRCIPD FROM DUAL; 45 SELECT :NEW.EMPLOYEE_ID INTO NEMPD FROM DUAL; 46 SELECT :NEW.CUSTOMER_ID INTO NCUID FROM DUAL; 47 SELECT :NEW.STORE_ID INTO NSTRID FROM DUAL; 48 SELECT :NEW.PRODUCT_ID INTO NRPID FROM DUAL; 49 SELECT :NEW.RECEIPT_TAX INTO NRPTX FROM DUAL; 50 SELECT :NEW.QTY INTO NQT FROM DUAL; 51 SELECT :NEW.RECEIPT_FINALAMT INTO NRFMT FROM DUAL; 52 SELECT :NEW.RECEIPT_AMOUNT INTO NRAMT FROM DUAL; 53 SELECT :NEW.RECEIPT_DATE INTO NRIDT FROM DUAL; 54 55 SELECT 'Update' INTO ACT From DUAL; 56 57 insert into ReceiptAudit 58 (OLD_RECEIPTID ,OLD_EMPLOYEEID,OLD_CUSTOMERID,OLD_STOREID, OLD_PRODID , OLD_RECEPTTAX, 59 OLD_QTY, OLD_RECEIPTDATE, OLD_RECPTFINALAMT ,OLD_RECPTAMT,RECEIPT_ID ,EMPLOYEE_ID,CUSTOMER_ID,STORE_ID, PRODUCT_ID , RECEIPT_TAX, 60 QTY, RECEIPT_DATE, RECEIPT_FINALAMT ,RECEIPT_AMOUNT, 61 Action_Type) 62 SELECT ORCIPD, OEMPD, OCUID, OSTRID,ORPID,ORPTX, OQT, ORIDT, ORFMT, ORAMT,NRCIPD, NEMPD, NCUID, NSTRID,NRPID,NRPTX, NQT, NRIDT, NRFMT, NRAMT, 63 ACT 64 65 66 from dual; 67 68 69 70 71 72 end ReceiptAudit_updt_trigg; 73 / Trigger created. SQL> SQL> SQL> SQL> SET ECHO OFF SQL> SPOOL OFF
  • 105. 104 SQL> Create table HRRecords 2 (Employee_ID Integer , 3 HR_ID Integer GENERATED ALWAYS AS IDENTITY (START WITH 0323 INCREMENT BY 20) , 4 Role_ID Integer , 5 Store_ID integer , 6 DOB Date not null, 7 Social_SecurityNum Integer , 8 Manager_id integer, 9 Hire_Date Date , 10 End_Date Date, 11 PayRate numeric(15,2) , 12 Employement_Status varchar2(45), 13 constraint HrRecord_hrid_pk primary key(Employee_ID,HR_ID,Role_ID,Store_ID, Manager_id), 14 constraint HrRecord_hri_uk unique (HR_ID), 15 constraint HrRecord_empid_fk foreign key(Employee_ID) references Employee(Employee_ID) , 16 constraint HrRecord_roleid_fk foreign key(Role_ID) references HRRoles(Role_ID) 17 ); Table created. SQL> Alter table HRRecords 2 add constraint HrRecord_storeid_fk foreign key(Store_ID) references store(store_id); Table altered. SQL> alter table hrrecordsaudit 2 add manager_id integer; Table altered. SQL> alter table hrrecordsaudit 2 add old_managerid integer; Table altered. SQL> create index hrrecord_Snn_idx on hrrecords (Social_SecurityNum); Index created. SQL> create index hrrecord_hiredate_idx on hrrecords (hire_date) 2 ; Index created. SQL> set echo off SQL> spool off
  • 106. 105 DBA Database Dictionary
  • 107. 106 Database Physical Model
  • 108. 107 Database Directory SQL> SQL> desc countrycode; Name Null? Type ----------------------------------------- -------- ---------------------- ------ COUNTRY_CODE NOT NULL NUMBER(38) COUNTRY_NAME NOT NULL VARCHAR2(60) COUNTRY_ABBRV NOT NULL VARCHAR2(12) SQL> desc countrycodesaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ COUNTRY_CODE NUMBER(38) COUNTRY_NAME VARCHAR2(60) COUNTRY_ABBRV VARCHAR2(12) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) OLD_COUNTRYCODE NUMBER(38) OLD_COUNTRYNAME VARCHAR2(60) OLD_COUNTRYABBRV VARCHAR2(12) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc statecodes; Name Null? Type ----------------------------------------- -------- ---------------------- ------ STATE_ID NOT NULL NUMBER(38) COUNTRY_CODE NOT NULL NUMBER(38) STATE_NAME NOT NULL VARCHAR2(110) STATE_ABBRV NOT NULL VARCHAR2(10) STATE_TAXRATE NOT NULL NUMBER(8,2) SQL> desc statecodesaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ STATE_ID NUMBER(38) COUNTRY_CODE NUMBER(38) STATE_NAME VARCHAR2(110) STATE_ABBRV VARCHAR2(10) STATE_TAXRATE NUMBER(8,2) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) OLD_STATE_ID NUMBER(38) OLD_COUNTRY_CODE NUMBER(38) OLD_STATE_NAME VARCHAR2(110) OLD_STATE_ABBRV VARCHAR2(10) OLD_STATE_TAXRATE NUMBER(8,2) SQL> desc store; Name Null? Type
  • 109. 108 ----------------------------------------- -------- ---------------------- ------ STORE_ID NOT NULL NUMBER(38) STORE_STATEID NOT NULL NUMBER(38) STORE_NAME NOT NULL VARCHAR2(65) STORE_TYPE NOT NULL VARCHAR2(34) STORE_ADDRESS NOT NULL VARCHAR2(65) STORE_CITY NOT NULL VARCHAR2(45) STORE_PHONE NOT NULL VARCHAR2(45) STORE_STATUS NOT NULL VARCHAR2(30) SQL> desc storeaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ STORE_ID NUMBER(38) STORE_STATEID NUMBER(38) STORE_NAME VARCHAR2(65) STORE_TYPE VARCHAR2(34) STORE_ADDRESS VARCHAR2(65) STORE_CITY VARCHAR2(45) STORE_PHONE VARCHAR2(45) STORE_STATUS VARCHAR2(30) OLD_STOREID NUMBER(38) OLD_STORSTATEID NUMBER(38) OLD_STORNAME VARCHAR2(65) OLD_STORTYPE VARCHAR2(34) OLD_STORADDRESS VARCHAR2(65) OLD_STORCITY VARCHAR2(45) OLD_STORPHONE VARCHAR2(45) OLD_STORSTATUS VARCHAR2(30) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc employee; Name Null? Type ----------------------------------------- -------- ---------------------- ------ EMPLOYEE_ID NOT NULL NUMBER(38) FIRST_NAME NOT NULL VARCHAR2(55) MIDDLE_NAME VARCHAR2(55) LAST_NAME NOT NULL VARCHAR2(55) ADDRESS NOT NULL VARCHAR2(55) CITY NOT NULL VARCHAR2(45) STATE_ID NOT NULL NUMBER(38) PHONE NOT NULL VARCHAR2(45) SQL> desc employeeaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ EMPLOYEE_ID NUMBER(38) FIRST_NAME VARCHAR2(55) MIDDLE_NAME VARCHAR2(55) LAST_NAME VARCHAR2(55)
  • 110. 109 ADDRESS VARCHAR2(55) CITY VARCHAR2(45) STATE_ID NUMBER(38) PHONE VARCHAR2(45) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) OLD_EMPLOYEE_ID NUMBER(38) OLD_FIRST_NAME VARCHAR2(55) OLD_MIDDLE_NAME VARCHAR2(55) OLD_LAST_NAME VARCHAR2(55) OLD_ADDRESS VARCHAR2(55) OLD_CITY VARCHAR2(45) OLD_STATE_ID NUMBER(38) OLD_PHONE VARCHAR2(45) SQL> desc management; Name Null? Type ----------------------------------------- -------- ---------------------- ------ MANAGER_ID NOT NULL NUMBER(38) STORE_ID NOT NULL NUMBER(38) EMPLOYEE_ID NOT NULL NUMBER(38) HIRE_DATE NOT NULL DATE HIRE_ENDDATE DATE SQL> desc managementaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ MANAGER_ID NUMBER(38) EMPLOYEE_ID NUMBER(38) HIRE_DATE DATE HIRE_ENDDATE DATE OLD_MANAGERID NUMBER(38) OLD_EMPLOYEEID NUMBER(38) OLD_HIREDATE DATE OLD_HIREENDDATE DATE AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) STORE_ID NUMBER(38) OLD_STOREID NUMBER(38) SQL> desc hrroles; Name Null? Type ----------------------------------------- -------- ---------------------- ------ ROLE_ID NOT NULL NUMBER(38) ROLE_TITLE NOT NULL VARCHAR2(45) ROLE_STATUS NOT NULL VARCHAR2(45) SQL> desc hrrolesaudit; Name Null? Type
  • 111. 110 ----------------------------------------- -------- ---------------------- ------ ROLE_ID NUMBER(38) ROLE_TITLE VARCHAR2(45) ROLE_STATUS VARCHAR2(45) OLD_ROLEID NUMBER(38) OLD_ROLETITLE VARCHAR2(45) OLD_ROLE_STATUS VARCHAR2(45) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc hrrecords; Name Null? Type ----------------------------------------- -------- ---------------------- ------ EMPLOYEE_ID NOT NULL NUMBER(38) HR_ID NOT NULL NUMBER(38) ROLE_ID NOT NULL NUMBER(38) STORE_ID NOT NULL NUMBER(38) DOB NOT NULL DATE SOCIAL_SECURITYNUM NUMBER(38) MANAGER_ID NOT NULL NUMBER(38) HIRE_DATE DATE END_DATE DATE PAYRATE NUMBER(15,2) EMPLOYEMENT_STATUS VARCHAR2(45) SQL> desc hrrecordsaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ EMPLOYEE_ID NUMBER(38) HR_ID NUMBER(38) ROLE_ID NUMBER(38) STORE_ID NUMBER(38) DOB DATE SOCIAL_SECURITYNUM NUMBER(38) HIRE_DATE DATE END_DATE DATE PAYRATE NUMBER(15,2) EMPLOYEMENT_STATUS VARCHAR2(45) OLD_EMPLOYEEID NUMBER(38) OLD_HRID NUMBER(38) OLD_ROLEID NUMBER(38) OLD_STOREID NUMBER(38) OLD_DOB DATE OLD_SOCIALSECURITYNUM NUMBER(38) OLD_HIREDATE DATE OLD_ENDDATE DATE OLD_PAYRATE NUMBER(15,2) OLD_EMPLOYEMENTSTATUS VARCHAR2(45) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20)
  • 112. 111 MANAGER_ID NUMBER(38) OLD_MANAGERID NUMBER(38) SQL> desc shipment; Name Null? Type ----------------------------------------- -------- ---------------------- ------ SHIPPING_ID NOT NULL NUMBER(38) SHIPPER_ID NOT NULL NUMBER(38) STATE_ID NOT NULL NUMBER(38) RECEIPT_ID NOT NULL NUMBER(38) SHIP_DATE DATE SHIP_ENDDATE DATE RECEIVE_DATE DATE NAME NOT NULL VARCHAR2(55) ADDRESS NOT NULL VARCHAR2(55) CITY NOT NULL VARCHAR2(55) SHIPPING_AMOUNT NOT NULL NUMBER(38) SHIPPING_TYPE NOT NULL CHAR(35) SQL> desc shipmentaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ SHIPPING_ID NUMBER(38) SHIPPER_ID NUMBER(38) STATE_ID NUMBER(38) RECEIPT_ID NUMBER(38) SHIP_DATE DATE SHIP_ENDDATE DATE RECEIVE_DATE DATE NAME VARCHAR2(55) ADDRESS VARCHAR2(55) CITY VARCHAR2(55) SHIPPING_AMOUNT NUMBER SHIPPING_TYPE CHAR(35) OLD_SHIPPINGID NUMBER(38) OLD_SHIPPERID NUMBER(38) OLD_STATEID NUMBER(38) OLD_RECEIPTID NUMBER(38) OLD_SHIPDATE DATE OLD_SHIPENDDATE DATE OLD_RECEIVEDATE DATE OLD_NAME VARCHAR2(55) OLD_ADDRESS VARCHAR2(55) OLD_CITY VARCHAR2(55) OLD_SHIPPINGAMT NUMBER OLD_SHIPPINGTYPE CHAR(35) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc paymentcop; Name Null? Type ----------------------------------------- -------- ---------------------- ------
  • 113. 112 PAYMENT_ID NOT NULL NUMBER(38) PAYMENT_COPNAME NOT NULL VARCHAR2(50) PAYMENT_TYPE NOT NULL VARCHAR2(45) PAYMENT_CREATEDDATE DATE PAYMENT_STATUS VARCHAR2(25) PAYMENTCARD_NUMBER NOT NULL NUMBER(38) PAYMENT_EXPDATE DATE RECEIPT_ID NOT NULL NUMBER(38) AUTHORIZED_AMOUNT NUMBER(8,2) SQL> desc paymentcopaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ PAYMENT_ID NUMBER(38) PAYMENT_COPNAME VARCHAR2(50) PAYMENT_TYPE VARCHAR2(45) PAYMENT_CREATEDDATE DATE PAYMENT_STATUS VARCHAR2(25) PAYMENTCARD_NUMBER NUMBER(38) OLD_PAYID NUMBER(38) OLD_PAYCOPNAME VARCHAR2(50) OLD_PAYTYPE VARCHAR2(45) OLD_PAYCREATEDDATE DATE OLD_PAYSTATUS VARCHAR2(25) OLD_PAYCARD_NUMBER NUMBER(38) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) PAYMENT_EXPDATE DATE OLD_PCARD_EXPDATE DATE RECEIPT_ID NUMBER(38) OLD_RECEIPTID NUMBER(38) AUTHORIZED_AMT NUMBER(8,2) OLD_AUTHAMT NUMBER(8,2) SQL> desc shippingco; Name Null? Type ----------------------------------------- -------- ---------------------- ------ SHIPPER_ID NOT NULL NUMBER(38) SHIPPER_NAME NOT NULL VARCHAR2(50) STATUS NOT NULL CHAR(25) CREATE_DATE DATE SQL> desc shippingcoaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ SHIPPER_ID NUMBER(38) SHIPPER_NAME VARCHAR2(50) STATUS CHAR(25) CREATE_DATE DATE OLD_SHIPPERID NUMBER(38) OLD_SHIPPERNAME VARCHAR2(50) OLD_STATUS CHAR(25)
  • 114. 113 OLD_CREATE_DATE DATE AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc receipt; Name Null? Type ----------------------------------------- -------- ---------------------- ------ RECEIPT_ID NOT NULL NUMBER(38) EMPLOYEE_ID NOT NULL NUMBER(38) CUSTOMER_ID NOT NULL NUMBER(38) STORE_ID NOT NULL NUMBER(38) PRODUCT_ID NOT NULL NUMBER(38) RECEIPT_TAX NUMBER(8,2) QTY NOT NULL NUMBER(38) RECEIPT_DATE NOT NULL DATE RECEIPT_FINALAMT NUMBER(8,2) RECEIPT_AMOUNT NOT NULL NUMBER(8,2) SQL> desc receiptaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ RECEIPT_ID NUMBER(38) EMPLOYEE_ID NUMBER(38) CUSTOMER_ID NUMBER(38) STORE_ID NUMBER(38) PRODUCT_ID NUMBER(38) RECEIPT_TAX NUMBER(8,2) QTY NUMBER(38) OLD_RECEIPTID NUMBER(38) OLD_EMPLOYEEID NUMBER(38) OLD_CUSTOMERID NUMBER(38) OLD_STOREID NUMBER(38) OLD_PRODID NUMBER(38) OLD_RECEPTTAX NUMBER(8,2) OLD_QTY NUMBER(38) AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) RECEIPT_DATE DATE OLD_RECEIPTDATE DATE RECEIPT_AMOUNT NUMBER(8,2) RECEIPT_FINALAMT NUMBER(8,2) OLD_RECPTFINALAMT NUMBER(8,2) OLD_RECPTAMT NUMBER(8,2) SQL> desc product; Name Null? Type ----------------------------------------- -------- ---------------------- ------ PRODUCT_ID NOT NULL NUMBER(38) PRODUCT_CATEGORYID NOT NULL NUMBER(38) PRODUCT_NAME NOT NULL VARCHAR2(110)
  • 115. 114 PRODUCT_COLOR VARCHAR2(35) PRODUCT_SIZE VARCHAR2(35) PRODUCT_WEIGHT VARCHAR2(45) PRODUCT_DESCRIPTION CLOB SQL> desc productaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ PRODUCT_ID NUMBER(38) PRODUCT_CATEGORYID NUMBER(38) PRODUCT_NAME VARCHAR2(110) PRODUCT_COLOR VARCHAR2(35) PRODUCT_SIZE VARCHAR2(35) PRODUCT_WEIGHT VARCHAR2(45) PRODUCT_DESCRIPTION CLOB OLD_PRODUCTID NUMBER(38) OLD_PRODCATEGORYID NUMBER(38) OLD_PRODNAME VARCHAR2(110) OLD_PRODCOLOR VARCHAR2(35) OLD_PRODSIZE VARCHAR2(35) OLD_PRODWEIGHT VARCHAR2(45) OLD_PRODDESCRIPTION CLOB AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> desc productcategory; Name Null? Type ----------------------------------------- -------- ---------------------- ------ PRODUCT_CATEGORYID NOT NULL NUMBER(38) CATEGORY_NAME NOT NULL VARCHAR2(45) CATEGORY_DESCRIPTION CLOB SQL> desc productcategoryaudit; Name Null? Type ----------------------------------------- -------- ---------------------- ------ PRODUCT_CATEGORYID NUMBER(38) CATEGORY_NAME VARCHAR2(45) CATEGORY_DESCRIPTION CLOB OLD_PRODCATEGORYID NUMBER(38) OLD_CATEGORYNAME VARCHAR2(45) OLD_CATEGORYDESCRIPTION CLOB AUDIT_DATE TIMESTAMP(6) AUDIT_USER VARCHAR2(50) AUDIT_ID NOT NULL NUMBER(38) ACTION_TYPE CHAR(20) SQL> set echo off; SQL> spool off;
  • 116. 115
  • 117. 116
  • 118. 117
  • 119. 118
  • 120. 119
  • 121. 120
  • 122. 121
  • 123. 122
  • 124. 123
  • 125. 124
  • 126. 125
  • 127. 126
  • 128. 127
  • 129. 128
  • 130. 129
  • 131. 130
  • 132. 131
  • 133. 132
  • 134. 133
  • 135. 134
  • 136. 135
  • 137. 136
  • 138. 137
  • 139. 138
  • 140. 139
  • 141. 140
  • 142. 141
  • 143. 142
  • 144. 143
  • 145. 144
  • 146. 145
  • 147. 146
  • 148. 147
  • 149. 148
  • 150. 149
  • 151. 150
  • 152. 151
  • 153. 152 Database Population SQL> SQL> show user; USER is "HOWARDDBA" SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( 105, 'Alabama', 'AL', 5); 1 row created. SQL> commit; Commit complete. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Alaska', 'AK', 4); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Arkansas', 'AR', 55); 1 row created. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Arizona', 'AZ', 55); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'California', 'CA', 6); 1 row created.
  • 154. 153 SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Colorado', 'CO', 3); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Connecticut', 'CT', 59); 1 row created. SQL> commit; Commit complete. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Delaware', 'DE', 4); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Florida', 'FL', 25); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Georgia', 'GA', 7); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Hawaii', 'HI', 5); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Idaho', 'ID', 3); 1 row created. SQL> commit;
  • 155. 154 Commit complete. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Indiana', 'IN', 55); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Iowa', 'IA', 45); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Kansas', 'KS', 5); 1 row created. SQL> commit; Commit complete. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Kentucky', 'KY', 6); 1 row created. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Louisiana', 'LA', 59); 1 row created. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Maine', 'ME', 5); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Maryland', 'MD', 65);
  • 156. 155 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Massachusetts', 'MA', 7); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Mississippi', 'MS', 5); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Minnesota', 'MN', 75); 1 row created. SQL> commit; Commit complete. SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Montana', 'MT', 65); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Virginia', 'VA', 55); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Nevada', 'NV', 45); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate )
  • 157. 156 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'New Hampshire', 'NH', 5); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'New Jersey', 'NJ', 6); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'New Mexico', 'NM', 59); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'New York', 'NY', 8); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'North Carolina', 'NC', 65); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'North Dakota', 'ND', 7); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Ohio', 'OH', 5); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate )
  • 158. 157 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'Pennsylvania', 'PA', 75); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'US'), 'District of Columbia', 'DC', 75); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'CA'), 'Alberta', 'AB', 45); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'CA'), 'British Columbia', 'BC', 5); 1 row created. SQL> commit; Commit complete. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'CA'), 'Ontario', 'ON', 6); 1 row created. SQL> SQL> Insert into statecodes(Country_Code, State_Name, State_Abbrv, State_TaxRate ) 2 values( (select Country_Code from countrycode where Country_Abbrv = 'CA'), 'Quebec', 'QC', 59); 1 row created. SQL> commit; Commit complete. SQL> SET ECHO OFF; SQL> SPOOL OFF;
  • 159. 158 SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Sunny', 'Lionel', '4234 W Peterson Apt 5B', 'Denver', '303-789- 9292', 3 TO_DATE( '10-FEB-1968','DD-MON-YYYY')); 1 row created. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Mercy', 'Wells', '553 S County RD ', 'Denver', '720-461-1989', 3 TO_DATE( '20-SEP-1950','DD-MON-YYYY')); 1 row created. SQL> commit; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Janet', 'Laurl', '19 E Dupage RD ', 'Castle Rock', '303-689-6565', 3 TO_DATE( '25-NOV-1978','DD-MON-YYYY')); 1 row created. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Tavin','Michael', '4223 N Ashland ', 'Broomfield ', '720-876- 9279', 3 TO_DATE( '21-JUN-1985','DD-MON-YYYY')); 1 row created. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Whitney ', 'Jackson', '798 S Austin Suite 25','Aurora ', '303-221- 890', 3 TO_DATE( '11-NOV-1972','DD-MON-YYYY')); 1 row created. SQL> COMMIT; Commit complete.
  • 160. 159 SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Mary', 'Nelson', '205 E Lakshore Drv Apt 7823B', 'Denver', '303- 235-4040', 3 TO_DATE( '19-APR-1975','DD-MON-YYYY')); 1 row created. SQL> SQL> SQL> commit; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CO'), 'Washington' ,'White', '200 N Capitol', 'Denver','303-456-8902', 3 TO_DATE( '21-FEB-1980','DD-MON-YYYY')); 1 row created. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'MD'), 'Rose', 'Hilson', '344 Airport Drv Apt 6C', 'Aurora','302-409- 2221', 3 TO_DATE( '03-MAR-1989','DD-MON-YYYY')); 1 row created. SQL> COMMIT; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'MD'), 'Townson', 'Kelly','192 York Rd Apt 7B', 'Broomfield', '720-243- 1989', TO_DATE( '24-JUL-1979','DD-MON-YYYY')); 1 row created. SQL> COMMIT; Commit complete. SQL> SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'PA'), 'Linda', 'Frost', '42 E York Rd Apt 5G' ,'Broomfield','720-980- 9873', 3 TO_DATE( '19-JAN-1992','DD-MON-YYYY')); 1 row created.
  • 161. 160 SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'DC'), 'Bryson' ,'Brown', '3232 Rocky Parks Ave', 'Castle Rock', '302- 334-432', 3 TO_DATE( '23-APR-1959','DD-MON-YYYY')); 1 row created. SQL> commit; Commit complete. SQL> SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'AZ'), 'Ebony','Young','402 Federal Blv Apt 20b', 'PHOENIX', 3 '602-980-9873', TO_DATE( '20-APR-1951','DD-MON-YYYY')); 1 row created. SQL> SQL> SQL> commit; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'AZ'), 'Diane', 'Yang', '1920 S Apple Drv Apt 12C','PHOENIX', 3 '602-444-9762',TO_DATE( '09-SEP-1982','DD-MON-YYYY')); 1 row created. SQL> SQL> commit; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Middle_Name,Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'AZ'), 'Christy', 'Christy', 'Mark', '20 University Drv Apt 4G', 3 'PHOENIX', '602-444-9762', 4 TO_DATE( '23-SEP-1976','DD-MON-YYYY')); 1 row created. SQL> SQL> SQL> commit; Commit complete.
  • 162. 161 SQL> SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CA'), 'Robyn','Young','402 Federal Blv Apt 20b', 'Los Angeles', 3 '323-980-9873',TO_DATE( '20-MAR-1973','DD-MON-YYYY')); 1 row created. SQL> SQL> commit; Commit complete. SQL> INSERT INTO customer(State_ID, First_Name, Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CA'), 'Diane', 'Yang', '1920 S Apple Drv Apt 12C','Los Angeles', 3 '323-444-9762',TO_DATE( '23-JUN-1973','DD-MON-YYYY')); 1 row created. SQL> INSERT INTO customer(State_ID, First_Name, Middle_Name,Last_Name,Address, City, Phone, DOB) 2 values( (select state_id from statecodes where state_abbrv = 'CA'), 'Christy', 'Christy', 'Mark', '20 University Drv Apt 4G', 3 'Los Angeles', '323-444-9762',TO_DATE( '23-APR-1986','DD-MON- YYYY')); 1 row created. SQL> commit; Commit complete. SQL> SET ECHO OFF SQL> SPOOL OFF;
  • 163. 162
  • 164. 163
  • 165. 164
  • 166. 165
  • 167. 166 Modifying the Table Column
  • 168. 167 Next I would change the declared variables for the triggers to reflect to the product name column data size SQL> create or replace TRIGGER productAudit_del_trigg 2 AFTER DELETE ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 OPID Integer; 6 OPCID Integer; 7 OPN Varchar2(110); 8 OPC Varchar2(35); 9 OPS Varchar2(35); 10 OPW Varchar2(45); 11 OPD CLOB; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :OLD.Product_ID INTO OPID FROM DUAL; 16 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 17 SELECT :OLD.Product_Name INTO OPN FROM DUAL; 18 SELECT :OLD.Product_Color INTO OPC FROM DUAL; 19 SELECT :OLD.Product_Size INTO OPS FROM DUAL; 20 SELECT :OLD.Product_Weight INTO OPW FROM DUAL; 21 SELECT :OLD.Product_Description INTO OPD FROM DUAL; 22 SELECT 'Delete' INTO ACT FROM DUAL; 23 24 25 INSERT INTO productAudit 26 (Old_ProductID,Old_ProdCategoryID,Old_ProdName,Old_ProdColor,Old_ProdSize, Old_ProdWeight,Old_ProdDescription, Action_Type) 27 SELECT OPID,OPCID, OPN, OPC,OPS,OPW,OPD, ACT FROM DUAL; 28 END productAudit_del_trigg; 29 30 31 / Trigger created.
  • 169. 168 SQL> SQL> create or replace TRIGGER productAudit_Inst_trigg 2 AFTER INSERT ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCID Integer; 7 NPN Varchar2(110); 8 NPC Varchar2(35); 9 NPS Varchar2(35); 10 NPW Varchar2(45); 11 NPD CLOB; 12 ACT Char(20); 13 14 BEGIN 15 SELECT :NEW.Product_ID INTO NPID FROM DUAL; 16 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 17 SELECT :NEW.Product_Name INTO NPN FROM DUAL; 18 SELECT :NEW.Product_Color INTO NPC FROM DUAL; 19 SELECT :NEW.Product_Size INTO NPS FROM DUAL; 20 SELECT :NEW.Product_Weight INTO NPW FROM DUAL; 21 SELECT :NEW.Product_Description INTO NPD FROM DUAL; 22 SELECT 'Insert' INTO ACT FROM DUAL; 23 24 25 INSERT INTO productAudit 26 (Product_ID,Product_CategoryID,Product_Name,Product_Color,Product_Size,Pro duct_Weight,Product_Description, Action_Type) 27 SELECT NPID,NPCID, NPN, NPC,NPS,NPW,NPD, ACT FROM DUAL; 28 END productAudit_Inst_trigg; 29 / Trigger created. SQL> create or replace TRIGGER productAudit_updt_trigg 2 AFTER update ON PRODUCT 3 FOR EACH ROW 4 DECLARE 5 NPID Integer; 6 NPCID Integer; 7 NPN Varchar2(110); 8 NPC Varchar2(35); 9 NPS Varchar2(35); 10 NPW Varchar2(45); 11 NPD CLOB; 12 OPID Integer; 13 OPCID Integer; 14 OPN Varchar2(110); 15 OPC Varchar2(35); 16 OPS Varchar2(35); 17 OPW Varchar2(45); 18 OPD CLOB; 19 ACT Char(20); 20 21 BEGIN
  • 170. 169 22 SELECT :NEW.Product_ID INTO NPID FROM DUAL; 23 SELECT :NEW.Product_CategoryID INTO NPCID FROM DUAL; 24 SELECT :NEW.Product_Name INTO NPN FROM DUAL; 25 SELECT :NEW.Product_Color INTO NPC FROM DUAL; 26 SELECT :NEW.Product_Size INTO NPS FROM DUAL; 27 SELECT :NEW.Product_Weight INTO NPW FROM DUAL; 28 SELECT :NEW.Product_Description INTO NPD FROM DUAL; 29 SELECT :OLD.Product_ID INTO OPID FROM DUAL; 30 SELECT :OLD.Product_CategoryID INTO OPCID FROM DUAL; 31 SELECT :OLD.Product_Name INTO OPN FROM DUAL; 32 SELECT :OLD.Product_Color INTO OPC FROM DUAL; 33 SELECT :OLD.Product_Size INTO OPS FROM DUAL; 34 SELECT :OLD.Product_Weight INTO OPW FROM DUAL; 35 SELECT :OLD.Product_Description INTO OPD FROM DUAL; 36 SELECT 'Update' INTO ACT FROM DUAL; 37 38 39 INSERT INTO productAudit 40 (Product_ID,Product_CategoryID,Product_Name,Product_Color,Product_Size,Pro duct_Weight,Product_Description, 41 Old_ProductID,Old_ProdCategoryID,Old_ProdName,Old_ProdColor,Old_ProdSize,O ld_ProdWeight,Old_ProdDescription, 42 Action_Type) 43 SELECT NPID,NPCID, NPN, NPC,NPS,NPW,NPD, OPID,OPCID, OPN, OPC,OPS,OPW,OPD, 44 ACT FROM DUAL; 45 END productAudit_updt_trigg; 46 / Trigger created. SQL> insert into Product(Product_CategoryID, Product_Name, Product_Color, Product_Size,Product_Description,Product_Weight ) 2 values ( (select product_categoryid from productcategory where category_name ='Televsion'), 3 'LG Electronics LN530B 32LN530B LED-lit 720p 60Hz TV ','Black','32-Inch', 4 'Intelligent Sensor, Picture Wizard, Smart Energy Saving, Simplink, Triple XD Engine, Mobile High-Definition Link (MHL)', 5 '14.8 pounds'); 1 row created. SQL> COMMIT; Commit complete. SQL> SET ECHO OFF SQL> SPOOL OFF;
  • 171. 170
  • 172. 171
  • 173. 172
  • 174. 173
  • 175. 174
  • 176. 175
  • 177. 176
  • 178. 177
  • 179. 178 Database Verifcation- Regular Tables
  • 180. 179
  • 181. 180
  • 182. 181
  • 183. 182
  • 184. 183
  • 185. 184 Database Verifcation- Audit Tables
  • 186. 185
  • 187. 186
  • 188. 187
  • 189. 188
  • 190. 189
  • 191. 190
  • 192. 191
  • 193. 192 Data Population and Mainpulation
  • 194. 193
  • 195. 194
  • 196. 195
  • 197. 196
  • 198. 197 In the following demonstrations , Microsoft Visual Studio would be utilized along with SQL Developer JD Developer to creat various Oracle database objects and scripts.
  • 199. 198
  • 200. 199
  • 201. 200
  • 202. 201
  • 203. 202
  • 204. 203
  • 205. 204 anonymous block completed EmployeeID:443 First Name:John Middle Name:NA Last Name:Martins City:Denver StateaID:295 Phone:259-8259 Address:5909 N Clark St Apt 16B2 StateName:Colorado CountryName:United States HireDate:2011-JAN-01 DOB:25-AUG-66 EmployeeID:468 First Name:Bryan Middle Name:NA Last Name:Sheridan City:Denver StateaID:295 Phone:720-9089 Address:174 S Wilson Apt 6B StateName:Colorado CountryName:United States HireDate:2011-JAN-01 DOB:19-APR-83 EmployeeID:493 First Name:liz Middle Name:NA Last Name:Clapton City:Denver StateaID:295 Phone:453-9870 Address:402 S Parker RD Apt 5c StateName:Colorado CountryName:United States HireDate:2011-JAN-01 DOB:15-FEB-80 EmployeeID:593 First Name:Michael Middle Name:NA Last Name:Wats City:Forest Lawn StateaID:280 Phone:453-9870 Address:42 N Empire Pike Apt 76B StateName:California CountryName:United States HireDate:2011-JAN-01 DOB:25-MAR-74 EmployeeID:618 First Name:Chantelle Middle Name:NA Last Name:Obi
  • 206. 205 City:Los Angeles StateaID:280 Phone:453-8432 Address:4040 5th Ave Apt 42b StateName:California CountryName:United States HireDate:2011-JAN-01 DOB:30-SEP-79 EmployeeID:643 First Name:Michael Middle Name:NA Last Name:Harrison City:Los Angeles StateaID:280 Phone:453-9437 Address:4040 Oakland Ave Apt 42b StateName:California CountryName:United States HireDate:2011-JAN-01 DOB:25-MAR-76 EmployeeID:518 First Name:Paulina Middle Name:NA Last Name:Dwanson City:PHOENIX StateaID:265 Phone:259-8259 Address: 2424 NW 5th St Apt 2c StateName:Arizona CountryName:United States HireDate:2011-JAN-01 DOB:21-JUN-82 EmployeeID:543 First Name:Roland Middle Name:Scott Last Name:Dwanson City:PHOENIX StateaID:265 Phone:458-8259 Address: 2424 NW 5th St Apt 2c StateName:Arizona CountryName:United States HireDate:2011-JAN-01 DOB:21-FEB-89 EmployeeID:568 First Name:Regina Middle Name:NA Last Name:Donald City:PHOENIX StateaID:265 Phone:112-1134 Address:40 E Circle Ave Apt 7B StateName:Arizona
  • 207. 206 CountryName:United States HireDate:2011-JAN-01 DOB:22-NOV-80 EmployeeID:568 First Name:Regina Middle Name:NA Last Name:Donald City:PHOENIX StateaID:265 Phone:112-1134 Address:40 E Circle Ave Apt 7B StateName:Arizona CountryName:United States HireDate:2011-JAN-01 DOB:22-NOV-80
  • 208. 207
  • 209. 208
  • 210. 209
  • 211. 210
  • 212. 211 User Account Creations and Privileges
  • 213. 212
  • 214. 213
  • 215. 214
  • 216. 215
  • 217. 216
  • 218. 217
  • 219. 218
  • 220. 219
  • 221. 220
  • 222. 221
  • 223. 222
  • 224. 223
  • 225. 224
  • 226. 225
  • 227. 226
  • 228. 227
  • 229. 228
  • 230. 229
  • 231. 230 Inorder for the receipt_tax and receipt_finalamt , I have to switch to the DBA account and use the receipt_dml package since the granted privileges are not working for user sunny.
  • 232. 231
  • 233. 232
  • 234. 233
  • 235. 234
  • 236. 235
  • 237. 236
  • 238. 237
  • 239. 238
  • 240. 239
  • 241. 240
  • 242. 241
  • 243. 242
  • 244. 243
  • 245. 244
  • 246. 245
  • 247. 246
  • 248. 247
  • 249. 248
  • 250. 249
  • 251. 250
  • 252. 251
  • 253. 252
  • 254. 253
  • 255. 254
  • 256. 255
  • 257. 256
  • 258. 257
  • 259. 258
  • 260. 259 anonymous block completed 1 is the number of rows processed Customer ID: 1078 First Name:Ebony Last Name:Young Receipt ID:1492 Product ID: 1162 Order Date:06-FEB-11 QTY:3 Amount:300 Tax:9 Final Amount:909 Prod Name:Sony HDR-CX220/B High Definition Handycam Camcorde Prod Color: Silver Prod Size: Store Name:Valley of Sun Electronics 2 is the number of rows processed Customer ID: 1078 First Name:Ebony Last Name:Young Receipt ID:1372 Product ID: 1207 Order Date:12-JAN-11 QTY:4 Amount:200 Tax:9 Final Amount:809 Prod Name:Avaya 1416 Digital Deskphone Prod Color: Black Prod Size: Store Name:Valley of Sun Electronics
  • 261. 260 3 is the number of rows processed Customer ID: 1078 First Name:Ebony Last Name:Young Receipt ID:1272 Product ID: 862 Order Date:05-JAN-11 QTY:5 Amount:880 Tax:9 Final Amount:4409 Prod Name:Acer C720 Chromebook Prod Color: Silver Prod Size:11.6 inch Store Name:Valley of Sun Electronics 4 is the number of rows processed Customer ID: 1078 First Name:Ebony Last Name:Young Receipt ID:1252 Product ID: 502 Order Date:05-JAN-11 QTY:8 Amount:600 Tax:9 Final Amount:4809 Prod Name:Samsung UN32EH5300 1080p 60 Hz Smart LED HDTV Prod Color: Black Prod Size:40-Inch Store Name:Valley of Sun Electronics Cursor is closed
  • 262. 261
  • 263. 262
  • 264. 263
  • 265. 264
  • 266. 265
  • 267. 266
  • 268. 267
  • 269. 268
  • 270. 269
  • 271. 270
  • 272. 271
  • 273. 272
  • 274. 273
  • 275. 274
  • 276. 275
  • 277. 276
  • 278. 277
  • 279. 278
  • 280. 279
  • 281. 280
  • 282. 281
  • 283. 282
  • 284. 283
  • 285. 284
  • 286. 285 Revised Physical Diagram
  • 287. 286 DBA Works
  • 288. 287
  • 289. 288
  • 290. 289
  • 291. 290
  • 292. 291
  • 293. 292
  • 294. 293
  • 295. 294 MYSQL 5.6
  • 296. 295 Database Creation Application Accounts Creation Oracle SQLDeveloper
  • 297. 296 Microsoft Visual Studio 2010 Oracle JDeveloper
  • 298. 297 Tables mysql> create table HowardR.countrycode -> (Country_Code Integer AUTO_INCREMENT, -> Country_Name Varchar(60) not null, -> Country_Abbrv Varchar(12) not null, -> constraint countrycode_countrycode_pk primary key (Country_Code) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.52 sec) mysql> create table HowardR.CountryCodesAudit -> (Country_Code Integer , -> Country_Name Varchar(60), -> Country_Abbrv Varchar(12), -> Audit_Date timestamp, -> Audit_User varchar(50), -> old_countrycode integer, -> old_countryname Varchar(60), -> old_countryabbrv Varchar(12), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint countrycd_AuditID_pk primary key (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.65 sec) mysql> Create table HowardR.statecodes -> (State_ID integer AUTO_INCREMENT, -> Country_Code integer, -> State_Name ENUM ( 'Alabama', 'Alaska', -> 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida' -> ,'Georgia', 'Hawaii', 'Idaho', 'ILLINOIS ', 'Indiana', 'Iowa', 'Kansas','Kentucky', -> 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', -> 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', -> 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', -> 'Ohio','Oklahoma', 'Pennsylvania', 'Rhode Island', 'South Carolina', -> 'South Dakota','Tennessee', 'Texas', 'Utah', 'Vermont','Virginia', 'Washington', -> 'West Virginia', 'Wisconsin', 'Wyoming','District of Columbia', 'Alberta', -> 'British Columbia', 'Manitoba', 'New Brunswick', 'Newfoundland- Larb', -> 'Northwest Territories', 'Nova Scotia', 'Nunavut', 'Ontario', 'Prince Edward Island',
  • 299. 298 -> 'Quebec', 'Saskatchewan', 'Yukon' ) not null, -> State_Abbrv ENUM( 'AL', 'AK','AZ', 'AR', -> 'CA', 'CO', 'CT','DE','FL', 'GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD', 'MA', -> 'MI','MN','MS','MO','MT','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR' ,'PA','RI','SC','SD','TN', -> 'TX','UT','VA','WA','WV', 'WI','WY','DC','AB','BC','MB','NB','NL','NT','NS','NU', -> 'ON', 'PE','QC', 'SK', 'YT' ) not null, -> State_TaxRate integer not null, -> constraint statecodes_statecode_pk primary key(State_ID, Country_Code), -> constraint statecodes_statecode_uk unique (State_ID), -> constraint Statecode_countrycode_fk foreign key (Country_Code) references -> HowardR.CountryCode(Country_Code) -> ) Engine = InnoDB ; Query OK, 0 rows affected (1.38 sec) mysql> mysql> Create table statecodesAudit -> (State_ID integer, -> Country_Code integer, -> State_Name varchar(110), -> State_Abbrv Varchar(10), -> State_TaxRate integer not null, -> Old_StateID integer , -> Old_CountryCode integer, -> Old_StateName varchar(110), -> Old_State_Abbrv Varchar(10), -> Old_StTaxRate integer, -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> Audit_Date timestamp, -> Audit_User varchar(50), -> constraint statecodesaudit_auditid_pk primary key(Audit_ID) -> )Engine = InnoDB ; Query OK, 0 rows affected (0.44 sec) mysql> create table HowardR.Customer -> (Customer_ID Integer, -> State_ID Integer, -> First_Name Varchar(50) not null, -> Middle_Name Varchar(50), -> Last_Name Varchar(50) not null, -> Address Varchar(50) not null, -> City Varchar(45) not null, -> Phone Varchar(25) not null, -> DOB DATE not null, -> CONSTRAINT Customer_custid_pk primary key(Customer_ID, State_ID), -> CONSTRAINT Customer_custid_uk unique(Customer_ID), -> CONSTRAINT Customer_stateid_pk foreign key(state_id) references HowardR.statecodes(state_id) -> ) Engine = InnoDB ; Query OK, 0 rows affected (1.28 sec)
  • 300. 299 mysql> Create table HowardR.CustomerAudit -> (ustomer_ID Integer, -> State_ID Integer, -> First_Name Varchar(50), -> Middle_Name Varchar(50), -> Last_Name Varchar(50), -> Address Varchar(50), -> City Varchar(45), -> Phone Varchar(25), -> DOB DATE, -> Old_CustomerID Integer, -> Old_StateID Integer, -> Old_FirstName Varchar(50), -> Old_MiddleName Varchar(50), -> Old_LastName Varchar(50), -> Old_Address Varchar(50), -> Old_City Varchar(45), -> Old_Phone Varchar(25), -> Old_DOB DATE, -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> Audit_Date timestamp, -> Audit_User varchar(50), -> constraint customeraudit_auditid_pk primary key(Audit_ID) -> ) -> Engine = InnoDB ; Query OK, 0 rows affected (0.96 sec) mysql> create table HowardR.Employee -> (Employee_ID integer AUTO_INCREMENT, -> First_Name varchar(55) not null, -> Middle_Name varchar(55), -> Last_Name Varchar(55) not null, -> Address varchar(55) not null, -> City Varchar(45) not null, -> State_ID Integer, -> Phone Varchar(45) not null, -> constraint employee_empid_pk primary key(Employee_ID,State_ID), -> constraint employee_empid_uk unique (Employee_ID), -> constraint employee_stateid_fk foreign key (State_ID) references HowardR.statecodes(State_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (1.21 sec) mysql> mysql> mysql> create table HowardR.EmployeeAudit -> (Employee_ID integer , -> First_Name varchar(55), -> Middle_Name varchar(55), -> Last_Name Varchar(55), -> Address varchar(55), -> City Varchar(45), -> State_ID Integer, -> Phone Varchar(45),
  • 301. 300 -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT, -> Action_Type char(20), -> Old_Employee_ID integer, -> Old_First_Name varchar(55), -> Old_Middle_Name varchar(55), -> Old_Last_Name Varchar(55), -> Old_Address varchar(55), -> Old_City Varchar(45), -> Old_State_ID Integer, -> Old_Phone Varchar(45), -> constraint employeeaudit_auditid_pk primary key(Audit_ID) -> )Engine = InnoDB ; Query OK, 0 rows affected (0.44 sec) mysql> create table HowardR.HRRoles -> (Role_ID integer AUTO_INCREMENT, -> Role_Title varchar(45) not null, -> Role_status varchar(45) not null, -> constraint HRRoles_roleid_pk primary key(Role_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.45 sec) mysql> mysql> create table HowardR.HRRolesAudit -> (Role_ID integer , -> Role_Title varchar(45), -> Role_status varchar(45), -> Old_RoleID integer, -> Old_RoleTitle varchar(45), -> Old_Role_status varchar(45), -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT, -> Action_Type char(20), -> constraint HRRoleAdt_AuditID_PK PRIMARY KEY(Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (1.14 sec) mysql> create table HowardR.store -> (Store_ID Integer AUTO_INCREMENT, -> Store_StateID Integer, -> Store_Name Varchar(65) not null , -> Store_Type Varchar(34) not null , -> Store_Address Varchar (65) not null , -> Store_City Varchar(45) not null , -> Store_Phone Varchar (45) not null , -> Store_Status Varchar (30) not null , -> constraint store_storeid_pk primary key(Store_ID,Store_StateID), -> constraint store_storestateid_fk foreign key(store_stateid) references statecodes(state_id), -> constraint store_storeid_uk unique (store_id) -> )Engine = InnoDB ; Query OK, 0 rows affected (1.13 sec)
  • 302. 301 mysql> create table HowardR.storeAudit -> (Store_ID Integer , -> Store_StateID Integer, -> Store_Name Varchar(65), -> Store_Type Varchar(34), -> Store_Address Varchar(65), -> Store_City Varchar(45), -> Store_Phone Varchar(45), -> Store_Status Varchar(30), -> Old_StoreID Integer, -> Old_StorStateID Integer, -> Old_StorName Varchar(65), -> Old_StorType Varchar(34), -> Old_StorAddress Varchar(65), -> Old_StorCity Varchar(45), -> old_StorPhone Varchar(45), -> old_StorStatus Varchar(30), -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT, -> Action_Type char(20), -> constraint storeaudit_AuditID_pk primary key (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.41 sec) mysql> create table HowardR.Management -> (Manager_ID integer AUTO_INCREMENT, -> Employee_ID integer, -> Hire_Date Date not null, -> Hire_EndDate Date, -> store_id integer not null, -> constraint Management_Magerid_pk primary key(Manager_ID,Employee_ID, store_id), -> constraint Management_Magerid_uk unique(Manager_ID), -> constraint Management_empid_fk foreign key(Employee_ID) references Employee(Employee_ID), -> constraint Management_storeid_fk foreign key (Store_ID) references store (store_id) -> ) Engine = InnoDB ; Query OK, 0 rows affected (1.55 sec) mysql> mysql> Alter table Management -> add constraint management_managerid_fk foreign key(Manager_id) references management(manager_id); Query OK, 0 rows affected (2.28 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create table HowardR.ManagementAudit -> (Manager_ID integer , -> Employee_ID integer, -> Store_ID integer, -> Hire_Date Date, -> Hire_EndDate Date, -> Old_ManagerID integer, -> Old_EmployeeID integer,
  • 303. 302 -> Old_HireDate Date, -> Old_HireEndDate Date, -> Old_StoreID Integer, -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint managementAudt_AuditID_pk primary key (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.57 sec) mysql> mysql> mysql> Create table HowardR.HRRecords -> (Employee_ID Integer AUTO_INCREMENT, -> HR_ID Integer Not null, -> Role_ID Integer not null, -> Store_ID integer not null, -> DOB Date not null, -> Manager_id INTEGER, -> Social_SecurityNum Integer, -> Hire_Date Date , -> End_Date Date, -> PayRate numeric(15,2) not null, -> Employement_Status varchar(45) not null, -> constraint HrRecord_hrid_pk primary key(Employee_ID,HR_ID,Role_ID,Store_ID, Manager_ID), -> constraint HrRecord_hri_uk unique (HR_ID), -> constraint HrRecord_empid_fk foreign key(Employee_ID) references HowardR.Employee(Employee_ID) , -> constraint HrRecord_roleid_fk foreign key(Role_ID) references HowardR.HRRoles(Role_ID), -> constraint HrRecord_storeid_fk foreign key(store_id) references HowardR.store(store_id), -> constraint HrRecords_managerid_fk foreign key(manager_id) references management(manager_id) -> )Engine = InnoDB ; Query OK, 0 rows affected (2.33 sec) mysql> mysql> mysql> Create table HowardR.HRRecordsAudit -> (Employee_ID Integer , -> HR_ID Integer , -> Role_ID Integer, -> Store_ID integer, -> DOB Date, -> Social_SecurityNum Integer, -> Hire_Date Date, -> End_Date Date, -> PayRate numeric(15,2), -> Manager_ID integer, -> Old_Managerid integer, -> Employement_Status varchar(45), -> Old_EmployeeID Integer, -> Old_HRID Integer,
  • 304. 303 -> Old_RoleID Integer, -> Old_StoreID integer, -> Old_DOB Date, -> Old_SocialSecurityNum Integer, -> Old_HireDate Date, -> Old_EndDate Date, -> Old_PayRate numeric(15,2), -> Old_EmployementStatus varchar(45), -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT, -> Action_Type char(20), -> Constraint HRRecordsAudit_AuditID_pk primary key (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.38 sec) mysql> create table HowardR.ProductCategory -> (Product_CategoryID Integer, -> Category_Name Varchar(45) not null, -> Category_Description text, -> constraint Prodcategory_prodcategory_pk primary key(Product_CategoryID) -> )Engine = InnoDB -> ; Query OK, 0 rows affected (0.34 sec) mysql> create table HowardR.ProductCategoryAudit -> (Product_CategoryID Integer, -> Category_Name Varchar(45) , -> Category_Description text, -> Old_ProdCategoryID Integer, -> Old_CategoName Varchar(45) , -> Old_CategoDescription text, -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint ProdcategoAudt_AuditID_pk primary key (Audit_ID) -> )Engine = InnoDB ; Query OK, 0 rows affected (0.54 sec) mysql> mysql> create table HowardR.product -> (Product_ID Integer AUTO_INCREMENT, -> Product_CategoryID Integer, -> Product_Name Varchar(50) not null, -> Product_Color Varchar(35), -> Product_Size Varchar(35), -> Product_Weight Varchar(45), -> Product_Description text, -> constraint Product_Prodid_pk primary key(Product_ID,Product_CategoryID), -> constraint product_prodid_uk unique (Product_ID), -> constraint product_prodcategoid_fk foreign key(Product_CategoryID) references HowardR.ProductCategory (Product_CategoryID)
  • 305. 304 -> )Engine = InnoDB ; Query OK, 0 rows affected (1.09 sec) mysql> mysql> create table HowardR.Receipt -> (Receipt_ID Integer AUTO_INCREMENT, -> Employee_ID integer, -> Customer_ID integer, -> Store_ID integer, -> Product_ID Integer, -> Receipt_Amount decimal (8,2) not null , -> Receipt_Tax decimal (8,2) not null, -> QTY Integer not null, -> Receipt_FinalAmt decimal (8,2) not null, -> constraint Receipt_Receipid_pk primary key(Receipt_ID,Employee_ID,Customer_ID,Store_ID -> ,Product_ID), -> constraint Receipt_Receiptid_uk unique (Receipt_ID) -> )Engine = InnoDB ; Query OK, 0 rows affected (1.18 sec) mysql> mysql> mysql> Alter table receipt -> add constraint receipt_customerid_fk foreign key(customer_id) references customer(customer_id); Query OK, 0 rows affected (2.23 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table receipt -> add constraint receipt_Employeeid_fk foreign key(Employee_ID) References Employee(Employee_id); Query OK, 0 rows affected (3.55 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table receipt -> add constraint receipt_storeid_fk foreign key(store_id) references store(store_id); Query OK, 0 rows affected (3.53 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table receipt -> add constraint receipt_productid_fk foreign key(product_id) references product(product_id); Query OK, 0 rows affected (4.75 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table receipt -> add receipt_date date; Query OK, 0 rows affected (5.32 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> desc receiptaudit; ERROR 1146 (42S02): Table 'howardr.receiptaudit' doesn't exist
  • 306. 305 mysql> desc receiptaudit; ERROR 1146 (42S02): Table 'howardr.receiptaudit' doesn't exist mysql> mysql> mysql> create table HowardR.Receiptaudit -> (Receipt_ID Integer , -> Employee_ID integer, -> Customer_ID integer, -> Store_ID integer, -> Product_ID Integer, -> Receipt_Amount decimal (8,2) , -> Receipt_Tax decimal (8,2) , -> QTY Integer , -> Receipt_FinalAmt decimal (8,2), -> Old_ReceiptID Integer, -> Old_EmployeeID integer, -> Old_CustomerID integer, -> Old_Store_ID integer, -> Old_Product_ID Integer, -> Old_Receipt_Amount decimal (8,2) , -> Old_Receipt_Tax decimal (8,2) , -> Old_QTY Integer , -> Old_ReceiptFinalAmt decimal (8,2), -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint Receipt_AuditID_pk primary key (Audit_ID) -> ); Query OK, 0 rows affected (0.50 sec) mysql> alter table Receiptaudit -> add receipt_date date; Query OK, 0 rows affected (1.06 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> alter table receiptaudit -> add old_receiptdate date; Query OK, 0 rows affected (1.83 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create table HowardR.PaymentCop -> (Payment_id integer AUTO_INCREMENT, -> Payment_CopName Varchar(50) not null, -> Payment_Type ENUM('VISA','MasterCard', 'Discovery','American Express','NA') not null, -> Payment_CreatedDate Date, -> Payment_Status varchar(25), -> PaymentCard_Number integer not null, -> Receipt_ID integer Not Null, -> payment_expdate date, -> constraint PaymentCop_paymentid_pk primary key(Payment_id, Receipt_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.69 sec)
  • 307. 306 mysql> Alter table Paymentcop -> add constraint paymentcop_paymentid_uk unique (Payment_ID); Query OK, 0 rows affected (0.77 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table Paymentcop -> add constraint PaymentCop_Receiptid_fk foreign key (receipt_id) references receipt(receipt_id); Query OK, 0 rows affected (1.74 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> Alter table Paymentcop -> add authorized_Amount Decimal(8,2); Query OK, 0 rows affected (2.46 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> mysql> create table HowardR.PaymentCopAudit -> (Payment_id integer, -> Payment_CopName Varchar(50) , -> Payment_Type char(35), -> Payment_CreatedDate Date, -> Payment_Status varchar(25), -> PaymentCard_Number integer , -> Receipt_ID integer , -> payment_expdate date, -> old_paymentExDate date, -> authorized_Amount Decimal(8,2), -> Old_Paymentid integer , -> Old_PayCopName Varchar(50), -> Old_PaynebtType char(35), -> Old_PayCreatedDate Date, -> Old_PaymentStatus varchar(25), -> Old_PayCardNum integer, -> Old_AuthordAmt Decimal(8,2), -> old_ReceiptID integer , -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint PaycopAudit_AuditID_pk primary key (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.42 sec) mysql> mysql> create table HowardR.shippingco -> (shipper_id integer AUTO_INCREMENT, -> Shipper_Name Varchar(50), -> status char(25), -> Create_date date, -> constraint shippingco_shipperid_pk primary key(shipper_id) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.40 sec)
  • 308. 307 mysql> mysql> create table HowardR.shippingcoAudit -> (shipper_id integer, -> Shipper_Name Varchar(50), -> status char(25), -> Create_date date, -> Old_shipperid integer, -> old_ShipperName Varchar(50), -> old_status char(25), -> old_Create_date date, -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT, -> Action_Type char(20), -> constraint shippingcoAudit_auditid_pk primary key(Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.69 sec) mysql> mysql> create table HowardR.shipment -> (shipping_id integer AUTO_INCREMENT, -> shipper_id integer, -> state_id integer, -> Receipt_ID integer, -> ship_date date, -> ship_enddate date, -> receive_date date, -> Name varchar(55) not null, -> Address Varchar(55) not null, -> City varchar(55) not null, -> shipping_amount NUMERIC not null, -> shipping_type char(35) not null, -> constraint shipment_shipmentid_pk primary key (shipping_id,shipper_id), -> constraint shipment_shipmentid_uk unique(shipping_id), -> constraint shipment_shipperid_fk foreign key(shipper_id) references shippingco(shipper_id) -> ) -> Engine = InnoDB ; Query OK, 0 rows affected (1.24 sec) mysql> mysql> create table HowardR.shipmentAudit -> (shipping_id integer, -> shipper_id integer, -> state_id integer, -> Receipt_ID integer, -> ship_date date, -> ship_enddate date, -> receive_date date, -> Name varchar(55), -> Address Varchar(55), -> City varchar(55), -> shipping_amount NUMERIC, -> shipping_type char(35), -> old_shippingid integer, -> old_shipperid integer,
  • 309. 308 -> old_stateid integer, -> old_ReceiptID integer, -> old_shipdate date, -> old_shipenddate date, -> old_receivedate date, -> old_Name varchar(55), -> old_Address Varchar(55), -> old_City varchar(55), -> old_shippingamt NUMERIC, -> old_shippingtype char(35), -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> CONSTRAINT shipaudit_AUDITID_PK PRIMARY KEY (Audit_ID) -> ) Engine = InnoDB ; Query OK, 0 rows affected (0.46 sec) mysql> mysql> mysql> create table HowardR.productAudit -> (Product_ID Integer , -> Product_CategoryID Integer, -> Product_Name Varchar(50) , -> Product_Color Varchar(35), -> Product_Size Varchar(35), -> Product_Weight Varchar(45), -> Product_Description text, -> Old_ProductID Integer , -> Old_ProductCategoryID Integer, -> Old_Product_Name Varchar(50) , -> Old_ProductColor Varchar(35), -> Old_ProductSize Varchar(35), -> Old_Product_Weight Varchar(45), -> Old_ProductDescription text, -> Audit_Date timestamp, -> Audit_User varchar(50), -> Audit_ID integer AUTO_INCREMENT , -> Action_Type char(20), -> constraint ProductAudit_AuditID_pk primary key (Audit_ID) -> )Engine = InnoDB ; Query OK, 0 rows affected (0.52 sec)
  • 310. 309 Indexes mysql> mysql> mysql> mysql> USE HOWARDR; Database changed mysql> create index country_countryname_idx using -> btree on HowardR.countrycode (Country_Name); Query OK, 0 rows affected (1.08 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index country_countryabbrv_indx using btree -> on HowardR.countrycode (Country_Abbrv); Query OK, 0 rows affected (1.23 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index statecodes_statename_indx using -> btree on HowardR.statecodes (State_Name); Query OK, 0 rows affected (1.71 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index statecodes_StateAbbrv_indx using btree -> on HowardR.statecodes (State_Abbrv); Query OK, 0 rows affected (1.54 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index statecodes_TaxRate_indx using btree -> on HowardR.statecodes (State_TaxRate) -> -> ; Query OK, 0 rows affected (1.70 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index Employee_FirstName_indx using -> btree on HowardR.Employee (First_Name); Query OK, 0 rows affected (1.87 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index Employee_city_indx using btree -> on HowardR.employee (City); Query OK, 0 rows affected (1.86 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index HRRecords_DOB_indx using HASH -> on HowardR.HRRecords (DOB); Query OK, 0 rows affected (3.24 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>
  • 311. 310 mysql> mysql> create index HRRecords_SNN_indx using HASH -> on HowardR.HRRecords (Social_SecurityNum); Query OK, 0 rows affected (3.80 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index Management_HireDate_indx using BTREE -> on HowardR.Management (Manager_ID); Query OK, 0 rows affected (1.53 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index store_StoreName_indx using BTREE -> on HowardR.store (Store_Name); Query OK, 0 rows affected (1.55 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> mysql> create index store_StoreType_indx using BTREE -> on HowardR.store (Store_Type); Query OK, 0 rows affected (1.82 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> mysql> create index store_StoreCity_indx using BTREE -> on HowardR.store (Store_City); Query OK, 0 rows affected (2.34 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> mysql> create index customer_firstname_indx using BTREE -> on HowardR.customer (First_Name); Query OK, 0 rows affected (1.99 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index customer_lastname_indx using BTREE -> on HowardR.customer (Last_name); Query OK, 0 rows affected (1.70 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index customer_city_indx using BTREE -> on HowardR.customer (city); Query OK, 0 rows affected (2.75 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> create index customer_address_indx using BTREE -> on HowardR.customer (address); Query OK, 0 rows affected (2.35 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index ProductCategory_CategoryName_indx using BTREE
  • 312. 311 -> on HowardR.ProductCategory (Category_Name); Query OK, 0 rows affected (0.92 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create index product_ProductName_indx using BTREE -> on HowardR.product (Product_Name); Query OK, 0 rows affected (1.49 sec) Records: 0 Duplicates: 0 Warnings: 0 Triggers
  • 313. 312
  • 314. 313
  • 315. 314
  • 316. 315
  • 317. 316 Database Altration
  • 318. 317
  • 319. 318
  • 320. 319 The triggers were recreated after the paymentcop, shipment and receipt tables were dropped due to a database error.
  • 321. 320 Data Population
  • 322. 321
  • 323. 322
  • 324. 323
  • 325. 324
  • 326. 325
  • 327. 326
  • 328. 327
  • 329. 328 Database Dictionary
  • 330. 329 Database Physical Diagram
  • 331. 330 Database Dictinoary mysql> mysql> USE HOWARDR; Database changed mysql> mysql> mysql> mysql> mysql> mysql> DESC CUSTOMER; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | Customer_ID | int(11) | NO | PRI | NULL | auto_increment | | State_ID | int(11) | NO | PRI | NULL | | | First_Name | varchar(50) | NO | MUL | NULL | | | Middle_Name | varchar(50) | YES | | NULL | | | Last_Name | varchar(50) | NO | MUL | NULL | | | Address | varchar(50) | NO | MUL | NULL | | | City | varchar(45) | NO | MUL | NULL | | | Phone | varchar(25) | NO | | NULL | | | DOB | date | NO | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 9 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM CUSTOMERG *************************** 1. row *************************** Field: Customer_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: State_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: First_Name Type: varchar(50) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment:
  • 332. 331 *************************** 4. row *************************** Field: Middle_Name Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Last_Name Type: varchar(50) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: Address Type: varchar(50) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: City Type: varchar(45) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Phone Type: varchar(25) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: DOB Type: date Collation: NULL Null: NO Key: Default: NULL
  • 333. 332 Extra: Privileges: select,insert,update,references Comment: 9 rows in set (0.03 sec) mysql> SHOW INDEXES FROM CUSTOMERG *************************** 1. row *************************** Table: customer Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Customer_ID Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 2. row *************************** Table: customer Non_unique: 0 Key_name: PRIMARY Seq_in_index: 2 Column_name: State_ID Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 3. row *************************** Table: customer Non_unique: 0 Key_name: Customer_custid_uk Seq_in_index: 1 Column_name: Customer_ID Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 4. row *************************** Table: customer Non_unique: 1 Key_name: customer_firstname_indx Seq_in_index: 1 Column_name: First_Name Collation: A Cardinality: 23 Sub_part: NULL
  • 334. 333 Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 5. row *************************** Table: customer Non_unique: 1 Key_name: customer_lastname_indx Seq_in_index: 1 Column_name: Last_Name Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 6. row *************************** Table: customer Non_unique: 1 Key_name: customer_city_indx Seq_in_index: 1 Column_name: City Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 7. row *************************** Table: customer Non_unique: 1 Key_name: customer_address_indx Seq_in_index: 1 Column_name: Address Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 8. row *************************** Table: customer Non_unique: 1 Key_name: Customer_stateid_pk Seq_in_index: 1 Column_name: State_ID Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL
  • 335. 334 Null: Index_type: BTREE Comment: Index_comment: 8 rows in set (0.00 sec) mysql> DESCRIBE CUSTOMERAUDIT; +----------------+-------------+------+-----+-------------------+--------- --------------------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+-------------------+--------- --------------------+ | Customer_ID | int(11) | YES | | NULL | | | State_ID | int(11) | YES | | NULL | | | First_Name | varchar(50) | YES | | NULL | | | Middle_Name | varchar(50) | YES | | NULL | | | Last_Name | varchar(50) | YES | | NULL | | | Address | varchar(50) | YES | | NULL | | | City | varchar(45) | YES | | NULL | | | Phone | varchar(25) | YES | | NULL | | | DOB | date | YES | | NULL | | | Old_CustomerID | int(11) | YES | | NULL | | | Old_StateID | int(11) | YES | | NULL | | | Old_FirstName | varchar(50) | YES | | NULL | | | Old_MiddleName | varchar(50) | YES | | NULL | | | Old_LastName | varchar(50) | YES | | NULL | | | Old_Address | varchar(50) | YES | | NULL | | | Old_City | varchar(45) | YES | | NULL | | | Old_Phone | varchar(25) | YES | | NULL | | | Old_DOB | date | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment | | Action_Type | char(20) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | |
  • 336. 335 +----------------+-------------+------+-----+-------------------+--------- --------------------+ 22 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM CUSTOMERAUDITG *************************** 1. row *************************** Field: Customer_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: State_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: First_Name Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Middle_Name Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Last_Name Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: Address
  • 337. 336 Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: City Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Phone Type: varchar(25) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: DOB Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: Old_CustomerID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 11. row *************************** Field: Old_StateID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references
  • 338. 337 Comment: *************************** 12. row *************************** Field: Old_FirstName Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 13. row *************************** Field: Old_MiddleName Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 14. row *************************** Field: Old_LastName Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 15. row *************************** Field: Old_Address Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 16. row *************************** Field: Old_City Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 17. row *************************** Field: Old_Phone Type: varchar(25) Collation: utf8_general_ci Null: YES Key:
  • 339. 338 Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 18. row *************************** Field: Old_DOB Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 19. row *************************** Field: Audit_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 20. row *************************** Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 21. row *************************** Field: Audit_Date Type: timestamp Collation: NULL Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 22. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 22 rows in set (0.05 sec) mysql> SHOW INDEXES FROM CUSTOMERAUDITG
  • 340. 339 *************************** 1. row *************************** Table: customeraudit Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 23 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> DESCRIBE COUNTRYCODE; +---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+----------------+ | Country_Code | int(11) | NO | PRI | NULL | auto_increment | | Country_Name | varchar(60) | NO | MUL | NULL | | | Country_Abbrv | varchar(12) | NO | MUL | NULL | | +---------------+-------------+------+-----+---------+----------------+ 3 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM COUNTRYCODEG *************************** 1. row *************************** Field: Country_Code Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: Country_Name Type: varchar(60) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Country_Abbrv Type: varchar(12) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment:
  • 341. 340 3 rows in set (0.03 sec) mysql> SHOW INDEXES FROM COUNTRYCODEG *************************** 1. row *************************** Table: countrycode Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Country_Code Collation: A Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 2. row *************************** Table: countrycode Non_unique: 1 Key_name: country_countryname_idx Seq_in_index: 1 Column_name: Country_Name Collation: A Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 3. row *************************** Table: countrycode Non_unique: 1 Key_name: country_countryabbrv_indx Seq_in_index: 1 Column_name: Country_Abbrv Collation: A Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 3 rows in set (0.00 sec) mysql> DESCRIBE COUNTRYCODESAUDIT; +------------------+-------------+------+-----+-------------------+------- ----------------------+ | Field | Type | Null | Key | Default | Extra | +------------------+-------------+------+-----+-------------------+------- ----------------------+ | Country_Code | int(11) | YES | | NULL | |
  • 342. 341 | Country_Name | varchar(60) | YES | | NULL | | | Country_Abbrv | varchar(12) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | | | old_countrycode | int(11) | YES | | NULL | | | old_countryname | varchar(60) | YES | | NULL | | | old_countryabbrv | varchar(12) | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment | | Action_Type | char(20) | YES | | NULL | | +------------------+-------------+------+-----+-------------------+------- ----------------------+ 10 rows in set (0.04 sec) mysql> SHOW FULL COLUMNS FROM COUNTRYCODESAUDIT G *************************** 1. row *************************** Field: Country_Code Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: Country_Name Type: varchar(60) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Country_Abbrv Type: varchar(12) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Audit_Date Type: timestamp Collation: NULL
  • 343. 342 Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: old_countrycode Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: old_countryname Type: varchar(60) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: old_countryabbrv Type: varchar(12) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: Audit_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 10. row ***************************
  • 344. 343 Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 10 rows in set (0.03 sec) mysql> SHOW INDEXES FROM COUNTRYCODESAUDIT G *************************** 1. row *************************** Table: countrycodesaudit Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> DESCRIBE EMPLOYEE; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | Employee_ID | int(11) | NO | PRI | NULL | auto_increment | | First_Name | varchar(55) | NO | MUL | NULL | | | Middle_Name | varchar(55) | YES | | NULL | | | Last_Name | varchar(55) | NO | | NULL | | | Address | varchar(55) | NO | | NULL | | | City | varchar(45) | NO | MUL | NULL | | | State_ID | int(11) | NO | PRI | 0 | | | Phone | varchar(45) | NO | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 8 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM EMPLOYEE G *************************** 1. row *************************** Field: Employee_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: First_Name Type: varchar(55)
  • 345. 344 Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Middle_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Last_Name Type: varchar(55) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Address Type: varchar(55) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: City Type: varchar(45) Collation: utf8_general_ci Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: State_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: 0 Extra: Privileges: select,insert,update,references Comment:
  • 346. 345 *************************** 8. row *************************** Field: Phone Type: varchar(45) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 8 rows in set (0.07 sec) mysql> SHOW INDEXES FROM EMPLOYEE G *************************** 1. row *************************** Table: employee Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Employee_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 2. row *************************** Table: employee Non_unique: 0 Key_name: PRIMARY Seq_in_index: 2 Column_name: State_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 3. row *************************** Table: employee Non_unique: 0 Key_name: employee_empid_uk Seq_in_index: 1 Column_name: Employee_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 4. row *************************** Table: employee
  • 347. 346 Non_unique: 1 Key_name: employee_stateid_fk Seq_in_index: 1 Column_name: State_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 5. row *************************** Table: employee Non_unique: 1 Key_name: Employee_FirstName_indx Seq_in_index: 1 Column_name: First_Name Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 6. row *************************** Table: employee Non_unique: 1 Key_name: Employee_city_indx Seq_in_index: 1 Column_name: City Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 6 rows in set (0.00 sec) mysql> DESCRIBE EMPLOYEEAUDIT; +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Employee_ID | int(11) | YES | | NULL | | | First_Name | varchar(55) | YES | | NULL | | | Middle_Name | varchar(55) | YES | | NULL | | | Last_Name | varchar(55) | YES | | NULL | |
  • 348. 347 | Address | varchar(55) | YES | | NULL | | | City | varchar(45) | YES | | NULL | | | State_ID | int(11) | YES | | NULL | | | Phone | varchar(45) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment | | Action_Type | char(20) | YES | | NULL | | | Old_Employee_ID | int(11) | YES | | NULL | | | Old_First_Name | varchar(55) | YES | | NULL | | | Old_Middle_Name | varchar(55) | YES | | NULL | | | Old_Last_Name | varchar(55) | YES | | NULL | | | Old_Address | varchar(55) | YES | | NULL | | | Old_City | varchar(45) | YES | | NULL | | | Old_State_ID | int(11) | YES | | NULL | | | Old_Phone | varchar(45) | YES | | NULL | | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ 20 rows in set (0.05 sec) mysql> SHOW INDEXES FROM EMPLOYEEAUDIT G *************************** 1. row *************************** Table: employeeaudit Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> SHOW FULL COLUMNS FROM EMPLOYEEAUDIT G *************************** 1. row *************************** Field: Employee_ID Type: int(11)
  • 349. 348 Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: First_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Middle_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Last_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Address Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: City Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment:
  • 350. 349 *************************** 7. row *************************** Field: State_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Phone Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: Audit_Date Type: timestamp Collation: NULL Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 11. row *************************** Field: Audit_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 12. row *************************** Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL
  • 351. 350 Extra: Privileges: select,insert,update,references Comment: *************************** 13. row *************************** Field: Old_Employee_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 14. row *************************** Field: Old_First_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 15. row *************************** Field: Old_Middle_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 16. row *************************** Field: Old_Last_Name Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 17. row *************************** Field: Old_Address Type: varchar(55) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 18. row *************************** Field: Old_City Type: varchar(45) Collation: utf8_general_ci
  • 352. 351 Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 19. row *************************** Field: Old_State_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 20. row *************************** Field: Old_Phone Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 20 rows in set (0.03 sec) mysql> DESCRIBE HRROLES; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | Role_ID | int(11) | NO | PRI | NULL | auto_increment | | Role_Title | varchar(45) | NO | | NULL | | | Role_status | varchar(45) | NO | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 3 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM HRROLES G *************************** 1. row *************************** Field: Role_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: Role_Title Type: varchar(45) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra:
  • 353. 352 Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Role_status Type: varchar(45) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 3 rows in set (0.03 sec) mysql> SHOW INDEXES FROM HRROLES G *************************** 1. row *************************** Table: hrroles Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Role_ID Collation: A Cardinality: 6 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.01 sec) mysql> DESCRIBE HRROLESAUDIT; +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Role_ID | int(11) | YES | | NULL | | | Role_Title | varchar(45) | YES | | NULL | | | Role_status | varchar(45) | YES | | NULL | | | Old_RoleID | int(11) | YES | | NULL | | | Old_RoleTitle | varchar(45) | YES | | NULL | | | Old_Role_status | varchar(45) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment |
  • 354. 353 | Action_Type | char(20) | YES | | NULL | | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ 10 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM HRROLESAUDIT G *************************** 1. row *************************** Field: Role_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: Role_Title Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Role_status Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Old_RoleID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Old_RoleTitle Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment:
  • 355. 354 *************************** 6. row *************************** Field: Old_Role_status Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: Audit_Date Type: timestamp Collation: NULL Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: Audit_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 10 rows in set (0.03 sec) mysql> SHOW INDEXES FROM HRROLESAUDIT G *************************** 1. row *************************** Table: hrrolesaudit Non_unique: 0 Key_name: PRIMARY
  • 356. 355 Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 6 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> DESCRIBE HRRECORDS; +--------------------+---------------+------+-----+---------+------------- ---+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------+------+-----+---------+------------- ---+ | Employee_ID | int(11) | NO | PRI | NULL | auto_increment | | HR_ID | int(11) | NO | PRI | NULL | | | Role_ID | int(11) | NO | PRI | NULL | | | Store_ID | int(11) | NO | PRI | NULL | | | DOB | date | NO | MUL | NULL | | | Manager_id | int(11) | NO | PRI | 0 | | | Social_SecurityNum | int(11) | YES | MUL | NULL | | | Hire_Date | date | YES | | NULL | | | End_Date | date | YES | | NULL | | | PayRate | decimal(15,2) | NO | | NULL | | | Employement_Status | varchar(45) | NO | | NULL | | +--------------------+---------------+------+-----+---------+------------- ---+ 11 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM HRRECORDS G *************************** 1. row *************************** Field: Employee_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row ***************************
  • 357. 356 Field: HR_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Role_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Store_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: DOB Type: date Collation: NULL Null: NO Key: MUL Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: Manager_id Type: int(11) Collation: NULL Null: NO Key: PRI Default: 0 Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: Social_SecurityNum Type: int(11) Collation: NULL Null: YES Key: MUL Default: NULL Extra:
  • 358. 357 Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Hire_Date Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: End_Date Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: PayRate Type: decimal(15,2) Collation: NULL Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 11. row *************************** Field: Employement_Status Type: varchar(45) Collation: utf8_general_ci Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 11 rows in set (0.03 sec) mysql> SHOW INDEXES FROM HRRECORDS G *************************** 1. row *************************** Table: hrrecords Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Employee_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE
  • 359. 358 Comment: Index_comment: *************************** 2. row *************************** Table: hrrecords Non_unique: 0 Key_name: PRIMARY Seq_in_index: 2 Column_name: HR_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 3. row *************************** Table: hrrecords Non_unique: 0 Key_name: PRIMARY Seq_in_index: 3 Column_name: Role_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 4. row *************************** Table: hrrecords Non_unique: 0 Key_name: PRIMARY Seq_in_index: 4 Column_name: Store_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 5. row *************************** Table: hrrecords Non_unique: 0 Key_name: PRIMARY Seq_in_index: 5 Column_name: Manager_id Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment:
  • 360. 359 Index_comment: *************************** 6. row *************************** Table: hrrecords Non_unique: 0 Key_name: HrRecord_hri_uk Seq_in_index: 1 Column_name: HR_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 7. row *************************** Table: hrrecords Non_unique: 1 Key_name: HrRecord_roleid_fk Seq_in_index: 1 Column_name: Role_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 8. row *************************** Table: hrrecords Non_unique: 1 Key_name: HrRecord_storeid_fk Seq_in_index: 1 Column_name: Store_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 9. row *************************** Table: hrrecords Non_unique: 1 Key_name: HrRecords_managerid_fk Seq_in_index: 1 Column_name: Manager_id Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment:
  • 361. 360 *************************** 10. row *************************** Table: hrrecords Non_unique: 1 Key_name: HRRecords_DOB_indx Seq_in_index: 1 Column_name: DOB Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 11. row *************************** Table: hrrecords Non_unique: 1 Key_name: HRRecords_SNN_indx Seq_in_index: 1 Column_name: Social_SecurityNum Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: Index_comment: 11 rows in set (0.00 sec) mysql> DESCRIBE HRRECORDSAUDIT; +-----------------------+---------------+------+-----+------------------- +-----------------------------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+---------------+------+-----+------------------- +-----------------------------+ | Employee_ID | int(11) | YES | | NULL | | | HR_ID | int(11) | YES | | NULL | | | Role_ID | int(11) | YES | | NULL | | | Store_ID | int(11) | YES | | NULL | | | DOB | date | YES | | NULL | | | Social_SecurityNum | int(11) | YES | | NULL | | | Hire_Date | date | YES | | NULL | | | End_Date | date | YES | | NULL | | | PayRate | decimal(15,2) | YES | | NULL | | | Manager_ID | int(11) | YES | | NULL | |
  • 362. 361 | Old_Managerid | int(11) | YES | | NULL | | | Employement_Status | varchar(45) | YES | | NULL | | | Old_EmployeeID | int(11) | YES | | NULL | | | Old_HRID | int(11) | YES | | NULL | | | Old_RoleID | int(11) | YES | | NULL | | | Old_StoreID | int(11) | YES | | NULL | | | Old_DOB | date | YES | | NULL | | | Old_SocialSecurityNum | int(11) | YES | | NULL | | | Old_HireDate | date | YES | | NULL | | | Old_EndDate | date | YES | | NULL | | | Old_PayRate | decimal(15,2) | YES | | NULL | | | Old_EmployementStatus | varchar(45) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment | | Action_Type | char(20) | YES | | NULL | | +-----------------------+---------------+------+-----+------------------- +-----------------------------+ 26 rows in set (0.04 sec) mysql> SHOW FULL COLUMNS FROM HRRECORDSAUDIT; +-----------------------+---------------+-----------------+------+-----+-- -----------------+-----------------------------+-------------------------- -------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-----------------------+---------------+-----------------+------+-----+-- -----------------+-----------------------------+-------------------------- -------+---------+ | Employee_ID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | HR_ID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Role_ID | int(11) | NULL | YES | | NULL | | select,insert,update,references | |
  • 363. 362 | Store_ID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | DOB | date | NULL | YES | | NULL | | select,insert,update,references | | | Social_SecurityNum | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Hire_Date | date | NULL | YES | | NULL | | select,insert,update,references | | | End_Date | date | NULL | YES | | NULL | | select,insert,update,references | | | PayRate | decimal(15,2) | NULL | YES | | NULL | | select,insert,update,references | | | Manager_ID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_Managerid | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Employement_Status | varchar(45) | utf8_general_ci | YES | | NULL | | select,insert,update,references | | | Old_EmployeeID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_HRID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_RoleID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_StoreID | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_DOB | date | NULL | YES | | NULL | | select,insert,update,references | | | Old_SocialSecurityNum | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | Old_HireDate | date | NULL | YES | | NULL | | select,insert,update,references | | | Old_EndDate | date | NULL | YES | | NULL | | select,insert,update,references | | | Old_PayRate | decimal(15,2) | NULL | YES | | NULL | | select,insert,update,references | | | Old_EmployementStatus | varchar(45) | utf8_general_ci | YES | | NULL | | select,insert,update,references | |
  • 364. 363 | Audit_Date | timestamp | NULL | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | select,insert,update,references | | | Audit_User | varchar(50) | utf8_general_ci | YES | | NULL | | select,insert,update,references | | | Audit_ID | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | | | Action_Type | char(20) | utf8_general_ci | YES | | NULL | | select,insert,update,references | | +-----------------------+---------------+-----------------+------+-----+-- -----------------+-----------------------------+-------------------------- -------+---------+ 26 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM HRRECORDSAUDITG *************************** 1. row *************************** Field: Employee_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: HR_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Role_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Store_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references
  • 365. 364 Comment: *************************** 5. row *************************** Field: DOB Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: Social_SecurityNum Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: Hire_Date Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: End_Date Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: PayRate Type: decimal(15,2) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: Manager_ID Type: int(11) Collation: NULL Null: YES Key:
  • 366. 365 Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 11. row *************************** Field: Old_Managerid Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 12. row *************************** Field: Employement_Status Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 13. row *************************** Field: Old_EmployeeID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 14. row *************************** Field: Old_HRID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 15. row *************************** Field: Old_RoleID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 16. row *************************** Field: Old_StoreID Type: int(11)
  • 367. 366 Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 17. row *************************** Field: Old_DOB Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 18. row *************************** Field: Old_SocialSecurityNum Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 19. row *************************** Field: Old_HireDate Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 20. row *************************** Field: Old_EndDate Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 21. row *************************** Field: Old_PayRate Type: decimal(15,2) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment:
  • 368. 367 *************************** 22. row *************************** Field: Old_EmployementStatus Type: varchar(45) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 23. row *************************** Field: Audit_Date Type: timestamp Collation: NULL Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 24. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 25. row *************************** Field: Audit_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 26. row *************************** Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 26 rows in set (0.03 sec) mysql> SHOW INDEXES FROM HRRECORDSAUDITG *************************** 1. row *************************** Table: hrrecordsaudit Non_unique: 0 Key_name: PRIMARY
  • 369. 368 Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> DESCRIBE MANAGEMENT; +--------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+----------------+ | Manager_ID | int(11) | NO | PRI | NULL | auto_increment | | Employee_ID | int(11) | NO | PRI | 0 | | | Hire_Date | date | NO | | NULL | | | Hire_EndDate | date | YES | | NULL | | | store_id | int(11) | NO | PRI | NULL | | +--------------+---------+------+-----+---------+----------------+ 5 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM MANAGEMENTG *************************** 1. row *************************** Field: Manager_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 2. row *************************** Field: Employee_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: 0 Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Hire_Date Type: date Collation: NULL Null: NO Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Hire_EndDate
  • 370. 369 Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: store_id Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: Privileges: select,insert,update,references Comment: 5 rows in set (0.05 sec) mysql> SHOW INDEXES FROM MANAGEMENTG *************************** 1. row *************************** Table: management Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Manager_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 2. row *************************** Table: management Non_unique: 0 Key_name: PRIMARY Seq_in_index: 2 Column_name: Employee_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 3. row *************************** Table: management Non_unique: 0 Key_name: PRIMARY Seq_in_index: 3 Column_name: store_id Collation: A Cardinality: 0
  • 371. 370 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 4. row *************************** Table: management Non_unique: 0 Key_name: Management_Magerid_uk Seq_in_index: 1 Column_name: Manager_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 5. row *************************** Table: management Non_unique: 1 Key_name: Management_empid_fk Seq_in_index: 1 Column_name: Employee_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 6. row *************************** Table: management Non_unique: 1 Key_name: Management_storeid_fk Seq_in_index: 1 Column_name: store_id Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: *************************** 7. row *************************** Table: management Non_unique: 1 Key_name: Management_HireDate_indx Seq_in_index: 1 Column_name: Manager_ID Collation: A Cardinality: 0 Sub_part: NULL
  • 372. 371 Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 7 rows in set (0.00 sec) mysql> DESCRIBE MANAGEMENTAUDIT; +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ | Manager_ID | int(11) | YES | | NULL | | | Employee_ID | int(11) | YES | | NULL | | | Store_ID | int(11) | YES | | NULL | | | Hire_Date | date | YES | | NULL | | | Hire_EndDate | date | YES | | NULL | | | Old_ManagerID | int(11) | YES | | NULL | | | Old_EmployeeID | int(11) | YES | | NULL | | | Old_HireDate | date | YES | | NULL | | | Old_HireEndDate | date | YES | | NULL | | | Old_StoreID | int(11) | YES | | NULL | | | Audit_Date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Audit_User | varchar(50) | YES | | NULL | | | Audit_ID | int(11) | NO | PRI | NULL | auto_increment | | Action_Type | char(20) | YES | | NULL | | +-----------------+-------------+------+-----+-------------------+-------- ---------------------+ 14 rows in set (0.26 sec) mysql> mysql> SHOW FULL COLUMNS FROM MANAGEMENTAUDIT G *************************** 1. row *************************** Field: Manager_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references
  • 373. 372 Comment: *************************** 2. row *************************** Field: Employee_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 3. row *************************** Field: Store_ID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 4. row *************************** Field: Hire_Date Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 5. row *************************** Field: Hire_EndDate Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 6. row *************************** Field: Old_ManagerID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 7. row *************************** Field: Old_EmployeeID Type: int(11) Collation: NULL Null: YES Key:
  • 374. 373 Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 8. row *************************** Field: Old_HireDate Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 9. row *************************** Field: Old_HireEndDate Type: date Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 10. row *************************** Field: Old_StoreID Type: int(11) Collation: NULL Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 11. row *************************** Field: Audit_Date Type: timestamp Collation: NULL Null: NO Key: Default: CURRENT_TIMESTAMP Extra: on update CURRENT_TIMESTAMP Privileges: select,insert,update,references Comment: *************************** 12. row *************************** Field: Audit_User Type: varchar(50) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: *************************** 13. row *************************** Field: Audit_ID Type: int(11)
  • 375. 374 Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: *************************** 14. row *************************** Field: Action_Type Type: char(20) Collation: utf8_general_ci Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references Comment: 14 rows in set (0.03 sec) mysql> SHOW INDEXES FROM MANAGEMENTAUDIT G *************************** 1. row *************************** Table: managementaudit Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: Audit_ID Collation: A Cardinality: 0 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: Index_comment: 1 row in set (0.00 sec) mysql> mysql> DESCRIBE PRODUCT; +---------------------+--------------+------+-----+---------+------------- ---+ | Field | Type | Null | Key | Default | Extra | +---------------------+--------------+------+-----+---------+------------- ---+ | Product_ID | int(11) | NO | PRI | NULL | auto_increment | | Product_CategoryID | int(11) | NO | PRI | 0 | | | Product_Name | varchar(110) | NO | MUL | NULL | | | Product_Color | varchar(35) | YES | | NULL | | | Product_Size | varchar(35) | YES | | NULL | | | Product_Weight | varchar(45) | YES | | NULL | |
  • 376. 375 | Product_Description | text | YES | | NULL | | +---------------------+--------------+------+-----+---------+------------- ---+ 7 rows in set (0.03 sec) mysql> SHOW FULL COLUMNS FROM PRODUCT G *************************** 1. row *************************** Field: Product_ID Type: int(11) Collation: NULL Null: NO Key: PRI Default: NULL Extra: auto_increment Privileges: select,insert,update,references Comment: **************************