afc project report
TRANSCRIPT
Abbey Fitness ClubPROJECT Documentation
This report contains the documentation of all the stages from Analysis, Data Modeling, Implementation to Final product testing is stated.
Syed Farhan Iqbal4/20/2012
Abbey Fitness Club
Table of Contents
Acknowledgement 3
Requirement Specification Document 4
Task 1: Understanding the Data Model and Database Technology 5
Task 2: Designing Relational Database Meeting User Requirements:- 8
Task 3: Implementation & Test of Different Queries In SQL Developer Tool 17
Task 4: Testing & Documentation 31
Abbey Fitness Club
Acknowledgement
Abbey Fitness Club
Requirement Specification Document:-
Now this the provided scenario where we have to
deal with a London based Fitness club
named as Abbey Fitness Club, as u
can extract that Club has six
branches across the London with
2000 members providing
facilities like swimming, boxing, Weight Lifting etc.
We have to develop a solution which can provide
total business
A special thanks to my project advisor Mr. Naeem Akhter who
really guided me in right direction and helped me out in difficult
situation with his great knowledge and experience.
Abbey Fitness Club
Task 1: Understanding the Data Model and Database Technology:-
The first step should be accurate to meet up the targeted consequence. We should comprehend that what our aspiration is prior to designing our model. Identifying the problem is most obligatory then implementing the solution. Because if problem is accurately identified that’s means your approach for development is in right direction and you are successful in filtering the problem from pool of problem now you can go for a solution.
For understanding the Data Model , I have studied from different net resources and consulted Mr. Naeem Akhter, now let’s discuss the data model and then we will select the most suited one for our system.
I have studied three different approaches and come to a decision that Relational Data modeling is the best among all,
The Hierarchical Data Model The Network Data Model The Relational Data Model
The Relational Data Model
The Relational Data Model has the relation at its heart, but then a whole series of rules governing keys, relationships, joins, functional dependencies, transitive dependencies. The database is all about relationship and dependencies, simple definition of database is collection of relations. If we managed the relationship according to standard rule or you can say if we are able to normalize the relations then outcome will be accurate data with accurate functionality.
The Relation
Table of values is called relation. Row is collection of related data values corresponding to real-world entity
Tuple - row
Attribute - column header
Relation – table
Abbey Fitness Club
Degree of a relation - number of attributes
Relation schema - Table(Column1,column 2,…,Column n) - Relation name Table; list of attributes Column1,Column 2,…,Column n
Column1 Column2 Column21 Farhan 031541993052 Yasir 03217610662
Third Normal Form Applied(Dividing the Relations):-
Let’s see this practical example & then we will discuss the 3NFwith respect to the given below example, as in our project we have different branches and each branch will have some employees as well, If we put the data in one table it can surely results in redundancy issue and we have to put same data again and again.
Advantages of Relational Data Model:-
1. Data redundancy can be reduced in RDBMS by splitting the tables/relations.2. RDBMS have Relational Operations supporting Normalization which never allow illegal or
incomplete data entry.3. A relational database supports access permissions, which empower the database
administrator.4. Supports SQL which is easy to implement, a global standard for many vendors.5. Authorization and privilege control features in an RDBMS allow the database administrator
to restrict access users only to their required data.
Abbey Fitness Club
6. Relational databases are scalable and provide support for the implementation of distributed systems.
7. It has a powerful user interface which makes management more users friendly.8. RDBMSs provide access to the database through a server daemon
9. RDBMSs allow multiple database users to access a database simultaneously. Built-in locking and transactions management functionality allow users to access data as it is being changed, prevents collisions between two users updating the data, and keeps users from accessing partially updated records.
Advantages of Relational Data Model:-
In above stated example if we have to just put a branch Id against an employee name so why should we use two tables, as our data is not complex but simple so implementation approach should also be simple, to depict this disadvantage let see the tables below here we can put FACILTY_SECTION_ID as alternate key in FACILTY table because data to be enter is not related upto a complex level.
1. The relational database model is not the fastest data structure. 2. Furthermore, the relationships can become extremely intricate when a relational database
contains more than just two tables.3. Designing complexity of RDBMS make its design phase is a daunting task in itself4. It’s not necessary to use RDBMS if data is not complexly related and dependent on each
other.5. Modification later on can be multifaceted task.
Abbey Fitness Club
Abbey Fitness Club
Task 2: Designing Relational Database Meeting User Requirements:-
I have designed the basic data model on my note pad then implemented on Toad,
Abbey Fitness Club
1. I have created several required tables and related them to their child to build such Relational data model for Abbey Fitness Club.
2. I used Primary key of Parent tables in as foreign key in child table to create one-to-many relation.
3. I made primary key not null able to make sure that every data entry have a unique key to make it distinct.
4. I have used Order_Supplier_Id as alternate key to make sure that each order has a unique supplier.
5. I have made Section table as child of Facility table as per user requirement specifications.
Script of Abbey Fitness Club project:-
CREATE TABLE BARANCH
(
BARANCH_ID NUMBER CONSTRAINT BARANCH_C01 NOT NULL,
BARANCH_NAME VARCHAR2(100 BYTE)
);
CREATE TABLE EMPLOYEES
(
EMP_ID NUMBER CONSTRAINT EMPLOYS_C02 NOT NULL,
BARANCH_ID NUMBER CONSTRAINT EMPLOYS_C03 NOT NULL,
EMP_NAME VARCHAR2(80 BYTE) CONSTRAINT EMPLOYS_C01 NOT NULL,
EMP_POST VARCHAR2(255 BYTE)
);
CREATE TABLE EQUIPMENT
(
EQUIPMENT_ID NUMBER CONSTRAINT EQUIPMENT_C04 NOT NULL,
BARANCH_ID NUMBER CONSTRAINT EQUIPMENT_C01 NOT NULL,
EQUIPMENT_NAME VARCHAR2(100 BYTE) CONSTRAINT EQUIPMENT_C03 NOT NULL,
EQUIPMENT_QUANTITY NUMBER
);
Abbey Fitness Club
CREATE TABLE FACILITY_SECTION
(
FACILITY_SECTION_ID NUMBER CONSTRAINT FACILITY_SECTION_C02 NOT NULL,
FACILITY_SECTION_NAME VARCHAR2(100 BYTE) CONSTRAINT FACILITY_SECTION_C03 NOT NULL
);
CREATE TABLE FACILTY
(
FACILTY_ID NUMBER CONSTRAINT FACILTY_C01 NOT NULL,
FACILTY_NAME VARCHAR2(50 BYTE) CONSTRAINT FACILTY_C03 NOT NULL,
BARANCH_ID NUMBER CONSTRAINT FACILTY_C04 NOT NULL,
FACILITY_SECTION_ID NUMBER
);
CREATE TABLE REGISTERED_MEMBER
(
MEMBER_ID NUMBER CONSTRAINT REGISTERED_MEMBER_C01 NOT NULL,
MEMBER_NAME VARCHAR2(255 BYTE),
ADDRESS VARCHAR2(255 BYTE),
BARANCH_ID NUMBER NOT NULL
);
CREATE TABLE SUPPLIER
(
ORDER_ID NUMBER CONSTRAINT SUPPLIER_C01 NOT NULL,
ORDER_SUPPLIER_ID NUMBER NOT NULL,
Abbey Fitness Club
SUPPLIER_ORDER_DATE DATE NOT NULL
);
CREATE UNIQUE INDEX BRANCHES_PK ON BARANCH
(BARANCH_ID);
CREATE UNIQUE INDEX EMPLOYS_PK ON EMPLOYEES
(EMP_ID);
CREATE UNIQUE INDEX EQUIPMENT_PK ON EQUIPMENT
(EQUIPMENT_ID);
CREATE UNIQUE INDEX FACILITY_SECTION_PK ON FACILITY_SECTION
(FACILITY_SECTION_ID);
CREATE UNIQUE INDEX FACILTY_PK ON FACILTY
(FACILTY_ID);
CREATE UNIQUE INDEX REGISTERED_MEMBER_PK ON REGISTERED_MEMBER
(MEMBER_ID);
CREATE UNIQUE INDEX SUPPLIER_PK ON SUPPLIER
(ORDER_ID);
Abbey Fitness Club
CREATE UNIQUE INDEX SUPPLIER_U01 ON SUPPLIER
(ORDER_SUPPLIER_ID);
CREATE TABLE FACILTY_RECORD
(
MEMBER_ID NUMBER,
TOTAL_TIME DATE,
START_TIME DATE,
END_TIME DATE,
EMP_ID NUMBER,
FACILIY_RECORD_ID NUMBER CONSTRAINT FACILTY_RECORD_C01 NOT NULL,
FACILTY_SECTION_ID NUMBER
);
CREATE TABLE REPAIR_RECORD
(
REPAIR_ID NUMBER CONSTRAINT REPAIR_RECORD_C01 NOT NULL,
LABOR_COST NUMBER CONSTRAINT REPAIR_RECORD_C06 NOT NULL,
TOTAL_COST NUMBER CONSTRAINT REPAIR_RECORD_C07 NOT NULL,
EQUIPMENT_ID NUMBER CONSTRAINT REPAIR_RECORD_C04 NOT NULL,
ORDER_ID NUMBER CONSTRAINT REPAIR_RECORD_C03 NOT NULL,
PART_PRICE NUMBER CONSTRAINT REPAIR_RECORD_C02 NOT NULL,
REPAIR_START DATE NOT NULL,
REPAIR_END DATE NOT NULL
);
Abbey Fitness Club
CREATE UNIQUE INDEX FACILTY_RECORD_PK ON FACILTY_RECORD
(FACILIY_RECORD_ID);
CREATE UNIQUE INDEX PART_PRICE_PK ON REPAIR_RECORD
(REPAIR_ID);
ALTER TABLE BARANCH ADD (
CONSTRAINT BRANCHES_PK
PRIMARY KEY
(BARANCH_ID)
USING INDEX BRANCHES_PK);
ALTER TABLE EMPLOYEES ADD (
CONSTRAINT EMPLOYEES_R01
CHECK (EMP_POST IS NOT NULL),
CONSTRAINT EMPLOYS_PK
PRIMARY KEY
(EMP_ID)
USING INDEX EMPLOYS_PK);
ALTER TABLE EQUIPMENT ADD (
CONSTRAINT EQUIPMENT_PK
PRIMARY KEY
(EQUIPMENT_ID)
USING INDEX EQUIPMENT_PK);
ALTER TABLE FACILITY_SECTION ADD (
CONSTRAINT FACILITY_SECTION_PK
Abbey Fitness Club
PRIMARY KEY
(FACILITY_SECTION_ID)
USING INDEX FACILITY_SECTION_PK);
ALTER TABLE FACILTY ADD (
CONSTRAINT FACILTY_R03
CHECK (FACILITY_SECTION_ID IS NOT NULL),
CONSTRAINT FACILTY_PK
PRIMARY KEY
(FACILTY_ID)
USING INDEX FACILTY_PK);
ALTER TABLE REGISTERED_MEMBER ADD (
CONSTRAINT REGISTERED_MEMBER_PK
PRIMARY KEY
(MEMBER_ID)
USING INDEX REGISTERED_MEMBER_PK);
ALTER TABLE SUPPLIER ADD (
CONSTRAINT SUPPLIER_PK
PRIMARY KEY
(ORDER_ID)
USING INDEX SUPPLIER_PK,
CONSTRAINT SUPPLIER_U01
UNIQUE (ORDER_SUPPLIER_ID)
USING INDEX SUPPLIER_U01);
Abbey Fitness Club
ALTER TABLE FACILTY_RECORD ADD (
CONSTRAINT FACILTY_RECORD_PK
PRIMARY KEY
(FACILIY_RECORD_ID)
USING INDEX FACILTY_RECORD_PK);
ALTER TABLE REPAIR_RECORD ADD (
CONSTRAINT PART_PRICE_PK
PRIMARY KEY
(REPAIR_ID)
USING INDEX PART_PRICE_PK);
ALTER TABLE EMPLOYEES ADD (
CONSTRAINT EMPLOYS_R01
FOREIGN KEY (BARANCH_ID)
REFERENCES BARANCH);
ALTER TABLE EQUIPMENT ADD (
CONSTRAINT EQUIPMENT_R01
FOREIGN KEY (BARANCH_ID)
REFERENCES BARANCH);
ALTER TABLE FACILTY ADD (
CONSTRAINT FACILTY_R01
FOREIGN KEY (BARANCH_ID)
REFERENCES BARANCH,
CONSTRAINT FACILTY_R02
FOREIGN KEY (FACILITY_SECTION_ID)
REFERENCES FACILITY_SECTION);
Abbey Fitness Club
ALTER TABLE REGISTERED_MEMBER ADD (
CONSTRAINT REGISTERED_MEMBER_R01
FOREIGN KEY (BARANCH_ID)
REFERENCES BARANCH);
ALTER TABLE FACILTY_RECORD ADD (
CONSTRAINT FACILTY_RECORD_R01
FOREIGN KEY (MEMBER_ID)
REFERENCES REGISTERED_MEMBER,
CONSTRAINT FACILTY_RECORD_R02
FOREIGN KEY (EMP_ID)
REFERENCES EMPLOYEES,
CONSTRAINT FACILTY_RECORD_R03
FOREIGN KEY (FACILTY_SECTION_ID)
REFERENCES FACILITY_SECTION);
ALTER TABLE REPAIR_RECORD ADD (
CONSTRAINT REPAIR_RECORD_R01
FOREIGN KEY (EQUIPMENT_ID)
REFERENCES EQUIPMENT,
CONSTRAINT REPAIR_RECORD_R03
FOREIGN KEY (ORDER_ID)
REFERENCES SUPPLIER);
End Of script.
Abbey Fitness Club
Task 3: Implementation & Test of Different Queries In SQL Developer Tool:-
Query 1: It will extract and show the data from Employees & Baranch tables
Query Code:
SELECT EMPLOYEES.EMP_ID,
EMPLOYEES.EMP_NAME,
BARANCH.BARANCH_ID,
BARANCH.BARANCH_NAME
FROM EMPLOYEES, BARANCH
WHERE (EMPLOYEES.BARANCH_ID = BARANCH.BARANCH_ID)
Query Result:
Abbey Fitness Club
Query 2: It will extract and show the data from Employees & Baranch tables for employees belonging to East London Branch A.
Query Code:
SELECT EMPLOYEES.EMP_ID,
EMPLOYEES.EMP_NAME,
BARANCH.BARANCH_ID,
BARANCH.BARANCH_NAME
FROM EMPLOYEES, BARANCH
WHERE (EMPLOYEES.BARANCH_ID = BARANCH.BARANCH_ID and baranch_name='East London Branch A')
Query Result:
Abbey Fitness Club
Query 3: It will insert a row in Registered_Member table
Query Code:
INSERT INTO REGISTERED_MEMBER (
MEMBER_ID, MEMBER_NAME, ADDRESS,
BARANCH_ID)
VALUES ( 10,'Salman','w',2 );
Query Result:
Query 4: It will show the data in ascending order of equipment name
Abbey Fitness Club
Query Code:
SELECT EQUIPMENT.EQUIPMENT_ID,
EQUIPMENT.EQUIPMENT_NAME,
REPAIR_RECORD.TOTAL_COST,
REPAIR_RECORD.ORDER_ID,
REPAIR_RECORD.REPAIR_START,
REPAIR_RECORD.REPAIR_END
FROM REPAIR_RECORD, EQUIPMENT
WHERE (REPAIR_RECORD.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_ID)
ORDER BY EQUIPMENT.EQUIPMENT_NAME ASC
Query Result:
Query 5: It will extract and show the data from Employees & Baranch tables
Abbey Fitness Club
Query Code:
SELECT DISTINCT equipment_name FROM equipment
Query Result:
Query 6: It will update a row in table supplier
Abbey Fitness Club
Note: we cannot update a connected column directly.
Query Code:
UPDATE SUPPLIER
SET ORDER_ID = 1,
SUPPLIER_ORDER_DATE = sysdate
WHERE ORDER_ID = 1;
Query Result:
Abbey Fitness Club
Query 7: It will extract data matching the defined value from Employees table using “In” clause
Query Code:
SELECT EMPLOYEES.EMP_ID, EMPLOYEES.EMP_NAME, EMPLOYEES.EMP_POST
FROM EMPLOYEES
WHERE emp_post in ('WORKER');
Query Result:
Abbey Fitness Club
Query 8: It will show the member names Naseem having form south London branch
Query Code:
SELECT REGISTERED_MEMBER.MEMBER_NAME,
REGISTERED_MEMBER.ADDRESS,
REGISTERED_MEMBER.MEMBER_ID,
REGISTERED_MEMBER.BARANCH_ID
FROM REGISTERED_MEMBER
WHERE baranch_id=6 and member_name='NASEEM';
Query Result:
Abbey Fitness Club
Query 9: It will show all the activities done by member having S as first letter of their name
Query Code:
SELECT REGISTERED_MEMBER.MEMBER_NAME,
FACILTY_RECORD.FACILIY_RECORD_ID,
FACILITY_SECTION.FACILITY_SECTION_NAME,
FACILTY_RECORD.TOTAL_TIME
FROM REGISTERED_MEMBER, FACILITY_SECTION, FACILTY_RECORD
WHERE member_name like 'S%'
Query Result:
Abbey Fitness Club
Query 10: It show the data all record about tread mill machine in all branches
Query Code:
SELECT BARANCH.BARANCH_NAME,
EQUIPMENT.EQUIPMENT_NAME,
REPAIR_RECORD.REPAIR_START,
REPAIR_RECORD.PART_PRICE,
REPAIR_RECORD.ORDER_ID
FROM BARANCH, EQUIPMENT, REPAIR_RECORD
WHERE equipment_name = 'TREAD MILL'
Query Result:
Abbey Fitness Club
Query 11: Tread mill machine repaired in North London branch in last 45 days
Query Code:
SELECT EQUIPMENT.EQUIPMENT_NAME,
BARANCH.BARANCH_NAME,
count(REPAIR_RECORD.REPAIR_ID) as repair_times
FROM EQUIPMENT, REPAIR_RECORD, BARANCH
WHERE (REPAIR_RECORD.EQUIPMENT_ID = EQUIPMENT.EQUIPMENT_ID)
AND (EQUIPMENT.BARANCH_ID = BARANCH.BARANCH_ID)
and EQUIPMENT.EQUIPMENT_NAME='TREAD MILL'
and BARANCH.BARANCH_NAME='North London Branch A'
and REPAIR_RECORD.REPAIR_START <= sysdate-45
group by
EQUIPMENT.EQUIPMENT_NAME,
BARANCH.BARANCH_NAME,
REPAIR_RECORD.TOTAL_COST,
REPAIR_RECORD.REPAIR_START
Query Result:
Abbey Fitness Club
Query 12: Members who used swimming pool of east London branch and staff booked them b/w '01-jan-1899' and '31-dec-1900'
Query Code:
SELECT REGISTERED_MEMBER.MEMBER_NAME,
SELECT FACILTY_RECORD.FACILIY_RECORD_ID,
FACILITY_SECTION.FACILITY_SECTION_NAME,
FACILTY.FACILTY_NAME,
REGISTERED_MEMBER.MEMBER_NAME,
EMPLOYEES.EMP_NAME,
FACILTY_RECORD.START_TIME,
BARANCH.BARANCH_NAME,
FACILTY_RECORD.END_TIME
FROM FACILTY_RECORD,
FACILITY_SECTION,
FACILTY,
BARANCH,
REGISTERED_MEMBER,
EMPLOYEES
WHERE (FACILTY_RECORD.FACILTY_SECTION_ID =
FACILITY_SECTION.FACILITY_SECTION_ID)
AND (FACILTY.FACILITY_SECTION_ID =
FACILITY_SECTION.FACILITY_SECTION_ID)
AND (FACILTY_RECORD.MEMBER_ID = REGISTERED_MEMBER.MEMBER_ID)
AND (FACILTY_RECORD.EMP_ID = EMPLOYEES.EMP_ID)
and (FACILTY.FACILTY_NAME='SWIMMING POOL')
and (FACILTY_RECORD.START_TIME between '01-jan-1899' and '31-dec-1990')
and (baranch_name like 'East London Branch%')
Abbey Fitness Club
Query Result:
Abbey Fitness Club
Query 13: Facility usage in order of popularity starting with least for east London branch Query Code:
SELECT FACILTY.FACILTY_NAME,
BARANCH.BARANCH_NAME,
FACILITY_SECTION.FACILITY_SECTION_NAME,
count(FACILTY_RECORD.FACILIY_RECORD_ID) as "facility count"
FROM FACILTY_RECORD,
FACILTY,
FACILITY_SECTION,
BARANCH
WHERE (FACILTY_RECORD.FACILTY_SECTION_ID =
FACILITY_SECTION.FACILITY_SECTION_ID)
AND (FACILTY.FACILITY_SECTION_ID =
FACILITY_SECTION.FACILITY_SECTION_ID)
AND (FACILTY.BARANCH_ID = BARANCH.BARANCH_ID)
and BARANCH.BARANCH_NAME='East London Branch A'
group by
FACILTY.FACILTY_NAME,
BARANCH.BARANCH_NAME,
FACILITY_SECTION.FACILITY_SECTION_NAME
order by 4
Abbey Fitness Club
Query Result:
Task 4: Testing & Documentation:-
I have entered the data for testing purposes to ensure the validation of data model and to check the outcomes of written queries.
As process of testing and documentation is carried by me simultaneously according to t he Rational Unified Process (RUP) so no more testing is required as I have achieved the required outcome.
Documentation process is also carried out in parallel.