Sie sind auf Seite 1von 64

Contents

Table of Figures ............................................................................................................. 1


Introduction .................................................................................................................... 3
Task 1 ............................................................................................................................ 4
Question A: .................................................................................................................... 4
Entity relationship diagram ............................................................................................ 4
Entity ............................................................................................................................. 4
Attribute ......................................................................................................................... 4
Relationship ................................................................................................................... 4
Types of relationship ..................................................................................................... 4
Explanation of ER diagram ............................................................................................ 5
Question B: .................................................................................................................... 7
Normalization ................................................................................................................. 7
1NF (1st normal form) .................................................................................................... 7
2NF (2nd normal form) .................................................................................................... 7
3NF (3rd normal form) .................................................................................................... 7
Question C: .................................................................................................................... 9
Data Dictionary .............................................................................................................. 9
Meta data ...................................................................................................................... 9
Constraints .................................................................................................................... 9
Data Dictionary ............................................................................................................ 10
Task 2 .......................................................................................................................... 13
TASK 3 ........................................................................................................................ 38
Question A: .................................................................................................................. 38
TASK 4 ........................................................................................................................ 42
TASK 5 ........................................................................................................................ 43
Conclusion ................................................................................................................... 45
References .................................................................................................................. 46
Appendix ...................................................................................................................... 47
00168692-Bishes-Upadhyaya-DDD

Table of Figures
Illustration 1: ER Diagram ............................................................................................... 5
Illustration 2: Normalization ............................................................................................. 8
Illustration 3: Query to create a user named seasalter .................................................. 13
Illustration 4: Query to create table named Courses ..................................................... 13
Illustration 5: Query to create table named modules ..................................................... 14
Illustration 6: Query to create table named Courses_modules ...................................... 14
Illustration 7: Query to create table named Equipment_type ......................................... 15
Illustration 8: Query to create table named Equipment.................................................. 15
Illustration 9: Query to create table named Module_type .............................................. 16
Illustration 10: Query to create table named Laboratories ............................................. 16
Illustration 11: Query to create table named Laboratories_modules ............................. 17
Illustration 12: Query to create table named Modules_Module_type ............................. 17
Illustration 13: Query to create table named Staff_type................................................. 18
Illustration 14: Query to create table named Staff ......................................................... 18
Illustration 15: Query to create table named Staff_Courses .......................................... 19
Illustration 16: Query to create table named Laboratories_equipment .......................... 19
Illustration 17: inserting values in table Courses ........................................................... 20
Illustration 18: inserting data in table modules. ............................................................. 20
Illustration 19: inserting data in table Courses_modules ............................................... 21
Illustration 20: inserting data in table Equipment_type .................................................. 21
Illustration 21: inserting data in table equipment ........................................................... 22
Illustration 22: inserting data in table Laboratories ........................................................ 23
Illustration 23: inserting data in table Laboratories_modules ......................................... 23
Illustration 24: inserting data in table Module_type ....................................................... 24
Illustration 25: inserting data in table Modules_module_type ........................................ 24
Illustration 26: inserting data in table staff_type ............................................................ 25
Illustration 27: inserting data in table staff ..................................................................... 25
Illustration 28: inserting data in table staff_courses ....................................................... 26
Illustration 29: inserting data in table laboratories_equipment....................................... 27
Illustration 30: Queries to show all the data of table courses and teacher .................... 28
Illustration 31: Query to show data for modules with its teachers .................................. 29
Illustration 32: Query to list all the data on laboratories table ........................................ 30
Illustration 33: Query to list the equipment found in laboratories ................................... 31
Illustration 34: Query to show all the teachers teaching chemistry ................................ 32
Illustration 35: Query changing plant biology to core unit .............................................. 32
Illustration 36: Query to edit the name of a teacher ....................................................... 33
Illustration 37: Query to shows all equipment in the chemistry laboratories .................. 34
Illustration 38: Query that shows all the teachers who might be using a microscope. ... 35
Illustration 39: Queries showing details of all courses and the modules including the
teachers for them .......................................................................................................... 36
Illustration 40: Query showing how many types of item are classified as Chemistry
Experiment. ................................................................................................................... 37

1
00168692-Bishes-Upadhyaya-DDD

Illustration 41: Modified ER Diagram ............................................................................. 38


Illustration 42: Query to create table maintenance_type ............................................... 39
Illustration 43: Query to insert data into table maintenance_type .................................. 39
Illustration 44: Query to create table lab_maintenance ................................................. 39
Illustration 45: Query to insert data into lab_maintenance............................................. 40
Illustration 46: Grant view to seasalter. ......................................................................... 40
Illustration 47: Query to create view for cost information ............................................... 41
Illustration 48: Distributed database system .................................................................. 43

2
00168692-Bishes-Upadhyaya-DDD

Introduction
Seasalter College is a further education college based on Kent, United Kingdom that
specialize in science education wants a standard database to manage teaching and
resources for their various courses. Based on the scenario a system is designed to
address the indispensable requirements of the college. Initially the scenario is to be
normalized to for making a proper Entity Relationship diagram from which a data
dictionary is auto generated using reverse engineering function. This will make writing the
queries easier and efficient. ER diagram and data dictionary is made using Visual
paradigm and all the queries are written using SQL tools and the database is stored in
ORACLE 11g.

3
00168692-Bishes-Upadhyaya-DDD

Task 1
Question A:

Entity relationship diagram


Entity-relationship (ER) diagram is a data modelling technique that shows the graphic
depiction of entities and their respective relationships to each other. It is generally used
in computing to embody the entity framework infrastructure.(Connolly and Begg)
The elements of ER diagram are:

 Entities
 Relationships
 Attributes

Entity
In regards to database, an entity is any object in a system that is singular, distinguishable
and distinct. Usually, entities are easily identifiable as it refers to individuals, organizations
or even distinct system component which are significant to themselves. (Rouse and Flanigan)

Attribute
Attributes are the characteristics of the entities. In a database management system an
attribute denotes a database element such as table. They describe the instances in the
row of a database. For example, the attributes in staff might be first_name, DOB or
contact_number. (Rouse)

Relationship
In the background of databases, a relationship are the state that occurs amongst two
relational database tables when one table has a foreign key that references the primary
key of other tables. Relationship authorities relational databases to divide and store data
in different tables, while linking desperate data.

Types of relationship
In databases there are a total of three types of relationship. They are as follows:

 One-to-one relationships: This type of relationship is applied via single table by


forming relationship between identical types of column in table.

4
00168692-Bishes-Upadhyaya-DDD

 One-to-many relationships: This relationship is applied using two tables with primary
key and foreign key relationships.

 Many-to-many relationships: It is a complex relationship applied using a junction


table. The keys from both tables form composite primary key of the junction table.
(Elmasri and Navathe)

Explanation of ER diagram

Illustration 1: ER Diagram

5
00168692-Bishes-Upadhyaya-DDD

Centered on the given scenario and sample data an Entity Relationship Diagram for
Seasalter College is developed. The above ER shows that a staff might be allocated in
teaching one or more than one course and a course might be taught by many staffs
therefore to resolve this issue a linking table is created. Similarly a staff’s first name has
been made not null because a staff cannot be without a first name and their phone number
and email address is made to be unique because they must always be exclusive and
cannot be similar to each other. Module_type table is made and shares a many to many
relationship with modules table because a module type can have many modules in them
and a module can be a part of many module types. In the modules table module_code
is set to be the primary key and in the Courses table course_code is made as the primary
key. Since they have many to many relationship a linking table Courses_module is
created where the primary key of both table are made into foreign key. In the
Equipment_type table Equipment_type_id is set as the primary key and equipment_type
is made unique because in the scenario this field is already defined. This table shares a
one to many relationship with Equipment table because equipment_type can have many
equipment in it. Therefore the Equipment_type_id is made to be the foreign key in the
Equipment table. Laboratory_ID is the primary key in the Laboratories table and
Laboratory_Name is made to be unique since there cannot be more than one laboratory
with the same name. Similarly a laboratory can have many equipment in it and many
equipment can be found in many laboratories therefore there is a many to many
relationship among these two tables where the primary key of the parent table is made to
be the foreign key and a new field quantity is added and made as not null to find out the
number of equipment in a laboratory. The entities for the table were carefully chosen
using Natural Language Analysis and for every many to many relationship a linking table
is created. Constraints are given to the attributes based to the tables.

6
00168692-Bishes-Upadhyaya-DDD

Question B:
Normalization
Normalization is a procedure of reordering data in a database in order to decrease the
redundancy of data and to make sure that the data dependencies are reasonable.
Normalization is performed because it allows the database to take up as little disk space
as possible which results in improved performance.
There are three main types of normalization which are explained below:

1NF (1st normal form)


Any multi valued attributes is detached so that there will be a solitary value at the juncture
of each row and column. First Normalization form eradicates repeating groups in
individual table, creates a distinct table for each set of related data, identify each set of
data with primary key

2NF (2nd normal form)


Second Normalization form removes the partial dependencies. It is in the first normal form
and all non-key attributes are fully functional dependent upon primary key.

3NF (3rd normal form)


Third normalized form removes transitive dependencies. The tables are in 2 nd Normal
form and it contains only column that are non-transitively dependent on the primary key.

7
00168692-Bishes-Upadhyaya-DDD

Normalization

Illustration 2: Normalization

8
00168692-Bishes-Upadhyaya-DDD

Question C:

Data Dictionary
A data dictionary is a group of database tables used to collect evidence about a
database’s description. It covers information such as tables, datatypes, rows, indexes,
etc. It’s used to execute queries and is updated by design whenever changes to an object
within the database is made. (Wenzel)

Meta data
Metadata characterizes data. It offers documentation about data so that it can be
understood and consumed more willingly by an organization. It answers who, what, when,
where, why and how questions for users data. (Mullins)

Constraints
Constraints are rules on data. What data is valid and what is invalid can be defined using
constraints. Its main importance is to maintain data integrity. The constraints that are
widely used in database are: NOT NULL, Primary key, Foreign key, Check, Default.
(Garcia-Molina, Ullman and Widom)

9
00168692-Bishes-Upadhyaya-DDD

Data Dictionary

10
00168692-Bishes-Upadhyaya-DDD

11
00168692-Bishes-Upadhyaya-DDD

12
00168692-Bishes-Upadhyaya-DDD

Task 2

Query to
create a
user named
seasalter

Illustration 3: Query to create a user named seasalter

Query to
create table
named
Courses

Illustration 4: Query to create table named Courses

13
00168692-Bishes-Upadhyaya-DDD

Query to
create table
named
modules
Mo

Illustration 5: Query to create table named modules

Query to create
table named
Courses_modules

Illustration 6: Query to create table named Courses_modules

14
00168692-Bishes-Upadhyaya-DDD

Query to create
table named
Equipment_type

Illustration 7: Query to create table named Equipment_type

Query to
create table
named
Equipment

Illustration 8: Query to create table named Equipment

15
00168692-Bishes-Upadhyaya-DDD

Query to
create table
named
Module_type

Illustration 9: Query to create table named Module_type

Query to
create table
named
Laboratories

Illustration 10: Query to create table named Laboratories

16
00168692-Bishes-Upadhyaya-DDD

Query to
create table
named
Laboratories
_modules

Illustration 11: Query to create table named Laboratories_modules

Query to create
table named
Modules_Module_
type

Illustration 12: Query to create table named Modules_Module_type

17
00168692-Bishes-Upadhyaya-DDD

Query to
create table
named
Staff_type

Illustration 13: Query to create table named Staff_type

Query to
create table
named Staff

Illustration 14: Query to create table named Staff

18
00168692-Bishes-Upadhyaya-DDD

Query to create
table named
Staff_Courses

Illustration 15: Query to create table named Staff_Courses

Query to
create table
named
Laboratories_
equipment

Illustration 16: Query to create table named Laboratories_equipment

19
00168692-Bishes-Upadhyaya-DDD

Inserting
values in table
Courses

Illustration 17: inserting values in table Courses

Inserting
data in
table
modules

Illustration 18: inserting data in table modules.

20
00168692-Bishes-Upadhyaya-DDD

inserting data in
table
Courses_modules

Illustration 19: inserting data in table Courses_modules

inserting data in
table
Equipment_type

Illustration 20: inserting data in table Equipment_type

21
00168692-Bishes-Upadhyaya-DDD

Inserting
data in
table
Equipment

Illustration 21: inserting data in table equipment

22
00168692-Bishes-Upadhyaya-DDD

Inserting data
in table
Laboratories

Illustration 22: inserting data in table Laboratories

Inserting
data in table
Laboratories
_modules

Illustration 23: inserting data in table Laboratories_modules

23
00168692-Bishes-Upadhyaya-DDD

Inserting data in
table
Module_type

Illustration 24: inserting data in table Module_type

Inserting data in
table
Modules_module
_type

Illustration 25: inserting data in table Modules_module_type

24
00168692-Bishes-Upadhyaya-DDD

Inserting data in
table staff_type

Illustration 26: inserting data in table staff_type

Inserting
data in
table
staff

Illustration 27: inserting data in table staff

25
00168692-Bishes-Upadhyaya-DDD

Inserting data in
table
Staff_courses

Illustration 28: inserting data in table staff_courses

26
00168692-Bishes-Upadhyaya-DDD

Inserting data
in table
laboratories_
equipment

Illustration 29: inserting data in table laboratories_equipment

27
00168692-Bishes-Upadhyaya-DDD

Queries to show
all the data of
table courses
and teacher

Illustration 30: Queries to show all the data of table courses and teacher

28
00168692-Bishes-Upadhyaya-DDD

Query to
show data for
modules with
its teachers

Illustration 31: Query to show data for modules with its teachers

29
00168692-Bishes-Upadhyaya-DDD

Query to list
all the data on
laboratories
table

Illustration 32: Query to list all the data on laboratories table

30
00168692-Bishes-Upadhyaya-DDD

Query to list
the
equipment
found in
laboratories

Illustration 33: Query to list the equipment found in laboratories

31
00168692-Bishes-Upadhyaya-DDD

Query to show
all the teachers
teaching
chemistry

Illustration 34: Query to show all the teachers teaching chemistry

Query changing
plant biology to
core unit

Illustration 35: Query changing plant biology to core unit

32
00168692-Bishes-Upadhyaya-DDD

Query to edit the


name of a teacher

Illustration 36: Query to edit the name of a teacher

33
00168692-Bishes-Upadhyaya-DDD

Query to shows all


equipment in the
chemistry laboratories

Illustration 37: Query to shows all equipment in the chemistry laboratories

34
00168692-Bishes-Upadhyaya-DDD

Query that
shows all the
teachers who
might be using
a microscope.

Illustration 38: Query that shows all the teachers who might be using a microscope.

35
00168692-Bishes-Upadhyaya-DDD

Queries showing details


of all courses and the
modules including the
teachers for them

Illustration 39: Queries showing details of all courses and the modules including the teachers for them

36
00168692-Bishes-Upadhyaya-DDD

Query showing
how many types
of item are
classified as
Chemistry
Experiment.

Illustration 40: Query showing how many types of item are classified as Chemistry Experiment.

37
00168692-Bishes-Upadhyaya-DDD

TASK 3
Question A:

Illustration 41: Modified ER Diagram

A new table maintenance has been added to this diagram because Seasalter College
wants to save information regarding the maintenance work on the college’s database
system. In the maintenance table maintenance_type_id is made to be the primary key
with maintence_type_name, cost_per_unit and staff_requirement included. There is a
many to many relationship between the laboratories and maintenance table therefore a
new linking table is formed named Laboratories_maintenance where the laboratory and
their equivalent maintenance type is stockpiled.

38
00168692-Bishes-Upadhyaya-DDD

Query to create
table
maintenance_type

Illustration 42: Query to create table maintenance_type

Query to
insert data
into table
maintenance_
type

Illustration 43: Query to insert data into table maintenance_type

Query to create
table
lab_maintenance

Illustration 44: Query to create table lab_maintenance

39
00168692-Bishes-Upadhyaya-DDD

Query to insert
data into
lab_maintenance

Illustration 45: Query to insert data into lab_maintenance

A view is a virtual table founded on the result-set of an SQL statement. A view covers
rows and columns and the fields in a view are fields from one or more real tables in the
database. It constantly shows the up to date data which makes it more explanatory.
(W3schools.com)

Grant view
to seasalter.

Illustration 46: Grant view to seasalter.

40
00168692-Bishes-Upadhyaya-DDD

Query to
create view for
cost
information

Illustration 47: Query to create view for cost information

41
00168692-Bishes-Upadhyaya-DDD

TASK 4

In this age of technological advancement data and computing environment have created
a paradigm shift in data management from centralized working to decentralized working.
Data is only going to get larger and larger. It is hard to store all the data in on server
sometimes. Centralized database is a single point of failure whereas a distributed
database will improve the availability, reliability and performance. Splitting the database
into fragments that is assigned to one site will definitely improve the read output.

If Seasalter College wants to expand and merge with other colleges they must definitely
use a distributed database system because of the following reasons:

A distributed database is the assembly of numerous interconnected databases, which are


spread physically across various locations that communicates through a network
Advantages of implementing DDBMS

 As the name suggest the database is distributed due to which the data becomes more
safe and reliable on different systems.
 Migration of data becomes easy.
 Distributed database supports both OLTP and OLAP work upon diversified systems
by providing synchronized data.
 Since most organization use variety of software with its specific database support.
Distributed DBMS will provide a uniform functionality for multiple application software
and
 In case of database failure the system will continue to function may be at a reduced
performance.
Disadvantages of implementing DDBMS

 A distributed database requests complex and expensive software to provide data


transparency across several sites.
 Updating data in several site pose complications of data integrity.
 Distributed database has more complex design. (tutorialspoint)

42
Distributed 00168692-Bishes-Upadhyaya-DDD
database system

Illustration 48: Distributed database system

TASK 5

According to the given scenario Seasalter Education College wants to implement a proper
normalized database to help them manage teaching and resources for various courses.
Various steps were carried out to standardize the database this process are given below:

Initially as per the request of Seasalter College a new database was made to carry out
the information about staff, module, course, laboratories, and equipment and later a new
table maintenance was added to store the information about maintenance of the
laboratories.

Normalization process (1NF – 3NF) was carried out to minimize the data redundancy as
much as possible. Partial and functional dependencies were removed in this process and
the database was standardized.

Following applications were used to reduce the design the database for Seasalter
College:

43
00168692-Bishes-Upadhyaya-DDD

Oracle 11g

Oracle 11g was the software used for the storing the database of Seasalter College. This
particular software was used because of its well renowned market presence, portability
options and performance.
Visual Paradigm

Visual paradigm was the tool used to design the database because of its extensive
database coverage and reverse engineering feature. After the completion of
normalization process entities were linked with each other and an Entity Relationship
diagram was finalized.
Microsoft Excel

Microsoft Excel was used for inserting query in the database. This was made easy
through its automation feature.
SQLTools

All the queries were written and executed through the SQL tool. This software was
preferred because of its well define standards that helps to make the database
standardized, its fast execution and versatility in writing the codes to execute the
information from the database.

44
00168692-Bishes-Upadhyaya-DDD

Conclusion
Finally a standard database proposed by Seasalter College is made. This database
manages the teaching and resources for various courses. All together 15 entities were
used to complete this process which was made easy after performing normalization on
the scenario which would help in making a standardized database by reducing
redundancy. The ER diagram was created using Visual paradigm and a data dictionary
was generated using reverse engineering function available on the software whilst the
query part was written in SQL tools and the database was stored in ORACLE 11g.

45
00168692-Bishes-Upadhyaya-DDD

References
Connolly, T. and Begg, C. (n.d.). Database systems. 4th ed. PEARSON, p.23.

Elmasri, R. and Navathe, S. (2014). Fundamentals of database systems. 6th ed. Boston: Addison wesley,
p.342.

Garcia-Molina, H., Ullman, J. and Widom, J. (n.d.). Database systems. PEARSON, p.315.

Available at: https://whatis.techtarget.com/definition/entity

[Accessed 30 Jun. 2018].

Available at: https://searchmicroservices.techtarget.com/definition/attribute

[Accessed 30 Jun. 2018].

Available at: https://www.essentialsql.com/what-is-a-data-dictionary/

[Accessed 30 Jun. 2018].

Available at: https://datatechnologytoday.wordpress.com/2010/09/07/on-the-importance-of-metadata/

[Accessed 30 Jun. 2018].

Available at: https://www.w3schools.com/sql/sql_view.asp

[Accessed 30 Jun. 2018].

Available at: https://www.tutorialspoint.com/distributed_dbms/distributed_dbms_databases.htm

[Accessed 30 Jun. 2018].

46
00168692-Bishes-Upadhyaya-DDD

Appendix

47
00168692-Bishes-Upadhyaya-DDD

48
00168692-Bishes-Upadhyaya-DDD

49
00168692-Bishes-Upadhyaya-DDD

50
00168692-Bishes-Upadhyaya-DDD

51
00168692-Bishes-Upadhyaya-DDD

52
00168692-Bishes-Upadhyaya-DDD

53
00168692-Bishes-Upadhyaya-DDD

54
00168692-Bishes-Upadhyaya-DDD

Query to create table Courses


CREATE TABLE Courses (
Course_Code varchar2(50),
Course_Name varchar2(50) NOT NULL UNIQUE);
ALTER TABLE Courses ADD constraint pk_course_code PRIMARY KEY (Course_Code);
Query to create table modules
CREATE TABLE modules (
Module_code varchar2(50),
Module_name varchar2(50) NOT NULL UNIQUE);
ALTER TABLE modules ADD CONSTRAINT pk_module_code PRIMARY KEY (Module_code);

55
00168692-Bishes-Upadhyaya-DDD

Query to create table Courses_modules


CREATE TABLE Courses_modules (
Course_Code varchar2(50),
Module_code varchar2(50));
ALTER TABLE Courses_modules ADD CONSTRAINT fk_courses_code_cm FOREIGN KEY
(Course_Code) REFERENCES Courses (Course_Code)ON DELETE CASCADE ;
ALTER TABLE Courses_modules ADD CONSTRAINT fk_module_code_cm FOREIGN KEY
(Module_Code) REFERENCES Modules (Module_Code)ON DELETE CASCADE ;
Query to create table Equipment_type
CREATE TABLE Equipment_type (
Equipment_type_id varchar2(50),
equipment_type varchar2(50) NOT NULL UNIQUE);
ALTER TABLE Equipment_type ADD CONSTRAINT pk_equipment_type_id PRIMARY KEY
(Equipment_type_id);
Query to create table Equipment
CREATE TABLE Equipment (
Equipment_ID varchar2(50),
Equipment_Name varchar2(50) NOT NULL,
Equipment_type_id varchar2(50));
ALTER TABLE Equipment ADD CONSTRAINT pk_equipment_id PRIMARY KEY
(Equipment_ID);
ALTER TABLE Equipment ADD CONSTRAINT fk_equipment_type_id_e FOREIGN KEY
(Equipment_type_id)REFERENCES equipment_type(Equipment_type_id)ON DELETE SET
NULL;
Query to create table Laboratories
CREATE TABLE Laboratories (
Laboratory_ID varchar2(50),
Laboratory_Name varchar2(50) NOT NULL UNIQUE);
ALTER TABLE laboratories ADD CONSTRAINT pk_laboratory_id PRIMARY KEY
(Laboratory_ID);

56
00168692-Bishes-Upadhyaya-DDD

Query to create table Laboratories_modules


CREATE TABLE Laboratories_modules (
Laboratory_ID varchar2(50),
Module_code varchar2(50));
ALTER TABLE Laboratories_modules ADD CONSTRAINT fk_laboratory_id_lm FOREIGN KEY
(Laboratory_id) REFERENCES Laboratories (Laboratory_ID)ON DELETE CASCADE ;
ALTER TABLE Laboratories_modules ADD CONSTRAINT fk_module_code_lm FOREIGN KEY
(Module_Code) REFERENCES Modules (Module_Code)ON DELETE CASCADE ;
Query to create table Module_type
CREATE TABLE Module_type (
Module_type_code varchar2(50),
module_type varchar2(50));
ALTER TABLE Module_type ADD CONSTRAINT pk_module_type_code PRIMARY KEY
(Module_type_code);
Query to create table Modules_Module_type
CREATE TABLE Modules_Module_type (
Module_code varchar2(50),
Module_type_code varchar2(50));
ALTER TABLE Modules_Module_type ADD CONSTRAINT fk_module_code_mmt FOREIGN
KEY (Module_code) REFERENCES Modules (Module_code)ON DELETE CASCADE ;
ALTER TABLE Modules_Module_type ADD CONSTRAINT fk_module_type_code_mmt
FOREIGN KEY (Module_type_code) REFERENCES Module_type (Module_type_code)ON
DELETE CASCADE ;

57
00168692-Bishes-Upadhyaya-DDD

Query to create table Staff


CREATE TABLE Staff (
Staff_id varchar2(50),
Staff_fname varchar2(50) NOT NULL,
Staff_middle_name varchar2(50),
Staff_lname varchar2(50),
Staff_Type_ID varchar2(50),
staff_phone_number varchar2(50) NOT NULL UNIQUE,
staff_email varchar2(50) NOT NULL UNIQUE);
ALTER TABLE staff ADD CONSTRAINT pk_staff_id PRIMARY KEY (Staff_id);
ALTER TABLE staff ADD CONSTRAINT fk_sraff_type_id_s FOREIGN KEY (Staff_Type_ID)
REFERENCES Staff_Type (Staff_Type_ID)ON DELETE SET NULL ;
Query to create table Staff_Courses
CREATE TABLE Staff_Courses (
Course_Code varchar2(50),
Staff_id varchar2(50));
ALTER TABLE Staff_Courses ADD CONSTRAINT fk_course_code_sc FOREIGN KEY
(course_code) REFERENCES Courses (Course_code)ON DELETE CASCADE ;
ALTER TABLE Staff_Courses ADD CONSTRAINT fk_staff_id_sc FOREIGN KEY (Staff_id)
REFERENCES Staff (Staff_id)ON DELETE CASCADE ;
Query to create table Staff_type
CREATE TABLE Staff_type (
Staff_Type_ID varchar2(50),
Staff_Type varchar2(50));
ALTER TABLE Staff_type ADD CONSTRAINT pk_staff_type_id PRIMARY KEY
(Staff_Type_ID);

58
00168692-Bishes-Upadhyaya-DDD

Query to create table laboratories_equipment


CREATE TABLE laboratories_equipment (
Laboratory_ID varchar2(50),
Equipment_ID varchar2(50),
Quantity number(5));
ALTER TABLE laboratories_equipment ADD CONSTRAINT fk_laboratory_id_le FOREIGN
KEY (Laboratory_id) REFERENCES laboratories (Laboratory_ID)ON DELETE CASCADE ;
ALTER TABLE laboratories_equipment ADD CONSTRAINT fk_equipment_id_le FOREIGN
KEY (Equipment_id) REFERENCES Equipment (Equipment_ID)ON DELETE CASCADE ;
Query to insert into table Courses
insert into Courses values('CHEM ','BTEC Level 3 Chemistry');
insert into Courses values('BIO ','BTEC Level 3 Biology');
insert into Courses values('ENG ','Certificate in Engineering');

Query to insert into table Modules


insert into Modules values('BC ','Biochemistry of Life');
insert into Modules values('EP ','Experimental Practice ');
insert into Modules values('CAD ','Computer Aided Design ');
insert into Modules values('PB ','Plant Biology');
insert into Modules values('ME1','Metals 1');
insert into Modules values('ME2','Metals 2');
insert into Modules values('NEU','Neurochemistry ');
insert into Modules values('IO','Inorganic Chemistry ');

Query to insert into table Courses_Modules

insert into Courses_Module values('BIO','BC');


insert into Courses_Module values('CHEM','BC');
insert into Courses_Module values('CHEM','EP');
insert into Courses_Module values('ENG','CAD');
insert into Courses_Module values('BIO','PB');
insert into Courses_Module values('CHEM','ME1');
insert into Courses_Module values('CHEM','ME2');
insert into Courses_Module values('CHEM','NEU');
insert into Courses_Module values('BIO','NEU');
insert into Courses_Module values('CHEM','IO');
insert into Courses_Module values('BIO','EP');

59
00168692-Bishes-Upadhyaya-DDD

Query to insert into table Equipment_type

insert into Equipment_type values('Sf1','Safety ');


insert into Equipment_type values('Ce1','Chemistry
Experiment');
insert into Equipment_type values('Be1','Biology Experiment ');
insert into Equipment_type values('Ee1','Engineering
Experiment ');

Query to insert into table Equipment

insert into Equipment values('SG','Safety googles','Sf1');


insert into Equipment values('BS','Beakers','Ce1');
insert into Equipment values('CS','Conical flasks','Ce1');
insert into Equipment values('BF','Boiling flasks','Ce1');
insert into Equipment values('TT','Test tubes','Ce1');
insert into Equipment values('MI','Microscopes','Be1');
insert into Equipment values('PD','Petri dishes','Be1');
insert into Equipment values('DY','Dyes','Be1');
insert into Equipment values('FO','Forceps','Be1');
insert into Equipment values('MM','Multi meter','Ee1');
insert into Equipment values('LCR','LCR Meter','Ee1');
insert into Equipment values('OSC','Oscilloscope','Ee1');
insert into Equipment values('SI ','Soldering Iron ','Ee1');
insert into Equipment values('PMT ','Precision Mechanical Tools
set','Ee1');

Query to insert into table laboratories

insert into Laboratory values('CHEM1 ','Chemistry One');


insert into Laboratory values('CHEM2 ','Chemistry Two');
insert into Laboratory values('BIO1 ','Biology One');
insert into Laboratory values('ENG1 ','Engineering One ');

60
00168692-Bishes-Upadhyaya-DDD

Query to insert into table laboratories_module

insert into laboratories_module values('BIO1 ','BC');


insert into laboratories_module values('CHEM1 ','BC');
insert into laboratories_module values('CHEM1 ','EP');
insert into laboratories_module values('ENG1','CAD');
insert into laboratories_module values('BIO1 ','PB');
insert into laboratories_module values('CHEM1 ','ME1');
insert into laboratories_module values('CHEM2','ME2');
insert into laboratories_module values('CHEM2','NEU');
insert into laboratories_module values('BIO1 ','NEU');
insert into laboratories_module values('CHEM2','IO');
insert into laboratories_module values('BIO1 ','EP');

Query to insert into table Module_type


insert into Module_type values('Co1','Core');
insert into Module_type values('El1','Elective');
insert into Module_type values('Op1','Optional');

Query to insert into table Modules_Module_type

insert into Modules_Module_type values('BC','Co1');


insert into Modules_Module_type values('BC','Co1');
insert into Modules_Module_type values('EP','El1');
insert into Modules_Module_type values('CAD','El1');
insert into Modules_Module_type values('PB','Op1');
insert into Modules_Module_type values('ME1','Op1');
insert into Modules_Module_type values('ME2','Op1');
insert into Modules_Module_type values('NEU','Op1');
insert into Modules_Module_type values('NEU','Op1');
insert into Modules_Module_type values('IO','Co1');
insert into Modules_Module_type values('EP','El1');

Query to insert into table Staff_type

insert into Staff_type values('Tch1','Teacher');


insert into Staff_type values('Tsp1','Technical Support');
insert into Staff_type values('Admin','Administration');
insert into Staff_type values('Oth1','Other');

61
00168692-Bishes-Upadhyaya-DDD

Query to insert into table Staff


insert into Staff values('S2399','Barry','','Harvey','Tch1','baryyharry@gmail.com','129 8745
6223','male');
insert into Staff values('S2400','Dorinda','','Harvey','Tch1','dorindaharvey@gmail.com','039 1353
2791','female');
insert into Staff values('S2300','Arabella','','Johnson','Tch1','Johnsona@gmail.com','378 5077
1362','female');
insert into Staff values('S2301','Mavis ','','Kingdom','Oth1','mk11@gmail.com','023 2435
1469','male');
insert into Staff values('S1101','Alison','','Walters','Tsp1','waltersali@gmail.com','132 0098
0343','female');
insert into Staff values('S1102','Dennis','','Brown','Tch1','dennisb@gmail.com','001 4620
3337','male');
insert into Staff values('S2111','Abidh','','Khan','Tch1','geordieabidh@gmail.com','572 9843
0002','male');
insert into Staff values('S8321','Kristian','','Cobaj','Admin','kristan3@gmail.com','981 8634
9807','female');
insert into Staff values('S9088','Kjulius','','Env','Admin','env@gmail.com','065 7861 1094','male');
Query to insert into table Staff_Courses

insert into Course_Staff values('CHEM ','S2399 ');


insert into Course_Staff values('BIO ','S2399 ');
insert into Course_Staff values('CHEM ','S2400 ');
insert into Course_Staff values('BIO ','S2300 ');
insert into Course_Staff values('CHEM ','S2301 ');
insert into Course_Staff values('BIO ','S2301 ');
insert into Course_Staff values('ENG','S2301 ');
insert into Course_Staff values('CHEM ','S1101 ');
insert into Course_Staff values('BIO ','S1101 ');
insert into Course_Staff values('ENG','S1101 ');
insert into Course_Staff values('ENG','S1102 ');
insert into Course_Staff values('CHEM ','S2111 ');
insert into Course_Staff values('BIO ','S2111 ');
insert into Course_Staff values('BIO ','S8321 ');
insert into Course_Staff values('ENG','S8321 ');
insert into Course_Staff values('CHEM ','S9088 ');

62
00168692-Bishes-Upadhyaya-DDD

Query to insert into table Laboratories_equipment

insert into Laboratories_equipment values('CHEM1','SG','21');


insert into Laboratories_equipment values('CHEM1','BS','50');
insert into Laboratories_equipment values('CHEM1','CS','30');
insert into Laboratories_equipment values('CHEM1','BF','30');
insert into Laboratories_equipment values('CHEM1','TT','50');
insert into Laboratories_equipment values('CHEM2','SG','21');
insert into Laboratories_equipment values('CHEM2','BS','50');
insert into Laboratories_equipment values('CHEM2','CS','30');
insert into Laboratories_equipment values('CHEM2','BF','30');
insert into Laboratories_equipment values('CHEM2','TT','50');
insert into Laboratories_equipment values('BIO1','SG','21');
insert into Laboratories_equipment values('BIO1','MI','10');
insert into Laboratories_equipment values('BIO1','PD','20');
insert into Laboratories_equipment values('BIO1','DY','23');
insert into Laboratories_equipment values('BIO1','FO','5');
insert into Laboratories_equipment values('BIO1','BF','20');
insert into Laboratories_equipment values('ENG1','MM','5');
insert into Laboratories_equipment values('ENG1','LCR','5');
insert into Laboratories_equipment values('ENG1','OSC','5');
insert into Laboratories_equipment values('ENG1','SI','24');
insert into Laboratories_equipment values('ENG1','PMT','24');
insert into Laboratories_equipment values('ENG1','SG','24');

63

Das könnte Ihnen auch gefallen