<pre>

/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     17-12-2010 20:35:29                          */
/*==============================================================*/












drop index FK_REFERENCE_12 on dataVault.Link_CustomerCustomerDemo;

drop index FK_REFERENCE_11 on dataVault.Link_CustomerCustomerDemo;


drop index FK_REFERENCE_9 on dataVault.Link_EmployeeEmployee;


drop index FK_REFERENCE_14 on dataVault.Link_EmployeeTerritories;

drop index FK_REFERENCE_13 on dataVault.Link_EmployeeTerritories;


drop index FK_REFERENCE_6 on dataVault.Link_OrderCustShipEmpl;

drop index FK_REFERENCE_5 on dataVault.Link_OrderCustShipEmpl;

drop index FK_REFERENCE_4 on dataVault.Link_OrderCustShipEmpl;

drop index FK_REFERENCE_3 on dataVault.Link_OrderCustShipEmpl;


drop index FK_REFERENCE_2 on dataVault.Link_OrderCustShipEmpl_Prod;

drop index FK_REFERENCE_1 on dataVault.Link_OrderCustShipEmpl_Prod;


drop index FK_REFERENCE_8 on dataVault.Link_RegioTerritory;

drop index FK_REFERENCE_7 on dataVault.Link_RegioTerritory;


drop index FK_REFERENCE_18 on dataVault.Link_SupProdCat;

drop index FK_REFERENCE_17 on dataVault.Link_SupProdCat;

drop index FK_REFERENCE_15 on dataVault.Link_SupProdCat;











/*==============================================================*/
/* User: dataVault                                              */
/*==============================================================*/
create user dataVault;

/*==============================================================*/
/* User: information_schema                                     */
/*==============================================================*/
create user information_schema;

/*==============================================================*/
/* User: mysql                                                  */
/*==============================================================*/
create user mysql;

/*==============================================================*/
/* User: northwind                                              */
/*==============================================================*/
create user northwind;

/*==============================================================*/
/* User: northwind_Oud                                          */
/*==============================================================*/
create user northwind_Oud;

/*==============================================================*/
/* User: staging                                                */
/*==============================================================*/
create user staging;

/*==============================================================*/
/* User: temp                                                   */
/*==============================================================*/
create user temp;

/*==============================================================*/
/* User: test                                                   */
/*==============================================================*/
create user test;

/*==============================================================*/
/* User: wikidb                                                 */
/*==============================================================*/
create user wikidb;

/*==============================================================*/
/* User: wordpress                                              */
/*==============================================================*/
create user wordpress;

/*==============================================================*/
/* Table: Hub_Categories                                        */
/*==============================================================*/
create table dataVault.Hub_Categories
(
   CategoryID_BK        int(11),
   Category_ID          int(11) not null auto_increment,
   Category_RecSource   national varchar(15),
   Category_LoadDTS     datetime,
   primary key (Category_ID)
);

/*==============================================================*/
/* Table: Hub_CustomerDemographics                              */
/*==============================================================*/
create table dataVault.Hub_CustomerDemographics
(
   CustomerTypeID_BK    char(10),
   CustDemo_ID          int(11) not null auto_increment,
   CustDemo_RecSource   national varchar(15),
   CustDemo_LoadDTS     datetime,
   primary key (CustDemo_ID)
);

/*==============================================================*/
/* Table: Hub_Customers                                         */
/*==============================================================*/
create table dataVault.Hub_Customers
(
   CustomerID_BK        national char(5),
   Customers_ID         int(11) not null auto_increment,
   Customers_RecSource  national varchar(15),
   Customers_LoadDTS    datetime,
   primary key (Customers_ID)
);

/*==============================================================*/
/* Table: Hub_Employees                                         */
/*==============================================================*/
create table dataVault.Hub_Employees
(
   EmployeeID_BK        int(11),
   Employees_ID         int(11) not null auto_increment,
   Employees_RecSource  national varchar(15),
   Employees_LoadDTS    datetime,
   primary key (Employees_ID)
);

/*==============================================================*/
/* Table: Hub_Orders                                            */
/*==============================================================*/
create table dataVault.Hub_Orders
(
   OrderID_BK           int(11),
   Order_ID             int(11) not null auto_increment,
   Order_RecSource      national varchar(15),
   Order_LoadDTS        datetime,
   primary key (Order_ID)
);

/*==============================================================*/
/* Table: Hub_Products                                          */
/*==============================================================*/
create table dataVault.Hub_Products
(
   ProductID_BK         int(11),
   Product_ID           int(11) not null auto_increment,
   Product_RecSource    national varchar(15),
   Product_LoadDTS      datetime,
   primary key (Product_ID)
);

/*==============================================================*/
/* Table: Hub_Region                                            */
/*==============================================================*/
create table dataVault.Hub_Region
(
   RegionID_BK          int(11),
   Regio_ID             int(11) not null auto_increment,
   Regio_RecSource      national varchar(15),
   Regio_LoadDTS        datetime,
   primary key (Regio_ID)
);

/*==============================================================*/
/* Table: Hub_Shippers                                          */
/*==============================================================*/
create table dataVault.Hub_Shippers
(
   ShipperID_BK         int(11),
   Shippers_ID          int(11) not null auto_increment,
   Shippers_RecSource   national varchar(15),
   Shippers_LoadDTS     datetime,
   primary key (Shippers_ID)
);

/*==============================================================*/
/* Table: Hub_Suppliers                                         */
/*==============================================================*/
create table dataVault.Hub_Suppliers
(
   SupplierID_BK        int(11),
   Suppliers_ID         int(11) not null auto_increment,
   Suppliers_RecSource  national varchar(15),
   Suppliers_LoadDTS    datetime,
   primary key (Suppliers_ID)
);

/*==============================================================*/
/* Table: Hub_Territories                                       */
/*==============================================================*/
create table dataVault.Hub_Territories
(
   TerritoryID_BK       national varchar(20),
   Territory_ID         int(11) not null auto_increment,
   Territory_RecSource  national varchar(15),
   Territory_LoadDTS    datetime,
   primary key (Territory_ID)
);

/*==============================================================*/
/* Table: Link_CustomerCustomerDemo                             */
/*==============================================================*/
create table dataVault.Link_CustomerCustomerDemo
(
   Customers_ID         int(11) not null,
   CustDemo_ID          int(11) not null,
   CustCustDemo_ID      int(11) not null auto_increment,
   CustCustDemo_RecSource national varchar(15),
   CustCustDemo_LoadDTS datetime,
   primary key (CustCustDemo_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_11                                       */
/*==============================================================*/
create index FK_REFERENCE_11 on dataVault.Link_CustomerCustomerDemo
(
   Customers_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_12                                       */
/*==============================================================*/
create index FK_REFERENCE_12 on dataVault.Link_CustomerCustomerDemo
(
   CustDemo_ID
);

/*==============================================================*/
/* Table: Link_EmployeeEmployee                                 */
/*==============================================================*/
create table dataVault.Link_EmployeeEmployee
(
   EmployeesReportsTo_ID int(11),
   Employees_ID         int(11),
   EmployeeEmployee_ID  int(11) not null auto_increment,
   Hub_Employees_ID     int(11),
   EmployeeEmployee_RecSource national varchar(15),
   EmployeeEmployee_LoadDTS datetime,
   primary key (EmployeeEmployee_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_9                                        */
/*==============================================================*/
create index FK_REFERENCE_9 on dataVault.Link_EmployeeEmployee
(
   Employees_ID
);

/*==============================================================*/
/* Table: Link_EmployeeTerritories                              */
/*==============================================================*/
create table dataVault.Link_EmployeeTerritories
(
   Employees_ID         int(11) not null,
   Territory_ID         int(11) not null,
   EmployeeTerritories_ID int(11) not null auto_increment,
   EmployeeTerritories_RecSource national varchar(15),
   EmployeeTerritories_LoadDTS datetime,
   primary key (EmployeeTerritories_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_13                                       */
/*==============================================================*/
create index FK_REFERENCE_13 on dataVault.Link_EmployeeTerritories
(
   Employees_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_14                                       */
/*==============================================================*/
create index FK_REFERENCE_14 on dataVault.Link_EmployeeTerritories
(
   Territory_ID
);

/*==============================================================*/
/* Table: Link_OrderCustShipEmpl                                */
/*==============================================================*/
create table dataVault.Link_OrderCustShipEmpl
(
   Customers_ID         int(11) not null,
   Employees_ID         int(11) not null,
   Shippers_ID          int(11) not null,
   Order_ID             int(11) not null,
   OrderCustShipEmpl_ID int(11) not null auto_increment,
   OrderCustShipEmpl_RecSource national varchar(15),
   OrderCustShipEmpl_LoadDTS datetime,
   primary key (OrderCustShipEmpl_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_3                                        */
/*==============================================================*/
create index FK_REFERENCE_3 on dataVault.Link_OrderCustShipEmpl
(
   Customers_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_4                                        */
/*==============================================================*/
create index FK_REFERENCE_4 on dataVault.Link_OrderCustShipEmpl
(
   Employees_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_5                                        */
/*==============================================================*/
create index FK_REFERENCE_5 on dataVault.Link_OrderCustShipEmpl
(
   Shippers_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_6                                        */
/*==============================================================*/
create index FK_REFERENCE_6 on dataVault.Link_OrderCustShipEmpl
(
   Order_ID
);

/*==============================================================*/
/* Table: Link_OrderCustShipEmpl_Prod                           */
/*==============================================================*/
create table dataVault.Link_OrderCustShipEmpl_Prod
(
   OrderCustShipEmpl_ID int(11) not null,
   Product_ID           int(11) not null,
   OrderCustShipEmpl_Prod_ID int(11) not null auto_increment,
   OrderCustShipEmpl_Prod_RecSource national varchar(15),
   OrderCustShipEmpl_Prodl_LoadDTS datetime,
   primary key (OrderCustShipEmpl_Prod_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_1                                        */
/*==============================================================*/
create index FK_REFERENCE_1 on dataVault.Link_OrderCustShipEmpl_Prod
(
   Product_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_2                                        */
/*==============================================================*/
create index FK_REFERENCE_2 on dataVault.Link_OrderCustShipEmpl_Prod
(
   OrderCustShipEmpl_ID
);

/*==============================================================*/
/* Table: Link_RegioTerritory                                   */
/*==============================================================*/
create table dataVault.Link_RegioTerritory
(
   Regio_ID             int(11) not null,
   Territory_ID         int(11) not null,
   RegioTerritory_ID    int(11) not null auto_increment,
   RegioTerritory_RecSource national varchar(15),
   RegioTerritory_LoadDTS datetime,
   primary key (RegioTerritory_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_7                                        */
/*==============================================================*/
create index FK_REFERENCE_7 on dataVault.Link_RegioTerritory
(
   Regio_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_8                                        */
/*==============================================================*/
create index FK_REFERENCE_8 on dataVault.Link_RegioTerritory
(
   Territory_ID
);

/*==============================================================*/
/* Table: Link_SupProdCat                                       */
/*==============================================================*/
create table dataVault.Link_SupProdCat
(
   Suppliers_ID         int(11) not null,
   Category_ID          int(11) not null,
   Product_ID           int(11),
   SupProdCat_ID        int(11) not null auto_increment,
   SupProdCat_RecSource national varchar(15),
   SupProdCat_LoadDTS   datetime,
   primary key (SupProdCat_ID)
);

/*==============================================================*/
/* Index: FK_REFERENCE_15                                       */
/*==============================================================*/
create index FK_REFERENCE_15 on dataVault.Link_SupProdCat
(
   Suppliers_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_17                                       */
/*==============================================================*/
create index FK_REFERENCE_17 on dataVault.Link_SupProdCat
(
   Category_ID
);

/*==============================================================*/
/* Index: FK_REFERENCE_18                                       */
/*==============================================================*/
create index FK_REFERENCE_18 on dataVault.Link_SupProdCat
(
   Product_ID
);

/*==============================================================*/
/* Table: Sat_Categories                                        */
/*==============================================================*/
create table dataVault.Sat_Categories
(
   CategoryName         national varchar(15),
   Description          longblob,
   Picture              longblob,
   Category_ID          int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (Category_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_CustomerDemographics                              */
/*==============================================================*/
create table Sat_CustomerDemographics
(
   CustDemo_ID          int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   CustomerDesc         longblob,
   primary key (CustDemo_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_Customers                                         */
/*==============================================================*/
create table dataVault.Sat_Customers
(
   Address              national varchar(60),
   City                 national varchar(15),
   CompanyName          national varchar(40),
   ContactName          national varchar(40),
   ContactTitle         national varchar(30),
   Country              national varchar(15),
   Fax                  national varchar(24),
   Phone                national varchar(24),
   PostalCode           national varchar(10),
   Region               national varchar(15),
   Customers_ID         int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (Sat_LoadDTS, Customers_ID)
);

/*==============================================================*/
/* Table: Sat_Employees                                         */
/*==============================================================*/
create table dataVault.Sat_Employees
(
   Address              national varchar(60),
   BirthDate            datetime,
   City                 national varchar(15),
   Country              national varchar(15),
   Extension            national varchar(4),
   FirstName            national varchar(10),
   HireDate             datetime,
   HomePhone            national varchar(24),
   LastName             national varchar(20),
   Notes                longblob,
   Photo                longblob,
   PhotoPath            national varchar(255),
   PostalCode           national varchar(10),
   Region               national varchar(15),
   Title                national varchar(30),
   TitleOfCourtesy      national varchar(25),
   Employees_ID         int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (Employees_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_OrderCustShipEmpl                                 */
/*==============================================================*/
create table dataVault.Sat_OrderCustShipEmpl
(
   Freight              float(8,2),
   OrderDate            national varchar(40),
   RequiredDate         national varchar(40),
   ShipAddress          national varchar(60),
   ShipCity             national varchar(15),
   ShipCountry          national varchar(15),
   ShipName             national varchar(40),
   ShippedDate          national varchar(40),
   ShipPostalCode       national varchar(10),
   ShipRegion           national varchar(15),
   OrderCustShipEmpl_ID int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (OrderCustShipEmpl_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_OrderCustShipEmpl_Prod                            */
/*==============================================================*/
create table dataVault.Sat_OrderCustShipEmpl_Prod
(
   Discount             double,
   Quantity             smallint(6),
   UnitPrice            float(8,2),
   OrderCustShipEmpl_Prod_ID int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (OrderCustShipEmpl_Prod_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_Products                                          */
/*==============================================================*/
create table dataVault.Sat_Products
(
   ProductName          national varchar(40),
   Discontinued         varchar(11),
   QuantityPerUnit      national varchar(20),
   ReorderLevel         smallint(6),
   UnitPrice            float(8,2),
   UnitsInStock         smallint(6),
   UnitsOnOrder         smallint(6),
   Product_ID           int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (Product_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_Shippers                                          */
/*==============================================================*/
create table dataVault.Sat_Shippers
(
   CompanyName          national varchar(40),
   Phone                national varchar(24),
   Shippers_ID          int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   primary key (Shippers_ID, Sat_LoadDTS)
);

/*==============================================================*/
/* Table: Sat_Suppliers                                         */
/*==============================================================*/
create table dataVault.Sat_Suppliers
(
   Suppliers_ID         int(11) not null,
   Sat_LoadDTS          datetime not null,
   Sat_EndDTS           datetime,
   Address              national varchar(60),
   City                 national varchar(15),
   CompanyName          national varchar(40),
   ContactName          national varchar(30),
   ContactTitle         national varchar(30),
   Country              national varchar(15),
   Fax                  national varchar(24),
   HomePage             longblob,
   Phone                national varchar(24),
   PostalCode           national varchar(10),
   Region               national varchar(15),
   key Suppliers_ID (Suppliers_ID, Sat_LoadDTS)
);

alter table dataVault.Link_CustomerCustomerDemo add constraint FK_REFERENCE_18 foreign key (Customers_ID)
      references dataVault.Hub_Customers (Customers_ID) on delete restrict on update restrict;

alter table dataVault.Link_CustomerCustomerDemo add constraint FK_REFERENCE_19 foreign key (CustDemo_ID)
      references dataVault.Hub_CustomerDemographics (CustDemo_ID) on delete restrict on update restrict;

alter table dataVault.Link_EmployeeEmployee add constraint FK_REFERENCE_10 foreign key (Hub_Employees_ID)
      references dataVault.Hub_Employees (Employees_ID) on delete restrict on update restrict;

alter table dataVault.Link_EmployeeEmployee add constraint FK_REFERENCE_9 foreign key (Employees_ID)
      references dataVault.Hub_Employees (Employees_ID) on delete restrict on update restrict;

alter table dataVault.Link_EmployeeTerritories add constraint FK_REFERENCE_11 foreign key (Employees_ID)
      references dataVault.Hub_Employees (Employees_ID) on delete restrict on update restrict;

alter table dataVault.Link_EmployeeTerritories add constraint FK_REFERENCE_12 foreign key (Territory_ID)
      references dataVault.Hub_Territories (Territory_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl add constraint FK_REFERENCE_5 foreign key (Order_ID)
      references dataVault.Hub_Orders (Order_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl add constraint FK_REFERENCE_6 foreign key (Customers_ID)
      references dataVault.Hub_Customers (Customers_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl add constraint FK_REFERENCE_7 foreign key (Employees_ID)
      references dataVault.Hub_Employees (Employees_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl add constraint FK_REFERENCE_8 foreign key (Shippers_ID)
      references dataVault.Hub_Shippers (Shippers_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl_Prod add constraint FK_REFERENCE_24 foreign key (OrderCustShipEmpl_ID)
      references dataVault.Link_OrderCustShipEmpl (OrderCustShipEmpl_ID) on delete restrict on update restrict;

alter table dataVault.Link_OrderCustShipEmpl_Prod add constraint FK_REFERENCE_3 foreign key (Product_ID)
      references dataVault.Hub_Products (Product_ID) on delete restrict on update restrict;

alter table dataVault.Link_RegioTerritory add constraint FK_REFERENCE_13 foreign key (Territory_ID)
      references dataVault.Hub_Territories (Territory_ID) on delete restrict on update restrict;

alter table dataVault.Link_RegioTerritory add constraint FK_REFERENCE_14 foreign key (Regio_ID)
      references dataVault.Hub_Region (Regio_ID) on delete restrict on update restrict;

alter table dataVault.Link_SupProdCat add constraint FK_REFERENCE_1 foreign key (Suppliers_ID)
      references dataVault.Hub_Suppliers (Suppliers_ID) on delete restrict on update restrict;

alter table dataVault.Link_SupProdCat add constraint FK_REFERENCE_21 foreign key (Category_ID)
      references dataVault.Hub_Categories (Category_ID) on delete restrict on update restrict;

alter table dataVault.Link_SupProdCat add constraint FK_REFERENCE_22 foreign key (Product_ID)
      references dataVault.Hub_Products (Product_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Categories add constraint FK_REFERENCE_20 foreign key (Category_ID)
      references dataVault.Hub_Categories (Category_ID) on delete restrict on update restrict;

alter table Sat_CustomerDemographics add constraint FK_REFERENCE_26 foreign key (CustDemo_ID)
      references dataVault.Hub_CustomerDemographics (CustDemo_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Customers add constraint FK_REFERENCE_17 foreign key (Customers_ID)
      references dataVault.Hub_Customers (Customers_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Employees add constraint FK_REFERENCE_16 foreign key (Employees_ID)
      references dataVault.Hub_Employees (Employees_ID) on delete restrict on update restrict;

alter table dataVault.Sat_OrderCustShipEmpl add constraint FK_REFERENCE_25 foreign key (OrderCustShipEmpl_ID)
      references dataVault.Link_OrderCustShipEmpl (OrderCustShipEmpl_ID) on delete restrict on update restrict;

alter table dataVault.Sat_OrderCustShipEmpl_Prod add constraint FK_REFERENCE_4 foreign key (OrderCustShipEmpl_Prod_ID)
      references dataVault.Link_OrderCustShipEmpl_Prod (OrderCustShipEmpl_Prod_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Products add constraint FK_REFERENCE_2 foreign key (Product_ID)
      references dataVault.Hub_Products (Product_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Shippers add constraint FK_REFERENCE_15 foreign key (Shippers_ID)
      references dataVault.Hub_Shippers (Shippers_ID) on delete restrict on update restrict;

alter table dataVault.Sat_Suppliers add constraint FK_REFERENCE_23 foreign key (Suppliers_ID)
      references dataVault.Hub_Suppliers (Suppliers_ID) on delete restrict on update restrict;



</pre>