Sunteți pe pagina 1din 7

create table TBL_User ( User_ID INT not null, User_Code VARCHAR(30) not null, User_NAME VARCHAR(100) not null,

Dept_ID INT, Role_ID INT, Is_Customer CHAR(1) not null, Customer_ID INT, USER_TYPE CHAR(1) not null, Is_Active CHAR(1) not null, User_PASSWORD VARCHAR(20) not null, PASSWRD_UPDATE_DATE DATE, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, UserID INT not null ); -- Create/Recreate primary, unique and foreign key constraints alter table TBL_User add constraint User_ID_PK primary key (User_ID) ; alter table TBL_User add constraint User_Code_UK unique (User_Code) ; alter table TBL_User add constraint User_NAME_UK unique (User_NAME) ; -create table TBL_Role ( Role_ID INT not null, Role_NAME VARCHAR(100) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Role add constraint Role_ID_PK primary key (Role_ID) ; alter table TBL_Role add constraint Role_NAME_UK unique (Role_NAME) ; alter table TBL_Role add constraint Role_USER_ID_FK foreign key (USER_ID) refere nces TBL_User (USER_ID); -create table TBL_Role_Det ( Role_ID INT not null, Role_Det_ID INT not null, FORM_NAME VARCHAR(100) not null, Path VARCHAR(100) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ) ; alter table TBL_Role_Det add constraint TBL_Role_Det_PK primary key (Role_Det_I D) ; alter table TBL_Role_Det add constraint Role_ID_FK foreign key (Role_ID) referen ces TBL_Role (Role_ID); alter table TBL_Role_Det add constraint Role_Det_USER_ID_FK foreign key (USER_ID ) references TBL_User (USER_ID); -create table TBL_COUNTRY ( COUNTRY_ID INT not null, COUNTRY_Code INT, COUNTRY_NAME VARCHAR(200) not null,

IS_HEAD_OFFICE Is_Active REMARKS ENTRY_DATE USER_ID

CHAR(1) not null, CHAR(1) not null, VARCHAR(300), DATE not null, INT not null

); -- Create/Recreate primary, unique and foreign key constraints alter table TBL_COUNTRY add constraint COUNTRY_ID_PK primary key (COUNTRY_ID) ; alter table TBL_COUNTRY add constraint COUNTRY_NAME_UK unique (COUNTRY_NAME) ; alter table TBL_COUNTRY add constraint COUNTRY_USER_ID_FK foreign key (USER_ID) references TBL_User (USER_ID); -create table TBL_CITY ( COUNTRY_ID INT not null, CITY_ID INT not null, Zip_Code INT, CITY_NAME VARCHAR(200) not null, IS_HEAD_OFFICE CHAR(1) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); -- Create/Recreate primary, unique and foreign key constraints alter table TBL_CITY add constraint CITY_ID_PK primary key (CITY_ID); alter table TBL_CITY add constraint CITY_NAME_UK unique (CITY_NAME); alter table TBL_CITY add constraint COUNTRY_ID_FK foreign key (COUNTRY_ID) refer ences TBL_COUNTRY (COUNTRY_ID); alter table TBL_CITY add constraint CITY_USER_ID_FK foreign key (USER_ID) refere nces TBL_User (USER_ID); -create table TBL_COMPANY ( COMPANY_ID INT not null, COMPANY_NAME VARCHAR(150) not null, COMPANY_START_DATE DATE not null, COMPANY_ADDRESS VARCHAR(150), COMPANY_CONTACT_NO VARCHAR(15), COMPANY_EMAIL VARCHAR(30), COMPANY_HISTORY VARCHAR(300), CITY_ID INT not null, ABOUT_US VARCHAR(300) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ) ; -- Create/Recreate primary, unique and foreign key constraints alter table TBL_COMPANY add constraint COMPANY_ID_PK primary key (COMPANY_ID) ; alter table TBL_COMPANY add constraint CITY_ID_FK foreign key (CITY_ID) referenc es TBL_CITY (CITY_ID); alter table TBL_COMPANY add constraint COMPANY_USER_ID_FK foreign key (USER_ID) references TBL_User (USER_ID); -create table TBL_Dept ( CITY_ID INT not null, Dept_ID INT not null, Dept_NAME VARCHAR(200) not null,

Is_Active REMARKS ENTRY_DATE USER_ID

CHAR(1) not null, VARCHAR(300), DATE not null, INT not null

); -- Create/Recreate primary, unique and foreign key constraints alter table TBL_Dept add constraint Dept_ID_PK primary key (Dept_ID) ; alter table TBL_Dept add constraint Dept_CITY_ID_FK foreign key (CITY_ID) refere nces TBL_CITY (CITY_ID); alter table TBL_Dept add constraint Dept_USER_ID_FK foreign key (USER_ID) refere nces TBL_User (USER_ID); create table TBL_Product ( Product_ID INT not null, Product_NAME VARCHAR(200) not null, Product_CODE VARCHAR(20) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Product add constraint Product_ID_PK primary key (Product_ID) ; alter table TBL_Product add constraint Product_USER_ID_FK foreign key (USER_ID) references TBL_User (USER_ID); create table TBL_Customer ( Customer_ID INT not null, Customer_Name VARCHAR(200) not null, -Customer_CP_F_name VARCHAR(50) not null, Customer_CP_M_name VARCHAR(50) not null, Customer_CP_L_name VARCHAR(50) not null, Customer_CP_Person VARCHAR(100) not null, -address VARCHAR(200) not null, fax_No INT, Cell_No INT, Land_Line_No INT, CITY_ID INT not null, email VARCHAR(30) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Customer add constraint Customer_ID_PK primary key (Customer_ID) ; alter table TBL_Customer add constraint Customer_CITY_ID_FK foreign key (CITY_ID ) references TBL_CITY (CITY_ID); alter table TBL_Customer add constraint Customer_USER_ID_FK foreign key (USER_ID ) references TBL_User (USER_ID); -create table TBL_Payment ( Payment_ID INT not null, Payment_Name VARCHAR(100) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300),

ENTRY_DATE USER_ID

DATE not null, INT not null

); alter table TBL_Payment add constraint Payment_ID primary key (Payment_ID) ; alter table TBL_Payment add constraint Payment_USER_ID_FK foreign key (USER_ID) references TBL_User (USER_ID); -create table TBL_Delivery ( Delivery_ID INT not null, Delivery_Name VARCHAR(100) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Delivery add constraint Delivery_ID primary key (Delivery_ID) ; alter table TBL_Delivery add constraint Delivery_USER_ID_FK foreign key (USER_ID ) references TBL_User (USER_ID); -create table TBL_Inquiry ( Inquiry_ID INT not null, -- Pk Inquiry_Date date not null, Customer_ID INT not null, -- FK -Inquiry_CP_F_name VARCHAR(50) not null, Inquiry_CP_M_name VARCHAR(50) not null, Inquiry_CP_L_name VARCHAR(50) not null, -Inquiry_Year INT not null, Payment_ID INT not null, -- FK Delivery_Date date, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Inquiry add constraint Inq_ID_PK primary key (Inquiry_ID) ; alter table TBL_Inquiry add constraint Inq_Customer_ID_FK foreign key (Customer_ ID) references TBL_Customer (Customer_ID); alter table TBL_Inquiry add constraint Inq_USER_ID_FK foreign key (USER_ID) refe rences TBL_User (USER_ID); -create table TBL_Inquiry_Det ( Inquiry_No VARCHAR(200) not null, -- PK (E/0001/TKG/ Product /2010) Inquiry_Type char(1) not null, -- E Inquiry_Year INT(4) not null, -- 2010 Inquiry_Year_No char(6) not null, -- 000001 -- Unique Inquiry_Year_SNo INT(6) not null, -- 1 -- Unique Inquiry_CP char(4) not null, -- QHA Product_CODE VARCHAR(100) not null, -- from Product Table -Inquiry_ID INT not null, -- Fk Customer_ID INT not null, -- FK Product_ID INT not null, -- FK Quantity INT not null, Quantity_Unit INT not null, Product_Size INT not null,

Product_Size_Unit INT not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Inquiry_Det add constraint Inqd_Inquiry_No_PK primary key (Inqu iry_No) ; alter table TBL_Inquiry_Det add constraint Inqd_Inquiry_ID_FK foreign key (Inqu iry_ID) references TBL_Inquiry (Inquiry_ID); alter table TBL_Inquiry_Det add constraint Inqd_Customer_ID_FK foreign key (Cust omer_ID) references TBL_Customer (Customer_ID); alter table TBL_Inquiry_Det add constraint Inqd_Product_ID_FK foreign key (Prod uct_ID) references TBL_Product (Product_ID); alter table TBL_Inquiry_Det add constraint Inqd_Year_No_FK unique (Inquiry_Year _No); alter table TBL_Inquiry_Det add constraint Inqd_Year_sNo_FK unique (Inquiry_Yea r_SNo); alter table TBL_Inquiry_Det add constraint Inqd_USER_ID_FK foreign key (USER _ID) references TBL_User (USER_ID); -create table TBL_Supplier ( Sup_ID INT not null, Sup_Name VARCHAR(200) not null, -Supplier_CP_F_name VARCHAR(50) not null, Supplier_CP_M_name VARCHAR(50) not null, Supplier_CP_L_name VARCHAR(50) not null, Sup_CP_Person VARCHAR(100) not null, -Sup_address VARCHAR(200) not null, Sup_fax_No INT, Sup_Cell_No INT, Sup_Land_Line_No INT, CITY_ID INT not null, Sup_email VARCHAR(30) not null, Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Supplier add constraint Sup_ID_PK primary key (Sup_ID) ; alter table TBL_Supplier add constraint Sup_CITY_ID_FK foreign key (CITY_ID) ref erences TBL_CITY (CITY_ID); alter table TBL_Supplier add constraint Sup_USER_ID_FK foreign key (USER_ID) ref erences TBL_User (USER_ID); -create table TBL_Inquiry_Supplier ( Sup_Inq_ID INT not null, Company_Inquiry_No VARCHAR(200) not null, -(NE/0001/TKG/ Prod uct /2010) Inquiry_ID INT not null, -- Fk Inquiry_No VARCHAR(200) not null, -- FK (E/0001/TKG/ Produc t /2010) -Product_ID INT not null, -- FK Cust_Quantity INT not null, Cust_Quantity_Unit INT not null,

Cust_Product_Size INT not null, Cust_Product_Size_Unit INT not null, -Sup_ID INT not null, Sup_CP char(20) not null, Sup_Inquiry_No VARCHAR(200) not null, -(NE/0001/SK/ Produ ct /2010) -Sup_mailing_status char(1) not null, -- Y / N Sup_mailing_Date date not null, Sup_mailing_Address date not null, -Is_Reply_Received char(1) not null, -- Y / N Reply_Date date, -Sup_Unit_Price INT not null, Sup_Quantity INT not null, Sup_Quantity_Unit INT not null, Total_Amount INT not null, -Delivery_ID INT not null, -Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Inquiry_Supplier add constraint InqS_Sup_Inq_ID_PK primary key (Sup_Inq_ID) ; alter table TBL_Inquiry_Supplier add constraint InqS_Inquiry_No_FK foreign key (Inquiry_No) references TBL_Inquiry_Det (Inquiry_No); alter table TBL_Inquiry_Supplier add constraint InqS_Inquiry_ID_FK foreign key (Inquiry_ID) references TBL_Inquiry (Inquiry_ID); alter table TBL_Inquiry_Supplier add constraint InqS_Product_ID_FK foreign key (Product_ID) references TBL_Product (Product_ID); alter table TBL_Inquiry_Supplier add constraint InqS_USER_ID_FK foreign key (USER_ID) references TBL_User (USER_ID); -create table TBL_Coparative_Chart ( CC_ID INT, -- PK CC_No VARCHAR(200) not null, -- (CS/0001/SK/ Product /201 0) Sup_Inquiry_No VARCHAR(200) not null, -- FK (NE/0001/SK/ Product / 2010) Company_Inquiry_No VARCHAR(200) not null, -- FK (NE/0001/TKG/ Produc t /2010) Inquiry_No VARCHAR(200) not null, -- FK (E/0001/TKG/ Product / 2010) Inquiry_ID INT not null, -Sup_Inq_ID INT not null, -- FK Sup_ID INT not null, -- FK -SrNO INT not null, -- Always strt from 1 for enery P roduct Product_ID INT not null, Unit_Price INT not null, Quantity INT not null,

Quantity_Unit INT not null, Total_Amount INT not null, Delivery_ID INT not null, Is_Selected CHAR(1) not null, -- Y / N Is_Active CHAR(1) not null, REMARKS VARCHAR(300), ENTRY_DATE DATE not null, USER_ID INT not null ); alter table TBL_Coparative_Chart add constraint CC_CC_ID_PK primary key (CC_ID) ; alter table TBL_Coparative_Chart add constraint CC_Inquiry_No_FK foreign key (I nquiry_No) references TBL_Inquiry_Det (Inquiry_No); alter table TBL_Coparative_Chart add constraint CC_Inquiry_ID_FK foreign key (I nquiry_ID) references TBL_Inquiry (Inquiry_ID); alter table TBL_Coparative_Chart add constraint CC_Sup_ID_FK foreign key (Sup_ID ) references TBL_Supplier (Sup_ID); alter table TBL_Coparative_Chart add constraint CC_Product_ID_FK foreign key (P roduct_ID) references TBL_Product (Product_ID); alter table TBL_Coparative_Chart add constraint CC_USER_ID_FK foreign key (U SER_ID) references TBL_User (USER_ID); --

S-ar putea să vă placă și