You are on page 1of 3

//The Catalog Table stores information of users that that have used the maximum package or those whi

have used the least and also the users with the longest con nections CREATE TABLE Catalog ( Catalog_Code INTEGER UNSIGNED NOT NULL, User_with_longest_connection_time VARCHAR(20) NOT NULL AUTO_INCREMENT, User_with_least_Usage VARCHAR(20) NULL, User_with_most_usage VARCHAR(20) NULL, PRIMARY KEY(Catalog_Code) ); //The Connection table keeps information about the connection type a user is usi ng. Additional information like bytes uploaded and downloaded by a particular us er is also stored in the table. CREATE TABLE Connection ( Serial_no INTEGER UNSIGNED NOT NULL, USB_Shutter_Serial_no INTEGER UNSIGNED NOT NULL, USB Box_Serial_no INTEGER UNSIGNED NOT NULL, Time_of_connection TIMESTAMP NOT NULL, IP_assigned INTEGER UNSIGNED NOT NULL, Bytes_downloaded INTEGER UNSIGNED NOT NULL, Bytes_uploaded INTEGER UNSIGNED NOT NULL, Time_of_disconnect TIMESTAMP NOT NULL, Connection Bandwidth INTEGER UNSIGNED NULL, PRIMARY KEY(Serial_no), INDEX Connection_FKIndex1(USB Box_Serial_no), INDEX Connection_FKIndex2(USB_Shutter_Serial_no) ); //Information like remaining download limit and number of connections about a pa rticular user is kept in the table Details CREATE TABLE Details ( Connection_code INTEGER UNSIGNED NOT NULL, Users_User_CNIC INTEGER UNSIGNED NOT NULL, Remaining_download_limit INTEGER UNSIGNED NOT NULL, Number_of_connections INTEGER UNSIGNED NOT NULL, PRIMARY KEY(Connection_code, Users_User_CNIC), INDEX Account_FKIndex1(Connection_code, Users_User_CNIC) );

//Customers are free to choose their devices. Each device offer different servic es. The information that which devices are used by which users is stored in this Table CREATE TABLE Device ( Manufacture_id INTEGER UNSIGNED NOT NULL, Connection_code INTEGER UNSIGNED NOT NULL, Users_User_CNIC INTEGER UNSIGNED NOT NULL, Power_type VARCHAR NOT NULL, Device_code INTEGER UNSIGNED NOT NULL, Device_Type VARCHAR(20) NULL, PRIMARY KEY(Manufacture_id, Connection_code, Users_User_CNIC), INDEX Device_FKIndex1(Connection_code, Users_User_CNIC) ); The Package table keeps information about different packages, their services, ch arges, charges per extra gp, connection bandwidth etc. Packages used by customer

s are also stored in this table with user ids. CREATE TABLE Package ( Package_code INTEGER UNSIGNED NOT NULL, Connection_Serial_no INTEGER UNSIGNED NOT NULL, Package_name VARCHAR(20) NOT NULL, Bandwidth INTEGER UNSIGNED NOT NULL, Download_limit INTEGER UNSIGNED NOT NULL, Initial_Charges INTEGER UNSIGNED NULL, Monthly_charges INTEGER UNSIGNED NOT NULL, Charges_on_extra_gbs INTEGER UNSIGNED NOT NULL, PRIMARY KEY(Package_code), INDEX Package_FKIndex1(Connection_Serial_no) ); //Payment table stores the amount that the user has to make for the services. Pr eviosu bill records are also stored in this table. CREATE TABLE Payments ( Details_Connection_code INTEGER UNSIGNED NOT NULL, Users_User_CNIC INTEGER UNSIGNED NOT NULL, Account_Serial_Number INTEGER UNSIGNED NOT NULL, Connection_code INTEGER UNSIGNED NOT NULL, Details_Users_User_CNIC INTEGER UNSIGNED NOT NULL, Total_Amount INTEGER UNSIGNED NOT NULL, PRIMARY KEY(Details_Connection_code, Users_User_CNIC, Account_Serial_Number, C onnection_code), INDEX Payments_FKIndex1(Connection_code, Users_User_CNIC), INDEX Payments_FKIndex2(Details_Connection_code, Details_Users_User_CNIC) ); //Regional office is a location where customers can go and make payments. The ta ble stores locations of different Regional offices CREATE TABLE Regional_office ( Branch_code INTEGER UNSIGNED NOT NULL, Location VARCHAR(45) NOT NULL, PRIMARY KEY(Branch_code) ); //USB Box is a type of device that can be used by a number of users. The informa tion like device id, users using it and connection codes are kept in this table CREATE TABLE USB Box ( Serial_no INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Device_Users_User_CNIC INTEGER UNSIGNED NOT NULL, Device_Connection_code INTEGER UNSIGNED NOT NULL, Device_Manufacture_id INTEGER UNSIGNED NOT NULL, Power_source VARCHAR(20) NOT NULL, PRIMARY KEY(Serial_no), INDEX USB Box_FKIndex1(Device_Manufacture_id, Device_Connection_code, Device_U sers_User_CNIC) ); //USB Shutter is a type of device that can be used by a number of users. The inf ormation like device id, users using it and connection codes are kept in this ta ble CREATE TABLE USB_Shutter ( Serial_no INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Device_Users_User_CNIC INTEGER UNSIGNED NOT NULL, Device_Connection_code INTEGER UNSIGNED NOT NULL, Device_Manufacture_id INTEGER UNSIGNED NOT NULL, Power_Source VARCHAR(20) NULL,

PRIMARY KEY(Serial_no), INDEX USB_Shutter_FKIndex1(Device_Manufacture_id, Device_Connection_code, Devi ce_Users_User_CNIC) ); The table users store basic information of the users like thier ids, names, addr esses, packages, devices and connections CREATE TABLE Users ( Connection_code INTEGER UNSIGNED NOT NULL, User_CNIC INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Catalog_Code INTEGER UNSIGNED NOT NULL, Date_of_birth DATE NOT NULL, Gender VARCHAR NOT NULL, Connection_type VARCHAR(20) NOT NULL, Address VARCHAR(45) NOT NULL, Address_line_2 VARCHAR(45) NOT NULL, City VARCHAR(20) NOT NULL, Telephone INTEGER UNSIGNED NOT NULL, Cellphone INTEGER UNSIGNED NULL, Email VARCHAR(45) NOT NULL, PRIMARY KEY(Connection_code, User_CNIC), UNIQUE INDEX KEY(User_CNIC), INDEX Users_FKIndex1(Catalog_Code) );

You might also like