Download as pdf or txt
Download as pdf or txt
You are on page 1of 86

CC6001NI Advanced Database System Development

40% Individual Coursework

Student Name: Prajwol Kharel


London Met ID: 19033602
College ID: NP01CP4S200076
Assignment Due Date: 3/15/2023
Assignment Submission Date: 3/15/2023
Word Count: 5185

I confirm that I understand my coursework needs to be submitted online via Google Classroom under the relevant
module page before the deadline for my assignment to be accepted and marked. I am fully aware that late
submissions will be treated as non-submission and a mark of zero will be awarded.
Contents
1. Introduction ................................................................................................................................. 8
2. Textual Analysis ......................................................................................................................... 9
3. ERD from Case Study ............................................................................................................... 10
4. Normalization ........................................................................................................................... 11
4.1. Normalization of figure 1................................................................................................... 11
4.1.2. Unnormalized Form (UNF) ........................................................................................ 11
4.1.3. Frist Normal Form (1NF)............................................................................................ 11
4.1.4. Second Normal Form (2NF) ....................................................................................... 11
4.1.5. Third Normal Form (3NF) .......................................................................................... 12
4.2. Normalization of figure 2................................................................................................... 13
4.2.1. Unnormalized Form (UNF) ........................................................................................ 13
4.2.2. First Normal Form (1NF)............................................................................................ 13
4.2.3. Second Normal Form (2NF) ....................................................................................... 13
4.2.4. Third Normal Form (3NF) .......................................................................................... 14
5. Integration and Assumption ...................................................................................................... 15
6. Final ERD ................................................................................................................................. 16
7. Data Dictionary ......................................................................................................................... 17
7.1. Employees Table ................................................................................................................ 17
7.2. Jobs Table .......................................................................................................................... 17
7.3. Roles Table ........................................................................................................................ 18
7.4. Addresses Table ................................................................................................................. 18
7.5. Employee_Addresses Table ............................................................................................... 18
7.6. Departments Table ............................................................................................................. 19
7.7. Job_Histories Table ........................................................................................................... 19
7.8. Email_Addresses Table ..................................................................................................... 19
7.9. Department_Managers Table ............................................................................................. 20
7.10. Votes Table ...................................................................................................................... 20
8. Scripts ....................................................................................................................................... 21
8.1. Departments Table Script .................................................................................................. 21
8.2. Jobs Table Script ................................................................................................................ 22
8.3. Roles Table Script .............................................................................................................. 23
8.4. Addresses Table Script ...................................................................................................... 24
8.5. Employees Table Script ..................................................................................................... 25
8.6. Email_Addresses Table Script ........................................................................................... 28
8.7. Votes Table Script.............................................................................................................. 29
8.8. Job_Histories Table Script ................................................................................................. 31
8.9. Employee_Addresses Table Script .................................................................................... 33
8.9. Department_Managers Table Script .................................................................................. 35
9. Insert Statements ....................................................................................................................... 36
9.1. Departments Table Insert Statement .................................................................................. 36
9.2. Jobs Table Insert Statement ............................................................................................... 37
9.3. Roles Table Insert Statement ............................................................................................. 38
9.4. Addresses Table Insert Statement ...................................................................................... 39
9.5. Employees Table Insert Statement..................................................................................... 40
9.6. Email_Addresses Table Insert Statement .......................................................................... 42
9.7. Votes Table Insert Statement ............................................................................................. 43
9.8. Job_Histories Table Insert Statement ................................................................................ 45
9.9. Employee_Addresses Table Insert Statement .................................................................... 46
9.10. Department_Managers Table Insert Statement ................................................................ 47
10. Select Statements .................................................................................................................... 49
11. Forms ...................................................................................................................................... 55
11.1. Home Page ....................................................................................................................... 55
11.2. Complex Forms and Queries ........................................................................................... 55
11.2.1. SQL Queries.............................................................................................................. 55
11.2.2. Complex Forms ......................................................................................................... 57
11.3. Simple Forms ................................................................................................................... 59
11.3.1. Employee Details Form ............................................................................................ 59
11.3.2. Department Details Form .......................................................................................... 60
11.3.3. Job Details Form ....................................................................................................... 60
11.3.3. Role Details Form ..................................................................................................... 61
12. User Manual ............................................................................................................................ 62
12.1. Home page ....................................................................................................................... 62
12.2. Basic Forms ..................................................................................................................... 63
12.3. Complex Forms ................................................................................................................ 64
13. Testing..................................................................................................................................... 65
13.1. Departments Details Form Testing .................................................................................. 65
13.1.1. Insert ......................................................................................................................... 65
13.1.2. Update ....................................................................................................................... 66
13.1.3. Delete ........................................................................................................................ 67
13.2. Jobs Details Form Testing ............................................................................................... 68
13.2.1. Insert ......................................................................................................................... 68
13.2.2. Update ....................................................................................................................... 69
13.2.3. Delete ........................................................................................................................ 70
13.3. Roles Details Form Testing ............................................................................................. 71
13.3.1. Insert ......................................................................................................................... 71
13.3.2. Update ....................................................................................................................... 72
13.3.3. Delete ........................................................................................................................ 74
13.4. Addresses Details Form Testing ...................................................................................... 75
13.4.1. Insert ......................................................................................................................... 75
13.4.2. Update ....................................................................................................................... 76
13.4.3. Delete ........................................................................................................................ 77
13.5. Employee Details Form Testing ...................................................................................... 78
13.5.1. Insert ......................................................................................................................... 78
13.5.2. Update ....................................................................................................................... 80
13.5.3. Delete ........................................................................................................................ 82
13.6. Failure Cases .................................................................................................................... 83
13.6.1. Incorrect SQL Data Source ....................................................................................... 83
13.6.2. Delete Issue ............................................................................................................... 84
14. Further Discussion .................................................................................................................. 85
15. Conclusion .............................................................................................................................. 86
Figures
Figure 1: Textual Analysis of Employee and Department.............................................................. 9
Figure 2: Textual Analysis of Role and Job.................................................................................... 9
Figure 3: Textual Analysis of Employee and JobHistory ............................................................... 9
Figure 4: Textual Analysis of Manager and Employee .................................................................. 9
Figure 5: Initial ERD from Case Study......................................................................................... 10
Figure 6: Final ERD ...................................................................................................................... 16
Figure 7: Departments Table Script .............................................................................................. 21
Figure 8: Jobs Table Script ........................................................................................................... 22
Figure 9: Roles Table Script ......................................................................................................... 24
Figure 10: Addresses Table Script ................................................................................................ 25
Figure 11: Employees Table Script............................................................................................... 27
Figure 12: Email_Addresses Table Script .................................................................................... 28
Figure 13: Votes Table Script ....................................................................................................... 30
Figure 14: Job_Hitories Table Script ............................................................................................ 32
Figure 15: Employee_Addresses Table Script .............................................................................. 34
Figure 16: Department_Managers Table Script ............................................................................ 35
Figure 17: Departments Table Insert Statement ........................................................................... 36
Figure 18: Jobs Table Insert Statement ......................................................................................... 37
Figure 19: Roles Table Insert Statement ....................................................................................... 38
Figure 20: Addresses Table Insert Statement ............................................................................... 39
Figure 21: Employees Table Insert Statement .............................................................................. 41
Figure 22: Email_Addresses Table Insert Statement .................................................................... 42
Figure 23: Votes Table Insert Statement ...................................................................................... 44
Figure 24: Job_Histories Table Insert Statement .......................................................................... 46
Figure 25: Employee_Addresses Table Insert Statement ............................................................. 47
Figure 26: Department_Managers Table Insert Statement ........................................................... 48
Figure 27: Departments Table Select Statement ........................................................................... 49
Figure 28: Jobs Table Select Statement ........................................................................................ 49
Figure 29: Roles Table Select Statement ...................................................................................... 50
Figure 30: Email_Addresses Table Select Statement ................................................................... 50
Figure 31: Addresses Table Select Statement ............................................................................... 51
Figure 32: Employees Table Select Statement ............................................................................. 51
Figure 33: Votes Table Select Statement ...................................................................................... 52
Figure 34: Employee_addresses Table Select Statement.............................................................. 53
Figure 35: Job_Histories Table Select Statement ......................................................................... 53
Figure 36: Department_Managers Table Select Statement .......................................................... 54
Figure 37: Home Page .................................................................................................................. 55
Figure 38: Employee Job History Form........................................................................................ 57
Figure 39: Voting Record Form .................................................................................................... 57
Figure 40: Employee Of The Month Form ................................................................................... 58
Figure 41: Employee Details Form ............................................................................................... 59
Figure 42: Department Details Form ............................................................................................ 60
Figure 43: Job Details Form ......................................................................................................... 60
Figure 44: Role Details Form ....................................................................................................... 61
Figure 45: Home Page User Manual ............................................................................................. 62
Figure 46: Basics Form User Manual .......................................................................................... 63
Figure 47: Complex Forms User Manual ..................................................................................... 64
Figure 48: Before Inserting ........................................................................................................... 65
Figure 49: During Inserting .......................................................................................................... 65
Figure 50: After Inserting ............................................................................................................. 66
Figure 51: Before Updating .......................................................................................................... 66
Figure 52: During Updating .......................................................................................................... 66
Figure 53: After Updating ............................................................................................................. 67
Figure 54: Before Deleting ........................................................................................................... 67
Figure 55: After Deleting .............................................................................................................. 67
Figure 56: Before Inserting ........................................................................................................... 68
Figure 57: During Inserting .......................................................................................................... 68
Figure 58: After Inserting ............................................................................................................. 68
Figure 59: Before Updating .......................................................................................................... 69
Figure 60: During Updating .......................................................................................................... 69
Figure 61: After Updating ............................................................................................................. 69
Figure 62: Before Deleting ........................................................................................................... 70
Figure 63: After Deleting .............................................................................................................. 70
Figure 64:Before Inserting ............................................................................................................ 71
Figure 65: During Inserting .......................................................................................................... 71
Figure 66: After Inserting ............................................................................................................. 72
Figure 67: Before Updating .......................................................................................................... 72
Figure 68: During Updating .......................................................................................................... 73
Figure 69: After Updating ............................................................................................................. 73
Figure 70: Before Deleting ........................................................................................................... 74
Figure 71: After Deleting .............................................................................................................. 74
Figure 72: Before Inserting ........................................................................................................... 75
Figure 73:After Inserting .............................................................................................................. 75
Figure 74: Before Updating .......................................................................................................... 76
Figure 75: During Updating .......................................................................................................... 76
Figure 76: After Updating ............................................................................................................. 76
Figure 77: Before Deleting ........................................................................................................... 77
Figure 78: After Deleting .............................................................................................................. 77
Figure 79: Before Inserting ........................................................................................................... 78
Figure 80: During Inserting .......................................................................................................... 79
Figure 81: After Inserting ............................................................................................................. 80
Figure 82: Before Updating .......................................................................................................... 80
Figure 83: During Updating .......................................................................................................... 81
Figure 84: After Updating ............................................................................................................. 81
Figure 85: Before Deleting ........................................................................................................... 82
Figure 86: After Deleting .............................................................................................................. 82

Tables
Table 1: Employees Table Data Dictionary .................................................................................. 17
Table 2: Jobs Table Data Dictionary ............................................................................................ 17
Table 3: Roles Table Data Dictionary .......................................................................................... 18
Table 4: Addresses Table Data Dictionary ................................................................................... 18
Table 5: Employee_Addresses Table Data Dictionary ................................................................. 19
Table 6: Departments Table Data Dictionary ............................................................................... 19
Table 7: Job_Histories Table Data Dictionary.............................................................................. 19
Table 8: Email_Addresses Table Data Dictionary........................................................................ 20
Table 9: Department_Managers Table Data Dictionary ............................................................... 20
Table 10: Votes Table Data Dictionary ........................................................................................ 20
1. Introduction
This individual coursework for this subject, required us to construct and design database systems.
Analysing, creating, and constructing a web-based database application is another requirement for
this course. The case study that was provided to us was taken into consideration when creating the
database. The task started by assuming the appropriate Entities and Institute attributes, together
with main and foreign keys, a procedure known as normalization.

The prototype of this system was developed using Microsoft Visual Studio, ASP.NET, and C#.
The E-R diagram was converted into tables using SQL Developer Data Modular, and the tables
were then filled using the "Insert" command. Web forms developed in Visual Studio were used to
display all the data and to enable complete insert, update, and delete functionality as well as the
proper query implementation.
2. Textual Analysis

Figure 1: Textual Analysis of Employee and Department

Description: One employee is assigned to either one department or none. One department can have
at least one employee or many employees.

Figure 2: Textual Analysis of Role and Job

Description: One role must assign to one job. One job can have at least one role or many roles.

Figure 3: Textual Analysis of Employee and JobHistory

Description: One Job History must be of one employee. One employee can have at least one or
many job history.

Figure 4: Textual Analysis of Manager and Employee

Description: One manager must manage many employees. One employee must have one manager.
3. ERD from Case Study

Figure 5: Initial ERD from Case Study


4. Normalization

4.1. Normalization of figure 1

4.1.2. Unnormalized Form (UNF)

Employee (employeeID, employeeName, DateofBirth, Contact, {emailAddress},


{addressID, Address}, departmentID, department)
# Column addressID and departmentID are added.

4.1.3. Frist Normal Form (1NF)

In 1NF repeating groups and repeating data are separated into different entities. Therefore, the
final tables in 1NF after seperation are:

Employee-1 (employeeID, employeeName, DateofBirth, Contact, departmentID, Department).


EmailAddress-1 (emailAddress, employeeID*).
Address-1 (addressID, address, employeeID*).
Reference:
* -> Foreign key
____ -> Primary key
Two or more primary keys -> Composite key

4.1.4. Second Normal Form (2NF)

In 2NF partial dependencies are checked and removed from each entity.

Since there is only one primary key in the Employee-1 and EmailAddress-1, there will not be any
partial dependencies.

Checking partial dependency in Address-1:


addressID -> address
addressID, employeeID -> X
Removing partial dependency in Address-1:
➢ New entity with addressID as primary key and address as non-primary is created.
➢ New entity with addressID and employeeID both as primary key is created.

Address-2 (addressID, address)


EmployeeAddress-2 (employeeID*, addressID*)
Now, the final tables in 2NF are:
Employee-2: (employeeID, employeeName, DateofBirth, Contact, departmentID, Department).
EmailAddress-2: (emailAddress, employeeID*).
Address-2 (addressID, address)
EmployeeAddress-2 (employeeID*, addressID*)

4.1.5. Third Normal Form (3NF)

In 3NF transitive dependencies are checked and removed.

In EmailAddress-2 and Address-2, there are no transitive dependency as they have only one non
key attribute. Hence, they are already in 3NF.

In EmployeeAdress-2 there is not any non-key attribute. Hence this entity also does not have
transitive dependency and is already in 3NF.

Checking transitive dependency in Employee-2:


employeeID -> departmentID
departmentID -> Department
Removing transitive dependency from Employee-2:
➢ New entity with departmentID as primary key and Department as non-primary key is
created.
➢ departmentID is set as foreign key in Employee-3.
Employee-3 (employeeID, employeeName, DateofBirth, Contact, departmentID*)
Department-3 (departmentID, department)
Now, the final tables in 3NF are:
Employee-3 (employeeID, employeeName, DateofBirth, Contact, departmentID*)
Department-3 (departmentID, department)
EmailAddress-3 (emailAddress, employeeID*).
Address-3 (addressID, address)
EmployeeAddress-3 (employeeID*, addressID*)

4.2. Normalization of figure 2.

4.2.1. Unnormalized Form (UNF)

Voter (voterID, voterName {votingYear, votingMonth, candidateID, candidateName,


departmentID, candidateDepartment})

4.2.2. First Normal Form (1NF)

To be in 1NF repeating groups and repeating data are separated into different entities. Therefore,
the final tables in 1NF after seperation are:

Voter-1 (voterID, voterName)


VotingDetails-1 (votingYear, votingMonth, candidateID, candidateName, candidateDepartment,
voterID*)

4.2.3. Second Normal Form (2NF)

To be in 2NF, partial dependency is checked and removed.

Since there is only key in the Voter-1, it does not have any partial dependency they are already in
2NF.

In VotingDetails-1, all the non key attributes fully depend on the composite key (all the primary
key). Therefore, VotingDetails-1 does not have any partial dependency and are already in 2NF
Now, the final tables in the 2NF are as in 1NF:
Voter-2 (voterID, voterName)
VotingDetails-2 (votingYear, votingMonth, candidateID, candidateName, candidateDepartment,
voterID*)

4.2.4. Third Normal Form (3NF)

To be in 3NF transitive dependency is checked and removed.


Since there are only one key and one non key in Voter-2, it does not have any transitive dependency
and are already in 3NF.

Checking transitive dependency in VotingDetails-2:


votingID*, votingYear, votingMonths -> candidateID
candidateID -> candidateName, candidateDepartment
Removing transitive dependency from VotingDetails-2:
➢ New entity with votingID, votingYear and votingMonths as primary keys and candidateID
as foreign key is created.
➢ New entity with candidateID as primary key and candidateName and candidateDepartment
as foreign key is created.

VotingDetails-3 (voterID*, votingYear, votingMonth, candidateID*)


Candidate-3 (candidateID, candidateName, candidateDepartment)
Now, the final tables in 3NF are:
Voter-3 (voterID, voterName)
VotingDetails-3 (voterID*, votingYear, votingMonth, candidateID*)
Candidate-3 (candidateID, candidateName, candidateDepartment)
5. Integration and Assumption
Since, voters and candidates both are the employees of this organization, we can remove Voter-3
and Candidate-3 from figure 2 normalization to remove data redundancy. Job, job history and role
entities from initial ERD along with the remaining entities from normalization of figure one and
two are the final entities. The address attribute of address entity is broken down into city, district,
and province. The new entity departmentManager is also created to make data manipulation
feasible.

Job (jobsID, jobTitle)

Role (roleID, roleName, jobID*)

JobHistory (jobHistoryID, roleID*, departmentID*, startDate, endDate)

Employee (employeeID, employeeName, DateofBirth, Contact, departmentID*)

Department (departmentID, department)

EmailAddress (emailAddress, employeeID*).

Address (addressID, city, district, province)

EmployeeAddress (employeeID*, addressID*)

Voter (voterID, voterName)

VotingDetails (voterID*, votingYear, votingMonth, candidateID*)

departmentManager (departmentID, EmployeeID*)


6. Final ERD

Figure 6: Final ERD


7. Data Dictionary

7.1. Employees Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Employee_ Varchar 10 Primary Key To uniquely identify E1
id Each employee
Employee_ Varchar 30 Not null To store the Ram Sharma
name employee’s name
Date_of_bi DATE Not null To store employee’s 05/05/2000
rth DOB
contact Varchar 10 Unique
Department Varchar 10 Foreign Key Department Departme To store the D1
_id nt_id employee’s allocated
department
Role_id Varchar 10 Foreign Key Role Role_id To store the R1
employee’s allocated
role
salary Integer Not null To store the 80000
employee’s salary
Table 1: Employees Table Data Dictionary

7.2. Jobs Table

Data Size Constraint Reference Reference Description Example Data


Column Type Table Column
Name
Job_id Varchar 10 Primary Key To uniquely identify J1
Each job
Job_title Varchar 30 Not null To store the job title Manager
Table 2: Jobs Table Data Dictionary
7.3. Roles Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Role_id Varchar 10 Primary Key To uniquely identify R1
Each Role
Role_title Varchar 30 Not null To store the Role title Legal Advisor
Job_id Varchar 10 Foreign Key Job Job_id To store the J1
employee’s allocated
job
Table 3: Roles Table Data Dictionary

7.4. Addresses Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Address_id Varchar 10 Primary Key To uniquely identify A1
Each address
City Varchar 30 Not null To store the city Kathmandu
name
District Varchar 30 Not null To store district Kathmandu
name
province Varchar 30 Not null To store the Bagmati
province
Table 4: Addresses Table Data Dictionary

7.5. Employee_Addresses Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Employee_ Varchar 10 Primary Key, employee Employee To uniquely identify E1
id Foreign Key _id Each employee
Address_id Varchar 10 Primary Key, address address_id To uniquely identify A1
Foreign Key Each address
Table 5: Employee_Addresses Table Data Dictionary

7.6. Departments Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Departmen Varchar 10 Primary Key To uniquely identify D1
et_id Each department
Department Varchar 30 Not null To store the Marketing
_name department name
Table 6: Departments Table Data Dictionary

7.7. Job_Histories Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Job_history Varchar 10 Primary Key To uniquely identify JH1
_id Each job history
Department Varchar 10 Foreign Key Department Departme To uniquely identify D1
_id nt_id Each department
Role_id Varchar 10 Foreign Key Role Role_id To uniquely identify R1
Each role
Start_date DATE Not null To store start date 2015/02/23
End_date DATE Not null To store end date 2020/06/25
Employee_ Varchar 10 Foreign Key Employee Employee To uniquely identify E1
id _id Each employee
Table 7: Job_Histories Table Data Dictionary

7.8. Email_Addresses Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
email Varchar 10 Primary Key To uniquely identify Xyz123@gmail.
Each email com
Employee_ Varchar 10 Foreign Key employee Employee To uniquely identify E1
id _id Each the employee
Table 8: Email_Addresses Table Data Dictionary

7.9. Department_Managers Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Department Varchar 10 Primary Key, department Departme To uniquely identify D1
_id Foreign Key nt_id Each department
Employee_ Varchar 10 Foreign Key employee employee To uniquely identify E1
id _id Each employee
Table 9: Department_Managers Table Data Dictionary

7.10. Votes Table

Column Data Size Constraint Reference Reference Description Example Data


Name Type Table Column
Voter_id Varchar 10 Primary Key, Employee Employee To uniquely identify E1
Foreign Key _id Each voter
Voting_mo Varchar 30 Primary Key To uniquely identify Jan
nth Each voting month
Voting_yea Intiger Primary Key To uniquely identify 2000
r Each voting year
candidate_i Varchar 10 Foreign Key Employee Employee To uniquely identify E1
d _id Each candidate
Table 10: Votes Table Data Dictionary
8. Scripts

8.1. Departments Table Script

CREATE TABLE departments (


department_id VARCHAR2(10 CHAR)
CONSTRAINT nnc_department_department_id NOT NULL,
department_name VARCHAR2(30 CHAR) NOT NULL
);

ALTER TABLE departments ADD CONSTRAINT department_pk PRIMARY KEY (


department_id );
ALTER TABLE departments ADD CONSTRAINT department__un UNIQUE (
department_name );

Figure 7: Departments Table Script


8.2. Jobs Table Script

CREATE TABLE jobs (


job_id VARCHAR2(10 CHAR) NOT NULL,
job_title VARCHAR2(30 CHAR) NOT NULL
);

ALTER TABLE jobs ADD CONSTRAINT job_pk PRIMARY KEY ( job_id );

Figure 8: Jobs Table Script


8.3. Roles Table Script

CREATE TABLE roles (


role_id VARCHAR2(10 CHAR) NOT NULL,
role_title VARCHAR2(30 CHAR) NOT NULL,
job_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE roles ADD CONSTRAINT role_pk PRIMARY KEY ( role_id );

ALTER TABLE roles


ADD CONSTRAINT role_job_fk FOREIGN KEY ( job_id )
REFERENCES jobs ( job_id );
Figure 9: Roles Table Script

8.4. Addresses Table Script

CREATE TABLE addresses (


address_id VARCHAR2(10 CHAR) NOT NULL,
city VARCHAR2(30 CHAR) NOT NULL,
district VARCHAR2(30 CHAR) NOT NULL,
province VARCHAR2(30 CHAR) NOT NULL
);

ALTER TABLE addresses ADD CONSTRAINT address_pk PRIMARY KEY ( address_id );


Figure 10: Addresses Table Script

8.5. Employees Table Script

CREATE TABLE employees (


employee_id VARCHAR2(10 CHAR) NOT NULL,
employee_name VARCHAR2(30 CHAR) NOT NULL,
date_of_birth DATE NOT NULL,
contact VARCHAR2(10 CHAR) NOT NULL,
department_id VARCHAR2(10 CHAR) NOT NULL,
role_id VARCHAR2(10 CHAR) NOT NULL,
salary INTEGER NOT NULL
);

ALTER TABLE employees ADD CONSTRAINT employee_pk PRIMARY KEY ( employee_id


);

ALTER TABLE employees ADD CONSTRAINT employee__un UNIQUE ( contact );

ALTER TABLE employees


ADD CONSTRAINT employee_department_fk FOREIGN KEY ( department_id )
REFERENCES departments ( department_id );

ALTER TABLE employees


ADD CONSTRAINT employee_role_fk FOREIGN KEY ( role_id )
REFERENCES roles ( role_id );
Figure 11: Employees Table Script
8.6. Email_Addresses Table Script

CREATE TABLE email_addresses (


email VARCHAR2(50 CHAR) NOT NULL,
employee_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE email_addresses ADD CONSTRAINT email_pk PRIMARY KEY ( email,


employee_id );

ALTER TABLE email_addresses


ADD CONSTRAINT email_address_employee_fk FOREIGN KEY ( employee_id )
REFERENCES employees ( employee_id );

Figure 12: Email_Addresses Table Script


8.7. Votes Table Script

CREATE TABLE votes (


voter_id VARCHAR2(10 CHAR) NOT NULL,
voting_year INTEGER NOT NULL,
voting_month VARCHAR2(30) NOT NULL,
candidate_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE votes


ADD CONSTRAINT votes_pk PRIMARY KEY ( voting_year,
voter_id, voting_month );

ALTER TABLE votes


ADD CONSTRAINT votes_employee_fk FOREIGN KEY ( voter_id )
REFERENCES employees ( employee_id );

ALTER TABLE votes


ADD CONSTRAINT votes_employee_fkv1 FOREIGN KEY ( candidate_id )
REFERENCES employees ( employee_id );
Figure 13: Votes Table Script
8.8. Job_Histories Table Script

CREATE TABLE job_histories (


job_history_id VARCHAR2(10 CHAR) NOT NULL,
department_id VARCHAR2(10 CHAR) NOT NULL,
role_id VARCHAR2(10 CHAR) NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
employee_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE job_histories ADD CONSTRAINT job_history_pk PRIMARY KEY (


job_history_id );

ALTER TABLE job_histories


ADD CONSTRAINT job_history_department_fk FOREIGN KEY ( department_id )
REFERENCES departments ( department_id );

ALTER TABLE job_histories


ADD CONSTRAINT job_history_employee_fk FOREIGN KEY ( employee_id )
REFERENCES employees ( employee_id );

ALTER TABLE job_histories


ADD CONSTRAINT job_history_role_fk FOREIGN KEY ( role_id )
REFERENCES roles ( role_id );
Figure 14: Job_Hitories Table Script
8.9. Employee_Addresses Table Script

CREATE TABLE employee_addresses (


employee_id VARCHAR2(10 CHAR) NOT NULL,
address_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE employee_addresses ADD CONSTRAINT address_employee_pk PRIMARY


KEY ( employee_id, address_id );

ALTER TABLE employee_addresses


ADD CONSTRAINT address_employee_address_fk FOREIGN KEY ( address_id )
REFERENCES addresses ( address_id );

ALTER TABLE employee_addresses


ADD CONSTRAINT address_employee_employee_fk FOREIGN KEY ( employee_id )
REFERENCES employees ( employee_id );
Figure 15: Employee_Addresses Table Script
8.9. Department_Managers Table Script

CREATE TABLE department_managers (


department_id VARCHAR2(10 CHAR) NOT NULL,
employee_id VARCHAR2(10 CHAR) NOT NULL
);

ALTER TABLE department_managers ADD CONSTRAINT department_manager_pk


PRIMARY KEY ( department_id );

ALTER TABLE department_managers


ADD CONSTRAINT department_mangr_department_fk FOREIGN KEY ( department_id )
REFERENCES departments ( department_id );

ALTER TABLE department_managers


ADD CONSTRAINT department_manager_employee_fk FOREIGN KEY ( employee_id )
REFERENCES employees ( employee_id );

Figure 16: Department_Managers Table Script


9. Insert Statements

9.1. Departments Table Insert Statement

INSERT ALL
INTO departments VALUES ('D1', 'Marketing')
INTO departments VALUES ('D2', 'Finance')
INTO departments VALUES ('D3', 'IT')
INTO departments VALUES ('D4', 'customer')
INTO departments VALUES ('D5', 'legal')
SELECT * FROM dual;

Figure 17: Departments Table Insert Statement


9.2. Jobs Table Insert Statement

INSERT ALL
INTO jobs VALUES ('J1', 'Marketing Manager')
INTO jobs VALUES ('J2', 'Financial Analyst')
INTO jobs VALUES ('J3', 'IT specialist')
INTO jobs VALUES ('J4', 'Customer SR')
INTO jobs VALUES ('J5', 'Legal Counseler')
SELECT * FROM dual

Figure 18: Jobs Table Insert Statement


9.3. Roles Table Insert Statement

INSERT ALL
INTO roles VALUES ('R1', 'Marketing Coordinator','J1')
INTO roles VALUES ('R2', 'Marketing Researcher','J1')
INTO roles VALUES ('R3', 'Marketing Analyst','J1')
INTO roles VALUES ('R4', 'Financial Planner','J2')
INTO roles VALUES ('R5', 'Financial Advisor','J2')
INTO roles VALUES ('R6', 'IT Administrator','J3')
INTO roles VALUES ('R7', 'IT Support Specialist','J3')
INTO roles VALUES ('R8', 'Customer Support R','J4')
INTO roles VALUES ('R9', 'Customer Support Manager','J4')
INTO roles VALUES ('R10', 'Legal Assistant','J5')
SELECT * FROM dual;

Figure 19: Roles Table Insert Statement


9.4. Addresses Table Insert Statement

INSERT ALL
INTO addresses VALUES ('A1', 'Kathmandu','Kathmandu','Bagmati')
INTO addresses VALUES ('A2', 'Biratnagar','Morang','Province 1')
INTO addresses VALUES ('A3', 'Pokhara','Kaski','Gandaki')
INTO addresses VALUES ('A4', 'Butwal','Rupandehi','Lumbini')
INTO addresses VALUES ('A5', 'Janakpur','Dhanusha','Province 2')
SELECT * FROM dual;

Figure 20: Addresses Table Insert Statement


9.5. Employees Table Insert Statement

INSERT ALL
INTO employees VALUES ('E1', 'Ram Sharma', TO_DATE('1990-01-01', 'YYYY-MM-DD'),
'9861234567','D1','R1','50000')
INTO employees VALUES ('E2', 'Sita Maharjan', TO_DATE('1995-06-15', 'YYYY-MM-DD'),
'9871234561','D1','R1','45000')
INTO employees VALUES ('E3', 'Gita Thapa', TO_DATE('1995-06-15', 'YYYY-MM-DD'),
'9841236562','D2','R4','30000')
INTO employees VALUES ('E4', 'Hari Shrestha', TO_DATE('1992-03-07', 'YYYY-MM-DD'),
'9841234563','D2','R5','35000')
INTO employees VALUES ('E5', 'Nisha Tamang', TO_DATE('1993-07-19', 'YYYY-MM-DD'),
'9841534564','D3','R7','40000')
INTO employees VALUES ('E6', 'Bibek Adhikari', TO_DATE('1991-12-10', 'YYYY-MM-DD'),
'9891234565','D3','R7','30000')
INTO employees VALUES ('E7', 'Pramila Koirala', TO_DATE('1985-04-30', 'YYYY-MM-
DD'), '9841434566','D4','R8','20000')
INTO employees VALUES ('E8', 'Raju Shrestha', TO_DATE('1997-08-08', 'YYYY-MM-DD'),
'9821334567','D4','R9','45000')
INTO employees VALUES ('E9', 'Ramesh Khadka', TO_DATE('1994-05-25', 'YYYY-MM-
DD'), '9841234568','D5','R10','50000')
INTO employees VALUES ('E10', 'Sandhya Bhattarai', TO_DATE('1996-09-17', 'YYYY-MM-
DD'), '9861134569','D5','R10','60000')
SELECT * FROM dual;
Figure 21: Employees Table Insert Statement
9.6. Email_Addresses Table Insert Statement

INSERT ALL
INTO employee_addresses VALUES ('E1','A5')
INTO employee_addresses VALUES ('E2','A5')
INTO employee_addresses VALUES ('E4','A2')
INTO employee_addresses VALUES ('E3','A1')
INTO employee_addresses VALUES ('E9','A2')
INTO employee_addresses VALUES ('E10','A3')
INTO employee_addresses VALUES ('E5','A4')
INTO employee_addresses VALUES ('E6','A3')
INTO employee_addresses VALUES ('E6','A1')
INTO employee_addresses VALUES ('E9','A4')
SELECT * FROM DUAL;

Figure 22: Email_Addresses Table Insert Statement


9.7. Votes Table Insert Statement

INSERT ALL
INTO votes VALUES ('E1','2020','Jan','E5')
INTO votes VALUES ('E2','2020','Jan','E6')
INTO votes VALUES ('E1','2020','Feb','E6')
INTO votes VALUES ('E2','2020','Feb','E5')
INTO votes VALUES ('E3','2020','Jan','E9')
INTO votes VALUES ('E3','2020','May','E10')
INTO votes VALUES ('E4','2021','Jan','E6')
INTO votes VALUES ('E4','2021','Feb','E1')
INTO votes VALUES ('E5','2021','Mar','E3')
INTO votes VALUES ('E5','2021','Apr','E3')
INTO votes VALUES ('E6','2021','May','E4')
INTO votes VALUES ('E6','2021','Jun','E5')
INTO votes VALUES ('E7','2021','Jul','E5')
INTO votes VALUES ('E7','2021','Oct','E8')
INTO votes VALUES ('E8','2022','Jan','E9')
INTO votes VALUES ('E8','2022','Feb','E5')
INTO votes VALUES ('E9','2022','Jan','E6')
INTO votes VALUES ('E9','2022','Sept','E10')
INTO votes VALUES ('E10','2022','Nov','E9')
INTO votes VALUES ('E10','2022','Dec','E9')
SELECT * FROM dual;
Figure 23: Votes Table Insert Statement
9.8. Job_Histories Table Insert Statement

INSERT all
INTO job_histories VALUES ('JH1', 'D1', 'R2', TO_DATE('2015-01-01', 'YYYY-MM-DD'),
TO_DATE('2016-02-28', 'YYYY-MM-DD'), 'E1')
INTO job_histories VALUES ('JH2', 'D3', 'R6', TO_DATE('2016-03-01', 'YYYY-MM-DD'),
TO_DATE('2017-04-30', 'YYYY-MM-DD'), 'E3')
INTO job_histories VALUES ('JH3', 'D4', 'R8', TO_DATE('2017-05-01', 'YYYY-MM-DD'),
TO_DATE('2018-06-30', 'YYYY-MM-DD'), 'E4')
INTO job_histories VALUES ('JH4', 'D2', 'R4', TO_DATE('2018-07-01', 'YYYY-MM-DD'),
TO_DATE('2019-08-31', 'YYYY-MM-DD'), 'E5')
INTO job_histories VALUES ('JH5', 'D4', 'R9', TO_DATE('2019-09-01', 'YYYY-MM-DD'),
TO_DATE('2020-10-31', 'YYYY-MM-DD'), 'E6')
INTO job_histories VALUES ('JH6', 'D5', 'R10', TO_DATE('2015-02-01', 'YYYY-MM-DD'),
TO_DATE('2016-03-31', 'YYYY-MM-DD'), 'E8')
INTO job_histories VALUES ('JH7', 'D1', 'R2', TO_DATE('2016-04-01', 'YYYY-MM-DD'),
TO_DATE('2017-05-31', 'YYYY-MM-DD'), 'E5')
INTO job_histories VALUES ('JH8', 'D5', 'R10', TO_DATE('2017-06-01', 'YYYY-MM-DD'),
TO_DATE('2018-07-31', 'YYYY-MM-DD'), 'E5')
INTO job_histories VALUES ('JH9', 'D5', 'R10', TO_DATE('2018-08-01', 'YYYY-MM-DD'),
TO_DATE('2019-09-30', 'YYYY-MM-DD'), 'E2')
INTO job_histories VALUES ('JH10', 'D5', 'R10', TO_DATE('2019-10-01', 'YYYY-MM-DD'),
TO_DATE('2020-12-31', 'YYYY-MM-DD'), 'E2')
SELECT * FROM dual;
Figure 24: Job_Histories Table Insert Statement

9.9. Employee_Addresses Table Insert Statement

INSERT ALL
INTO employee_addresses VALUES ('E1','A5')
INTO employee_addresses VALUES ('E2','A5')
INTO employee_addresses VALUES ('E4','A2')
INTO employee_addresses VALUES ('E3','A1')
INTO employee_addresses VALUES ('E9','A2')
INTO employee_addresses VALUES ('E10','A3')
INTO employee_addresses VALUES ('E5','A4')
INTO employee_addresses VALUES ('E6','A3')
INTO employee_addresses VALUES ('E6','A1')
INTO employee_addresses VALUES ('E9','A4')
SELECT * FROM DUAL;
Figure 25: Employee_Addresses Table Insert Statement

9.10. Department_Managers Table Insert Statement

INSERT ALL
INTO department_managers VALUES ('D1','E2')
INTO department_managers VALUES ('D2','E4')
INTO department_managers VALUES ('D3','E7')
INTO department_managers VALUES ('D4','E8')
INTO department_managers VALUES ('D5','E9')
SELECT * FROM dual;
Figure 26: Department_Managers Table Insert Statement
10. Select Statements

Figure 27: Departments Table Select Statement

Figure 28: Jobs Table Select Statement


Figure 29: Roles Table Select Statement

Figure 30: Email_Addresses Table Select Statement


Figure 31: Addresses Table Select Statement

Figure 32: Employees Table Select Statement


Figure 33: Votes Table Select Statement
Figure 34: Employee_addresses Table Select Statement

Figure 35: Job_Histories Table Select Statement


Figure 36: Department_Managers Table Select Statement
11. Forms

11.1. Home Page

Figure 37: Home Page

11.2. Complex Forms and Queries

11.2.1. SQL Queries

11.2.1.1. Employee Job History Query

SELECT
e.employee_id, e.employee_name, d.department_name, r.role_title, j.start_date, j.end_date
FROM employees e
JOIN job_histories j ON e.employee_id = j.employee_id
JOIN roles r ON j.role_id = r.role_id
JOIN departments d ON j.department_id = d.department_id
WHERE e.employee_id = :employeeid
ORDER BY j.start_date;
11.2.1.2. Voting Record Query

SELECT
v.voter_id,
e1.employee_name AS voter_name,
d1.department_name AS voter_department,
r1.role_title AS voter_role,
v.voting_year,
v.voting_month,
v.candidate_id,
e2.employee_name AS candidate_name,
d2.department_name AS candidate_department,
r2.role_title AS candidate_role
FROM votes v
JOIN employees e1 ON v.voter_id = e1.employee_id
JOIN departments d1 ON e1.department_id = d1.department_id
JOIN roles r1 ON e1.role_id = r1.role_id
JOIN employees e2 ON v.candidate_id = e2.employee_id
JOIN departments d2 ON e2.department_id = d2.department_id
JOIN roles r2 ON e2.role_id = r2.role_id
WHERE v.voter_id = :employeeid
ORDER BY v.voting_year DESC, v.voting_month;
11.2.1.3. Employee Of the Month Query

SELECT * FROM (
SELECT e.employee_id, e.employee_name, v.voting_month, v.voting_year,
COUNT(v.candidate_id) AS vote_count
FROM employees e
JOIN votes v ON e.employee_id = v.candidate_id
WHERE v.voting_month = :month
AND v.voting_year = :year
GROUP BY e.employee_id, e.employee_name, v.voting_month, v.voting_year
ORDER BY vote_count DESC )
where rownum <= 3;

11.2.2. Complex Forms

11.2.2.1. Employee Job History From

Figure 38: Employee Job History Form

11.2.2.2. Voting Record From

Figure 39: Voting Record Form


11.2.2.3. Employee of the Month Form

Figure 40: Employee Of The Month Form


11.3. Simple Forms

11.3.1. Employee Details Form

Figure 41: Employee Details Form


11.3.2. Department Details Form

Figure 42: Department Details Form

11.3.3. Job Details Form

Figure 43: Job Details Form


11.3.3. Role Details Form

Figure 44: Role Details Form


12. User Manual

12.1. Home page

Figure 45: Home Page User Manual

Label 1 in the picture indicate the basic forms where there are basic forms below.
Label 2 in the picture indicate the basic forms where there are complex forms below.
Label 3 in the picture indicates that the user can view the details of Employee by clicking on it.
Label 4 in the picture indicates that the user can view the details of Employee Job History by
clicking on it.
12.2. Basic Forms

Figure 46: Basics Form User Manual

Label 1 in the picture suggests the text fields where user can enter values.

Label 2 in the picture suggests the edit button on clicking which, user can edit the entry and text
field are generated.

Label 3 in the picture suggests the delete function which can delete the entry.

Label 5 in the picture suggests the insert function which can insert the entries available in text
fields.
Label 4 in the picture suggest the cancel option which will cancel the new entry into the table.
12.3. Complex Forms

Figure 47: Complex Forms User Manual

Label 2 denotes the drop-down menu where values are stored corresponding to the selected form.
Label 2 denotes the button that on clicking, fetches the data from the database and shows in the
grid view.
13. Testing

13.1. Departments Details Form Testing

13.1.1. Insert

Figure 48: Before Inserting

Figure 49: During Inserting


Figure 50: After Inserting

13.1.2. Update

Figure 51: Before Updating

Figure 52: During Updating


Figure 53: After Updating

13.1.3. Delete

Figure 54: Before Deleting

Figure 55: After Deleting


13.2. Jobs Details Form Testing

13.2.1. Insert

Figure 56: Before Inserting

Figure 57: During Inserting

Figure 58: After Inserting


13.2.2. Update

Figure 59: Before Updating

Figure 60: During Updating

Figure 61: After Updating


13.2.3. Delete

Figure 62: Before Deleting

Figure 63: After Deleting


13.3. Roles Details Form Testing

13.3.1. Insert

Figure 64:Before Inserting

Figure 65: During Inserting


Figure 66: After Inserting

13.3.2. Update

Figure 67: Before Updating


Figure 68: During Updating

Figure 69: After Updating


13.3.3. Delete

Figure 70: Before Deleting

Figure 71: After Deleting


13.4. Addresses Details Form Testing

13.4.1. Insert

Figure 72: Before Inserting

Figure 73:After Inserting


13.4.2. Update

Figure 74: Before Updating

Figure 75: During Updating

Figure 76: After Updating


13.4.3. Delete

Figure 77: Before Deleting

Figure 78: After Deleting


13.5. Employee Details Form Testing

13.5.1. Insert

Figure 79: Before Inserting


Figure 80: During Inserting
Figure 81: After Inserting

13.5.2. Update

Figure 82: Before Updating


Figure 83: During Updating

Figure 84: After Updating


13.5.3. Delete

Figure 85: Before Deleting

Figure 86: After Deleting


13.6. Failure Cases

13.6.1. Incorrect SQL Data Source

Figure 87: Error message for incorrect SQL Data Source

Figure 88: Result after correct data source is selected.


13.6.2. Delete Issue

Error message shown after trying to delete role from a table whose primary key is foreign key in
another table.

Figure 89: Delete Error message.

To fix this issue we first need to delete or update the row in another table where primary key from
this row is set as foreign key.
14. Further Discussion
This coursework was one of the most significant tasks I'd ever undertaken, and it taught me a lot.
Whether it's a database or building online forms in Visual Studio using C#. This curriculum has
polished my skills, and I am confident it will be beneficial to my final year project as well.

There are various tools used for the completion of this coursework. Some of them are listed
below:
SQL Developer:
The entity relationship diagram's ddl file was created using Oracle SQL Developer, as well as the
queries for CRUD operations.

SQL Data Modeler:


With the help of Oracle SQL Data Modeler, the entity relationship diagram was created (ERD).
The ERD creation process was made simple by the program below. The creation of an ERD also
makes it feasible to quickly establish the composite minor key, primary key, and foreign key.

Visual Studio 2022:


The system was created using Visual Studio 2022 in its final form. The creation of both simple
and complicated web types was done using this application. In order to enforce the sql database
records, it was also utilized to link the produced database, which is minor information.

Draw.io:
Draw.io is a diagram construction tool that was used to construct textual analysis diagrams and a
basic ERD of textual analysis.

HTML/CSS/Bootstrap:
The basic styling of web forms is likewise done using HTML and CSS. As a result, it has given
me a foundational understanding of these tools or languages, and therefore aids in the design of
the table.
15. Conclusion
In conclusion, this course was quite difficult, but it also taught me a lot about databases. One of
the hardest projects I've ever completed was this coursework. However, despite all of these
difficulties and ambiguity, I managed to gain a solid understanding of databases and gain
experience working with Visual Studio and C#. I also realized how important and valuable
databases are to every sector. My faith in the database industry has increased as a result of this
project.

You might also like