Database Project of a Corporation or Firm

32

Transcript of Database Project of a Corporation or Firm

PowerPoint Presentation

Al-Madina Management System

Introduction,Erd,EErd ,Transformation,Views And Sequence

Project Members BS-CS 2C Evening

Hamza Ahmed 13-Arid-864Muhammad Saqib Nadeem 13-Arid-925Sinan Shafique Khan 13-Arid-969

Introduction:-

Our Project is about the Database system of a private company . It is able to save the record of employees ,department they are related with, stock position,equipments, customers and their given projects as well. It will manage the record in a sufficient way that everyone can retrieve data and information easily.

Problem Statement:-

Before this Project there was an issue of entering data manually because it was very time consuming and less efficient. There was an issue of data inconsistency and duplication of data.Before this data was on registers and it was very time consuming to search a record of a customer in a hurry.We were bound to search first for register number as well for searching a specific record.

Proposed Solution:-

As the problems mentioned above, this DBMS project is able to solve such problems which we are facing in entering data such as data duplication, data in-consistency and problem in entry of data manually. It will save data in a proper way and in a sequence so there will be less possibility of any kind of error and data duplication.

Entity Relationship Diagram

DepartmentDept_NameDept_id {Pk}Emp_id {fk}

CustomerCust_Name Ph_numEmp_id {FK}C_id {Pk}Phoneaddress

Employee Emp_id{Pk}Emp_NameF_nameCNIcDesignationSalaryAddressPhone_num

ProjectP_nameTypeCust_id {fk}Emp_id {FK}Start_dateDue_dateProject_Cost

EquipmentName Emp_id {FK}liscense_num{pk}Dept_id{fk}

StockName QuantityTypeDept_id {FK}St_id{pk}

1:*

managesHasHasWorksusesDealsCompletesAssigns1:*1:*1:11:*1:11:*1:11:11:11:*1:11:*1:11:*1:11:0

Enhanced Entity Relationship Diagram

DepartmentDept_NameDept_id {Pk}

CustomerName Ph_numEmp_id {FK}C_id {Pk}

Employee Emp_id{Pk}NameF_nameCNIcDesignationsalary

AddressT_addressP_addressEmp_id {fk}

ProjectP_nameTypeCust_id {fk}Emp_id {FK}Project_CostStart_dateDue_start

EquipmentName Emp_id {FK}liscense_num {pk}Dept_id{fk}

Phone NumberCell_numH_numEmp_id{fk}

StockName QuantityTypeDept_id {FK}St_id{pk}

1:*

managesHasHasWorksusesDealsHasCompletesAssignsHas1:*1:*1:11:*1:11:*1:11:*1:11:*1:11:11:11:*1:11:*1:11:*1:11:0MendatoryOr

ConstructionExcavatorOthers

C_AddressC_id{fk}P_addressOfc_address

C_PhoneC_id{fk}Cell_numOfc_num

has1:11:*

Has1:11:*

1:*

Table Creationcreate table Department ( Dept_id number(10) primary key,Dept_Name char(20) not null);

create table Employee(Emp_id number(10) primary key , Emp_Name char(14) not null, F_Name char(14) not null , CNIC varchar(20) not null , Salary number(15), Designation char (20) , Dept_id number(10) , constraint fk2_department foreign key(dept_id) references department(dept_id));

Contcreate table Customer (Cust_id number(10) primary key , Cust_Name char(15)not null,ph_num varchar(20) not null , Emp_id number(10),constraint fk1_employee foreign key (emp_id)references employee(emp_id));

Cont create table C_Address ( Cust_id number(10) , P_address varchar(60) , Ofc_address varchar(60) , constraint fk1_customer foreign key (cust_id) references customer(cust_id));

create table C_Phone (Cust_id number (10), Cell_num varchar (15) not null, Office_num varchar(15) not null,constraint fk2_customer foreign key (cust_id)references customer(cust_id));

Cont create table Stock ( St_id number(10) primary key, Name char(20) , Quantity varchar(20), Type char(30) , Dept_id number(10), constraint fk_department foreign key(dept_id) references department(dept_id));

Contcreate table Equipment ( Name char(20),Type char(20), liscense_num varchar (20) primary key , Emp_id number(10) , Dept_id number(10),constraint fk2_employee foreign key(emp_id)references employee(emp_id),constraint fk1_department foreign key(dept_id)references department(dept_id));

Cont

create table Project ( Emp_id number(10),Cust_id number(10), P_Name char(30) ,Project_cost varchar(15), Type char(30),Start_date Date,Due_date Dateconstraint fk3_employee foreign key(emp_id)references employee(emp_id),constraint fk_customer foreign key(cust_id)references customer(cust_id));

Contcreate table Emp_Address (Emp_idnumber(10), T_Address varchar (60) not null,P_Address varchar(60),constraint fk4_employee foreign key(emp_id)references employee(emp_id));

create table Emp_Phone (Emp_id number(10), Cell_num varchar(14) not null, H_num varchar(12) not null, constraint fk5_employee foreign key(emp_id) references employee(emp_id));

Dept-id{Pk}Dept_Name

DepartmentEmp_id{pk}Emp_NameF_nameCNICSalaryDesignationDept_id{fk}

Cust_id{pk}Cust_NameEmp_id{fk}C_cinc

EmployeeCustomerEmp_id{FK}Cust_id{Fk}P_nametypeStart_dateDue_dateProject_cost

projectSt_id {pk}NameQuantitytypeDept_id

Stock

Transformation:-Table Department:-DepartmentDept_id number(10) primary key,Dept_Name char(20) not null,Emp_id number(10),constraint fk_employee Foreign key (emp_id)references employee(emp_id))

Table Employee:-Employee Emp_Name char (14) not null, F_Name char(14) not null , CNIC varchar(20) not null ,Salary number(15), Designation char(20), Dept_id number(10), constraint fk2_department foreign key(dept_id) references department(dept_id)Emp_id number (10) Primary key

Table customer:-Stock(St_id number(10) primary key , Name char(20),Quantity varchar(20),Type char(30),Dept_id number(10),constraint fk_department foreign key(dept_id)references department(dept_id)

Table Project:- Emp_Phone Emp_id number(10), Cell_num varchar(14) not null, H_num varchar(12) not null, constraint fk5_employee foreign key(emp_id) references employee(emp_id))

Table Stock:-StockSt_id number(10) primary key, Name char (20),Quantity varchar(20),Type char(30),Dept_id number(10),constraint fk_department foreign key(dept_id)references department(dept_id))

Table Equipment:-Equipmentliscense_num varchar(20) primary keyName char(20),Type char(20),, Emp_id number(10),Dept_id number(10),constraint fk2_employee foreign key(emp_id)references employee(emp_id),constraint fk1_department foreign key(dept_id)references department(dept_id))

Table emp_address:- Emp_Address( Emp_id number(10), T_Address varchar(60) not null, P_Address varchar(60),constraint fk4_employee foreign key(emp_id) references employee(emp_id))

Table emp_phone:-

Emp_Phone Emp_id number(10) ,Cell_num varchar(14) not null,H_num varchar(12) not null,constraint fk5_employee foreign key(emp_id)references employee(emp_id))

Views Views are used for privacy , like we dont want our customer to see our all data so we will create view for them so they will be able to see the relavant information to them.We have generate following Views in our projectadmin_viewcust_Viewstock_view contact_view

Create view admin_view as select e.emp_id , e.emp_name , e.F_name, e.designation, e.salary, C.cust_id, c.cust_name,p. p_name, p.start_date, p.due_date from employee e, customer c, project p where e.emp_id = c.emp_id and c.cust_id = p.cust_id;

create view cust_View as select e.emp_id , e.emp_name, p.p_name, p.project_cost , p.start_date, p.due_date from employee e, project p where e.emp_id = p.emp_id;

Create view stock_view as select d.dept_id , d.dept_name , e.name,e.type from department d, equipment e where d.dept_id = e.dept_id;

Create view contact_view as select e.emp_id , e.emp_name , p.cell_num from employee e , emp_phone p where e.emp_id = p.emp_id;

Queries of Views

Sequences We have used sequences in our project for automatically generating the primary key values and it will generate a sequence by its own so we dont have to remember the last value.We have generate sequences onemp_iddept_idcust_idst_id

Queries For Sequence

create sequence emp_id increment by 1 start with 100 maxvalue 150 nocache nocycle;create sequence dept_id start with 1000 increment by 2 maxvalue 1050 nocache nocycle;Create sequence cust_id start with 2000 increment by 1 maxvalue 2050 nocache nocycle;Create sequence st_id start with 3000 increment by 1 maxvalue 3050 nocache nocycle;

How we will insert data into tables when we have used sequences?insert into department values(dept_id.nextval,'Administration');insert into employee values(emp_id.nextval,'Nadeem','Ahmed','37206-222222-1,'60000','MD',1000);insert into customer values(cust_id.nextval,'Bisharat','0900-78601',100);insert into stock values(st_id.nextval,'Tube Lights','20','Lights',1006);