Database MGT
Database MGT
1 ACTIVITY 1........................................................................................................... 1
1.1.1. Identify the user and system requirements to design a database for the above
scenario. ............................................................................................................................ 1
1.1.2. Identify entities and attributes of the given scenario and design a relational
database system using conceptual design (ER Model) by including identifiers (primary
Key) of entities and cardinalities, participations of relationships. ...................................... 3
1.1.3. Convert the ER Model into logical database design using relational database
model including primary keys foreign keys and referential Integrities. It should contain
at least five interrelated tables. .......................................................................................... 5
1.2.1. Explain data normalization with examples. Check whether the provided
logical design in Task 1.1 is normalised. If not, normalize the database by removing the
anomalies. ........................................................................................................................... 8
1.2.2. Design set of simple interfaces to input and output for the above scenario
using Wireframe or any interface-designing tool. ............................................................ 16
1.2.3. Explain the validation mechanisms to validate data in the tables with
examples. .......................................................................................................................... 20
1.3.1. Check whether the given design (ERD and Logical design) is representing the
identified user and system requirements to access the effectiveness of the design. ...... 22
2 ACTIVITY 2..........................................................................................................23
2.1 Develop the database system with evidence of user interface, output and data
validations, and querying across multiple tables. ............................................................... 23
2.1.1. Develop a relational database system according to the ER diagram you have
created (Use SQL DDL statements). .................................................................................. 23
i
2.1.2. Provide evidence of the use of a suitable IDE to create a simple interface to
insert, update and delete data in the database ................................................................ 32
2.1.4. Display the details payment with the job details and the customer details
using Join queries .............................................................................................................. 38
Activity 2.2............................................................................................................................ 39
2.2.1 Explain the usage of DML with below mentioned queries by giving at least
one single example per each case from the developed database. ................................... 39
Activity 2.3............................................................................................................................ 41
2.3.1. Explain how security mechanisms have been used and the importance of
these mechanisms for the security of the database. Implement proper security
mechanisms (EX: -User groups, access permissions) in the developed database. ........... 41
2.4.1. Explain the usage of the below SQL statements with the examples from the
developed database .......................................................................................................... 46
3 ACTIVITY 3..........................................................................................................49
3.1.1 Provide a suitable test plan to test the system against user and system
requirements ..................................................................................................................... 49
3.1.2 Provide relevant test cases for the database you have implemented..................... 54
3.2.1. Explain how the selected test data in task 3.1 b) can be used improve the
effectiveness of testing. .................................................................................................... 65
3.3.1. Get independent feedback on your database solution from the non-technical
users and some developers (use surveys, questioners, interviews or any other feedback
collecting method) and make recommendations and suggestions for improvements in a
separate conclusion/recommendations section. .............................................................. 66
ii
4 ACTIVITY 4..........................................................................................................72
Prepare a simple users’ guide and a technical documentation for the support and
maintenance of the software. ............................................................................................. 72
Your technical documentation should include some of the UML diagrams (Use case
diagram Class diagram, etc.), flow charts for the important functionalities, context level
DFD and the Level 1 DFD...................................................................................................... 93
Suggest the future improvements that may be required to ensure the continued
effectiveness of the database system. .............................................................................. 113
iii
Figure 1-1 Entity Relationship Diagram (Visual Paradigm) ........................................................ 3
Figure 1-2 Entity Relationship Diagram ..................................................................................... 4
Figure 1-3 CustomerTypes Table ............................................................................................... 5
Figure 1-4 Depot Table ............................................................................................................... 5
Figure 1-5 ProductTypes Table .................................................................................................. 5
Figure 1-6 LoadTypes Table ....................................................................................................... 5
Figure 1-7 Employees Table ....................................................................................................... 6
Figure 1-8 TransportUnits Table ................................................................................................ 6
Figure 1-9 Customers Table ....................................................................................................... 6
Figure 1-10 Jobs Table................................................................................................................ 7
Figure 1-11 Loads Table ............................................................................................................. 7
Figure 2-1 Customer Frame - Input .......................................................................................... 16
Figure 2-2 Employee Frame - Input ......................................................................................... 17
Figure 2-3 Job Frame - Input .................................................................................................... 17
Figure 2-4 Transport Unit Frame - Input .................................................................................. 18
Figure 2-5 Load Frame - Input .................................................................................................. 18
Figure 2-6 Report Frame - Output ........................................................................................... 19
Figure 2-1 Microsoft SQL Server Management - Database ..................................................... 32
Figure 2-2 Customer Type Table .............................................................................................. 33
Figure 2-3 Customer Table ....................................................................................................... 33
Figure 2-4 Employee Table....................................................................................................... 33
Figure 2-5 Depot Table ............................................................................................................. 33
Figure 2-6 Load Type Table ...................................................................................................... 33
Figure 2-7 Load Table ............................................................................................................... 34
Figure 2-8 Product Type ........................................................................................................... 34
Figure 2-9 Transport Unit Table ............................................................................................... 34
Figure 2-10 Payment Table ...................................................................................................... 34
Figure 2-11 Jobs Table.............................................................................................................. 35
Figure 2-12 Job details and the Customer details using Join query ........................................ 38
Figure 2-13 Job details and the Customer details using Join query result .............................. 38
Figure 2-14 SQL Server Login ................................................................................................... 45
Figure 2-15 Database ............................................................................................................... 45
iv
Figure 3-1 Creating Customer Table ........................................................................................ 55
Figure 3-2 Creating Customer Table – Result .......................................................................... 55
Figure 3-3 Creating Customer Type Table................................................................................ 55
Figure 3-4 Creating Customer Type Table - Result .................................................................. 55
Figure 3-5 Creating Deports Table ........................................................................................... 56
Figure 3-6 Creating Deports Table - Result .............................................................................. 56
Figure 3-7 Creating Employees Table ...................................................................................... 56
Figure 3-8 Creating Employees Table - Result ......................................................................... 56
Figure 3-9 Creating Jobs Table ................................................................................................. 57
Figure 3-10 Creating Jobs Table - Result .................................................................................. 57
Figure 3-11 Creating Loads Table ............................................................................................. 57
Figure 3-12 Creating Loads Table - Result................................................................................ 57
Figure 3-13 Creating Load Types Table .................................................................................... 58
Figure 3-14 Creating Load Types Table - Result ....................................................................... 58
Figure 3-15 Creating Payments Table ...................................................................................... 58
Figure 3-16 Creating Payments Table - Result ......................................................................... 58
Figure 3-17 Creating Product Types Table ............................................................................... 58
Figure 3-18 - Creating Product Types Table - Result ................................................................ 58
Figure 3-19 Creating Transport Unit Table .............................................................................. 59
Figure 3-20 Creating Transport Unit Table - Result ................................................................. 59
Figure 3-21 Alter Table ............................................................................................................. 60
Figure 3-22 Adding Customer Type Records............................................................................ 60
Figure 3-23 Adding Product Type Records ............................................................................... 60
Figure 3-24 Adding Load Type Records .................................................................................... 61
Figure 3-25 Adding Payment Records ...................................................................................... 61
Figure 3-26 Customer Type Records ........................................................................................ 61
Figure 3-27 Customer Records ................................................................................................. 61
Figure 3-28 Deport Records ..................................................................................................... 62
Figure 3-29 Employee Records ................................................................................................ 62
Figure 3-30 Job Records ........................................................................................................... 62
Figure 3-31 Load Type Records ................................................................................................ 62
Figure 3-32 Load Records ......................................................................................................... 62
v
Figure 3-33 Payment Records .................................................................................................. 63
Figure 3-34 Product Type Records ........................................................................................... 63
Figure 3-35 Transport Records................................................................................................. 63
Figure 3-36 Query .................................................................................................................... 64
Figure 3-37 Result .................................................................................................................... 64
Figure 3-38 Feedback Analysis ................................................................................................. 70
Figure 4-1 Employee Management .......................................................................................... 10
Figure 4-2 Customer Management .......................................................................................... 12
Figure 4-3 Job Management .................................................................................................... 14
Figure 4-4 Transport Unit Management .................................................................................. 16
Figure 4-5 Load Management .................................................................................................. 18
Figure 4-6 Reporting ................................................................................................................ 20
Figure 4-7 Use Case Diagram ................................................................................................... 93
Figure 4-8 Class Diagram .......................................................................................................... 94
Figure 4-9 Data Flow Diagram - Context Level......................................................................... 95
Figure 4-10 Data Flow Diagram - Level 1 ................................................................................. 96
Figure 4-11 Activity Diagram - Insert Employee ...................................................................... 97
Figure 4-12 Activity Diagram - Update Employee .................................................................... 98
Figure 4-13 Activity Diagram - Delete Employee ..................................................................... 99
Figure 4-14 Activity Diagram - Insert Customer..................................................................... 100
Figure 4-15 Activity Diagram - Update Customer .................................................................. 101
Figure 4-16 Activity Diagram - Delete Customer ................................................................... 102
Figure 4-17 Activity Diagram - Insert Job ............................................................................... 103
Figure 4-18 Activity Diagram - Update Job ............................................................................ 104
Figure 4-19 Activity Diagram - Delete Job.............................................................................. 105
Figure 4-20 Activity Diagram - Insert Transport Unit ............................................................. 106
Figure 4-21 Activity Diagram - Update Transport Unit .......................................................... 107
Figure 4-22 Activity Diagram - Delete Transport Unit ........................................................... 108
Figure 4-23 Activity Diagram - Insert Load............................................................................. 109
Figure 4-24 Activity Diagram - Update Load .......................................................................... 110
Figure 4-25 Activity Diagram - Delete Load ........................................................................... 111
Figure 4-26 Reporting ............................................................................................................ 112
vi
Table 1-1 Non-normalized table ................................................................................................ 8
Table 1-2 Un normalized Employee Table ............................................................................... 10
Table 1-3 Table 1: Employee Table .......................................................................................... 11
Table 1-4 Table 2: Department table ....................................................................................... 11
Table 1-5 Table in first normal form ........................................................................................ 12
Table 1-6 Table 1: Employee table ........................................................................................... 12
Table 1-7 Table 2: Department table ....................................................................................... 12
Table 1-8 Employee table in first normal form ........................................................................ 13
Table 1-9 Table 1: Employee table ........................................................................................... 13
Table 1-10 Table 2: Salary Table .............................................................................................. 14
Table 3-1 Test Cases ................................................................................................................. 54
Table 3-2 Feedback Questionnaire .......................................................................................... 66
Table 3-3 Collected Data .......................................................................................................... 67
vii
1 Activity 1
1.1 Activity 1.1
1.1.1. Identify the user and system requirements to design a database for the
above scenario.
User requirements are things the user does with the system, or the activities that
users must be able to perform. User requirements are documented in a User
Requirements Document (URD) and are signed off by the user and used as the
primary input for creating system requirements (Parker, 2019).
1.1.1.2. System Requirements
System requirements are the building blocks developers use to build the system.
System requirements are classified as functional or supplemental requirements. A
functional requirement specifies a requirement that a user needs to perform their
work. Supplemental or non-functional requirements specify quality of service
requirements. The plan for implementing functional requirements is detailed in the
system design. The plan for implementing supplemental requirements is detailed in
the system architecture (Parker, 2019).
5
Figure 1-7 Employees Table
6
Figure 1-10 Jobs Table
7
1.2 Activity 1.2
1.2.1. Explain data normalization with examples. Check whether the provided
logical design in Task 1.1 is normalised. If not, normalize the database by
removing the anomalies.
When database objects are not normalized, it is difficult to update the database
without facing the database loss. Insertion, updating and deletion are very frequent
if data is not normalized. Normalization is part of successful database design and
normalizing can result slowness, inaccuracy and inefficiency (SQL WORLD, 2019).
8
The problems that can occur with non-normalized tables are known as anomalies.
The are 3 types of anomalies.
1. Insert Anomaly
2. Update Anomaly
3. Deletion Anomaly
1. Insertion Anomaly
If a new employee joins company and he or she is not allocated to a department.
Hence, we need to insert null value there which leads to insertion anomaly (SQL
WORLD, 2019).
2. Update Anomaly
If we want to update the city of employee who occurred twice or more in the
table, then we need to update city of all the employees. Hence data will become
inconsistent. Example is Employee named Amit is associated with two
departments and the values of the departments are not atomic (SQL WORLD,
2019).
3. Deletion Anomaly
If Employee_id 101 has only 1 department and we delete that temporary then
Entire student record will be deleted (SQL WORLD, 2019).
Database normalization forms are used to fix such anomalies. Normalization should
achieve following objectives.
1. Arrangement of data into logical groups.
2. Minimize the Duplicate data.
3. Organize the data in such way that when modification needed then there
should be only one place modification required.
4. User can access and manipulate data quickly and efficiently.
(SQL WORLD, 2019).
9
1.2.1.3. Database Normalization Forms
Example:
Un normalized Employee Table:
1 Amit OBIEE,ETL
2 Divya COGNOS
3 Rama Administrator
Employee table does not hold atomic values in Department column resulting un normalized.
In order to normalize, the multi valued attributes should be removed. It can be achieved by
converting to First Normal Form. Splitting Employee table into 2 tables Employee and
Department achieves the task.
10
Table 1: Employee Table
1 Amit
2 Divya
3 Rama
Department Employee No
OBIEE 1
ETL 1
COGNOS 2
Administrator 3
As a result of normalizing, column of each table is holding the atomic values and duplicates
also removed.
11
Example:
Employee_Department table is in first normal form:
In the above table representing details about the Departments that Employees are
represented. It has a composite primary key {Employee No, Department No}. Accordingly,
EmployeeName is dependent on EmployeeNo and v is dependent on DepartmentNo. This
results partial dependency. In order to normalize, partial dependency is removed by splitting
the above table into 2 different tables:
1 Amit 101
2 Divya 102
3 Rama 101
DepartmentNo Department
101 OBIEE
102 COGNOS
As a result, the database is converted to second normal form where each entity of table is
functionally dependent on primary key.
12
Third Normal Form
The database is in Third normal form if it satisfies following conditions:
In the above table representing details about the Employees are represented. The primary
key of it is Employee No. Accordingly, non-key attribute Salary is dependent on another non-
key attribute SalarySlipNo. This results transitive dependency. In order to normalize,
transitive dependency is removed by splitting the above table into 2 different tables:
1 Amit
2 Divya
3 Rama
13
Table 2: Salary Table
As a result, the database is converted to third normal form where each entity of table is
functionally dependent on primary key.
Deport(DeportID,DeportName)
ProductType(ProductTypeID,ProductType)
LoadType(LoadTypeID,LoadType)
CustomerType(CustomerTypeID,CustomerType)
Employee(EmployeeID,EmployeeName,EmployeeType,Address,
TelephoneNo,DeportID)
Customer(CustomerID,CustomerName,CustomerAddress,TelephoneNo,
MobileNo,Email,Fax,CustomerID)
Job(JobID,StartLocation,EndLocation,JobDate,CustomerID,
DeportID)
TransportUnit(TransportUnitID,LorryNo,ContainerNo,DeportID,
14
DriverEmpID,AssostantEmpID)
Payment(PaymentID,Payment,LoadTypeID,ProductTypeID)
Load(LoadID,JobID,LoadTypeID,TransportUnitID,ProductTypeID,
PaymentID)
▪ 1st Normal Form - The relational schema does not include any repeating groups or
multivalued attributes. Atomicity of attributes is preserved. Therefore, SMARTMovers
Database is in 1st Normal Form.
▪ 2nd Normal Form - The relational schema does not include any entity with composite
primary key. As a result, no impact from partial dependency takes place. Therefore,
SMARTMovers Database is automatically in 2nd Normal Form.
▪ 3rd Normal Form - The relational schema does not include entities having transitive
dependency which means there are no non key attributes that depend on another
non – key attribute. Therefore, SMARTMovers Database is in 3rd Normal Form.
15
1.2.2. Design set of simple interfaces to input and output for the above scenario using
Wireframe or any interface-designing tool.
16
Figure 1-13 Employee Frame - Input
17
Figure 1-15 Transport Unit Frame - Input
18
Figure 1-17 Report Frame - Output
19
1.2.3. Explain the validation mechanisms to validate data in the tables with
examples.
Checking the accuracy and quality of your data prior to importing and processing is
known as data validation. It is also a form of cleansing data. Data validation ensures
that the data is complete (no blank or null values), unique (contains distinct values
that are not duplicated), and the range of values is consistent with what you expect
(dzone.com, 2019). Data validation is also used as a part of ETL process (Extract,
Transform, and Load) where you move data from a source database to a target data
warehouse so that the data can be joined with other data for analysis. Data validation
helps ensure that the results are accurate when data analysis is performed
(dzone.com, 2019).
Presence Check
Presence check compels the user to enter data in the required field. It ensures the
user has at least entered something into the field, stopping them from leaving empty
(Teach Computer Science, 2019) (Computer Science GCSE GURU, 2019).
Example:
In an address book, you can make either the address or phone number optional, while
the name field is required. Leaving a mandatory field blank will trigger an error
message that will prevent you from proceeding to the next step.
Type Check
Type check ensures that the data entered is of an expected type, e.g. a number or date
(Teach Computer Science, 2019).
Example:
If a specific field is defined numeric then it will not allow to input any letters or other
non-numeric characters. Some data types can carry out an extra type check. Date
data type will ensure that a date inputted existed at some point, or could exist in the
future. It would not accept the dates such as 30/02/2018.
20
Range Check
Range check is a validation check which can be applied to numeric fields. This is done
to ensure that only numbers within a certain domain can be entered into a field. It
ensures that data are certainly within reasonable limits (Teach Computer Science,
2019).
Example:
If an attribute called ‘exammarks’ is defined in a table, it can allow values from 0 to
100 only. Range check ensures the values stay within the range.
Unique Identifier
It is essential that one record can be plainly recognised from another record.
Therefore, each record has one field that functions as a unique identifier for a record.
An easy validation check can be done to make sure that a value occurs only once in
this field (Teach Computer Science, 2019).
Example:
In ‘student’ table, records should be uniquely identified. An attribute such as
‘StudentID’, ‘RegNo’ or ‘IndexNumber’ can be selected as a unique identifier.
Format Check
This is used for a field that requires an entry in a specific format. Input masks can be
used for this (Teach Computer Science, 2019) (Computer Science GCSE GURU, 2019).
Example:
Date format, postal codes, and driver’s license numbers.
Length Check
A length check ensures that the number of characters meets expectations (Computer
Science GCSE GURU, 2019).
Example:
Defining to store only an eight-character password under password field.
Restricted Choice
There are times that fields in a database have a definite amount of data that can be
entered into them (Teach Computer Science, 2019).
Example:
The amount of days in a week are limited to Sunday, Monday, Tuesday, etc.
21
1.3 Activity 1.3
1.3.1. Check whether the given design (ERD and Logical design) is representing the
identified user and system requirements to access the effectiveness of the
design.
A database should be designed in a way which it can satisfy user and system
requirements.
According to the user requirements, user must be facilitated to enter, view, update and
delete records of the entities such as employees, customers, jobs, loads, transport units,
etc. Interfaces are designed to perform all above mentioned functions in a single
interface. Interfaces include insert button which helps to input data, edit button allows
to update existing data and delete button gives access to delete unwanted data.
The logical design includes a primary database to store data regarding transport
management process. Job table stores essential data so that it would be easy to identify
through the unique number given to a job it should be able to view the particular regional
depot and through the unique number give to a load it should be able to access details
of the load details of the customer and its starting location, its destination.
Separate forms have been created to identify load details and a transport unit, which has
also been created simply so that entire details of load can be derived from transport unit,
transports load.
This also gives asses to product details and also payment details can also be viewed by
this design. Additionally, it makes user to identify the specific order made by a specific
customer and displays the date also which makes job even easier.
The overall view is that it satisfies more than what user required for by additionally
providing order details.
22
2 Activity 2
2.1 Develop the database system with evidence of user interface, output and
data validations, and querying across multiple tables.
2.1.1. Develop a relational database system according to the ER diagram you have
created (Use SQL DDL statements).
USE [SmartMovers]
GO
/****** Object: Table [dbo].[Customers] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customers](
[CustomerId] [int] IDENTITY(1,1) NOT NULL,
[CustomerTypeId] [int] NOT NULL,
[CustomerName] [nvarchar](20) NOT NULL,
[Address] [nvarchar](50) NOT NULL,
[TelephoneNo] [nvarchar](10) NOT NULL,
[MobileNo] [nvarchar](10) NULL,
[Email] [nvarchar](50) NULL,
[Fax] [nvarchar](10) NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
(
[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[CustomerTypes] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomerTypes](
[CustomerTypeId] [int] IDENTITY(1,1) NOT NULL,
[CustomerType] [nvarchar](10) NOT NULL,
CONSTRAINT [PK_CustomerTypes] PRIMARY KEY CLUSTERED
(
[CustomerTypeId] ASC
23
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Deports] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Deports](
[DeportId] [int] IDENTITY(1,1) NOT NULL,
[DeportName] [nvarchar](20) NOT NULL,
CONSTRAINT [PK_Deports] PRIMARY KEY CLUSTERED
(
[DeportId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Employees] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employees](
[EmployeeId] [int] IDENTITY(1,1) NOT NULL,
[DeportId] [int] NOT NULL,
[EmployeeName] [nvarchar](20) NOT NULL,
[EmployementType] [nvarchar](10) NOT NULL,
[Address] [nvarchar](50) NOT NULL,
[TelephoneNo] [nvarchar](10) NOT NULL,
CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED
(
[EmployeeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Jobs] Script Date: 11/26/2019 1:51:59
AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Jobs](
24
[JobId] [int] IDENTITY(1,1) NOT NULL,
[CustomerId] [int] NOT NULL,
[DeportId] [int] NOT NULL,
[StartLocation] [nvarchar](20) NOT NULL,
[EndLocation] [nvarchar](20) NOT NULL,
[Date] [datetime] NOT NULL,
CONSTRAINT [PK_Jobs] PRIMARY KEY CLUSTERED
(
[JobId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Loads] Script Date: 11/26/2019 1:51:59
AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Loads](
[LoadId] [int] IDENTITY(1,1) NOT NULL,
[JobId] [int] NOT NULL,
[LoadTypeId] [int] NOT NULL,
[TransportUnitId] [int] NOT NULL,
[ProductTypeId] [int] NOT NULL,
[PaymentId] [int] NOT NULL,
CONSTRAINT [PK_Loads] PRIMARY KEY CLUSTERED
(
[LoadId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[LoadTypes] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LoadTypes](
[LoadTypeId] [int] IDENTITY(1,1) NOT NULL,
[LoadType] [nvarchar](10) NOT NULL,
CONSTRAINT [PK_LoadTypes] PRIMARY KEY CLUSTERED
(
[LoadTypeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
25
GO
/****** Object: Table [dbo].[Payments] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Payments](
[PaymentId] [int] IDENTITY(1,1) NOT NULL,
[CustomerTypeId] [int] NOT NULL,
[LoadTypeId] [int] NOT NULL,
[ProductTypeId] [int] NOT NULL,
[Payment] [numeric](10, 2) NOT NULL,
CONSTRAINT [PK_Payments] PRIMARY KEY CLUSTERED
(
[PaymentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ProductTypes] Script Date: 11/26/2019
1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProductTypes](
[ProductTypeId] [int] IDENTITY(1,1) NOT NULL,
[ProductType] [nvarchar](10) NOT NULL,
CONSTRAINT [PK_ProductTypes] PRIMARY KEY CLUSTERED
(
[ProductTypeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[TransportUnits] Script Date:
11/26/2019 1:51:59 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TransportUnits](
[TransportUnitId] [int] IDENTITY(1,1) NOT NULL,
[DeportId] [int] NOT NULL,
[LorryNo] [nvarchar](10) NOT NULL,
[DriverEmpId] [int] NOT NULL,
26
[AssistantEmpId] [int] NOT NULL,
[ContainerNo] [int] NOT NULL,
CONSTRAINT [PK_TransportUnits] PRIMARY KEY CLUSTERED
(
[TransportUnitId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Customers] WITH CHECK ADD CONSTRAINT
[FK_Customers_CustomerTypes] FOREIGN KEY([CustomerTypeId])
REFERENCES [dbo].[CustomerTypes] ([CustomerTypeId])
GO
ALTER TABLE [dbo].[Customers] CHECK CONSTRAINT
[FK_Customers_CustomerTypes]
GO
ALTER TABLE [dbo].[Employees] WITH CHECK ADD CONSTRAINT
[FK_Employees_Deports] FOREIGN KEY([DeportId])
REFERENCES [dbo].[Deports] ([DeportId])
GO
ALTER TABLE [dbo].[Employees] CHECK CONSTRAINT [FK_Employees_Deports]
GO
ALTER TABLE [dbo].[Jobs] WITH CHECK ADD CONSTRAINT
[FK_Jobs_Customers] FOREIGN KEY([CustomerId])
REFERENCES [dbo].[Customers] ([CustomerId])
GO
ALTER TABLE [dbo].[Jobs] CHECK CONSTRAINT [FK_Jobs_Customers]
GO
ALTER TABLE [dbo].[Jobs] WITH CHECK ADD CONSTRAINT [FK_Jobs_Deports]
FOREIGN KEY([DeportId])
REFERENCES [dbo].[Deports] ([DeportId])
GO
ALTER TABLE [dbo].[Jobs] CHECK CONSTRAINT [FK_Jobs_Deports]
GO
ALTER TABLE [dbo].[Loads] WITH CHECK ADD CONSTRAINT [FK_Loads_Jobs]
FOREIGN KEY([JobId])
REFERENCES [dbo].[Jobs] ([JobId])
GO
ALTER TABLE [dbo].[Loads] CHECK CONSTRAINT [FK_Loads_Jobs]
GO
ALTER TABLE [dbo].[Loads] WITH CHECK ADD CONSTRAINT
[FK_Loads_LoadTypes] FOREIGN KEY([LoadTypeId])
REFERENCES [dbo].[LoadTypes] ([LoadTypeId])
GO
ALTER TABLE [dbo].[Loads] CHECK CONSTRAINT [FK_Loads_LoadTypes]
GO
ALTER TABLE [dbo].[Loads] WITH CHECK ADD CONSTRAINT
[FK_Loads_Payments] FOREIGN KEY([PaymentId])
REFERENCES [dbo].[Payments] ([PaymentId])
27
GO
ALTER TABLE [dbo].[Loads] CHECK CONSTRAINT [FK_Loads_Payments]
GO
ALTER TABLE [dbo].[Loads] WITH CHECK ADD CONSTRAINT
[FK_Loads_ProductTypes] FOREIGN KEY([ProductTypeId])
REFERENCES [dbo].[ProductTypes] ([ProductTypeId])
GO
ALTER TABLE [dbo].[Loads] CHECK CONSTRAINT [FK_Loads_ProductTypes]
GO
ALTER TABLE [dbo].[Loads] WITH CHECK ADD CONSTRAINT
[FK_Loads_TransportUnits] FOREIGN KEY([TransportUnitId])
REFERENCES [dbo].[TransportUnits] ([TransportUnitId])
GO
ALTER TABLE [dbo].[Loads] CHECK CONSTRAINT [FK_Loads_TransportUnits]
GO
ALTER TABLE [dbo].[Payments] WITH CHECK ADD CONSTRAINT
[FK_Payments_CustomerTypes] FOREIGN KEY([CustomerTypeId])
REFERENCES [dbo].[CustomerTypes] ([CustomerTypeId])
GO
ALTER TABLE [dbo].[Payments] CHECK CONSTRAINT
[FK_Payments_CustomerTypes]
GO
ALTER TABLE [dbo].[Payments] WITH CHECK ADD CONSTRAINT
[FK_Payments_LoadTypes] FOREIGN KEY([LoadTypeId])
REFERENCES [dbo].[LoadTypes] ([LoadTypeId])
GO
ALTER TABLE [dbo].[Payments] CHECK CONSTRAINT [FK_Payments_LoadTypes]
GO
ALTER TABLE [dbo].[Payments] WITH CHECK ADD CONSTRAINT
[FK_Payments_ProductTypes] FOREIGN KEY([ProductTypeId])
REFERENCES [dbo].[ProductTypes] ([ProductTypeId])
GO
ALTER TABLE [dbo].[Payments] CHECK CONSTRAINT
[FK_Payments_ProductTypes]
GO
ALTER TABLE [dbo].[TransportUnits] WITH CHECK ADD CONSTRAINT
[FK_TransportUnits_Deports] FOREIGN KEY([DeportId])
REFERENCES [dbo].[Deports] ([DeportId])
GO
ALTER TABLE [dbo].[TransportUnits] CHECK CONSTRAINT
[FK_TransportUnits_Deports]
GO
ALTER TABLE [dbo].[TransportUnits] WITH CHECK ADD CONSTRAINT
[FK_TransportUnits_Employees] FOREIGN KEY([AssistantEmpId])
REFERENCES [dbo].[Employees] ([EmployeeId])
GO
ALTER TABLE [dbo].[TransportUnits] CHECK CONSTRAINT
[FK_TransportUnits_Employees]
GO
28
ALTER TABLE [dbo].[TransportUnits] WITH CHECK ADD CONSTRAINT
[FK_TransportUnits_Employees1] FOREIGN KEY([DriverEmpId])
REFERENCES [dbo].[Employees] ([EmployeeId])
GO
ALTER TABLE [dbo].[TransportUnits] CHECK CONSTRAINT
[FK_TransportUnits_Employees1]
GO
USE [SmartMovers]
GO
SET IDENTITY_INSERT [dbo].[CustomerTypes] ON
GO
INSERT [dbo].[CustomerTypes] ([CustomerTypeId], [CustomerType])
VALUES (1, N'Category1')
GO
INSERT [dbo].[CustomerTypes] ([CustomerTypeId], [CustomerType])
VALUES (2, N'Category2')
GO
INSERT [dbo].[CustomerTypes] ([CustomerTypeId], [CustomerType])
VALUES (3, N'Category3')
GO
SET IDENTITY_INSERT [dbo].[CustomerTypes] OFF
GO
SET IDENTITY_INSERT [dbo].[ProductTypes] ON
GO
INSERT [dbo].[ProductTypes] ([ProductTypeId], [ProductType]) VALUES
(1, N'No Risk')
GO
INSERT [dbo].[ProductTypes] ([ProductTypeId], [ProductType]) VALUES
(2, N'High Risk')
GO
SET IDENTITY_INSERT [dbo].[ProductTypes] OFF
GO
SET IDENTITY_INSERT [dbo].[LoadTypes] ON
GO
INSERT [dbo].[LoadTypes] ([LoadTypeId], [LoadType]) VALUES (1,
N'Small')
GO
INSERT [dbo].[LoadTypes] ([LoadTypeId], [LoadType]) VALUES (2,
N'Medium')
GO
INSERT [dbo].[LoadTypes] ([LoadTypeId], [LoadType]) VALUES (3,
N'Large')
GO
SET IDENTITY_INSERT [dbo].[LoadTypes] OFF
GO
29
SET IDENTITY_INSERT [dbo].[Payments] ON
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (1, 1, 1, 1, CAST(1000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (2, 1, 1, 2, CAST(10000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (3, 1, 2, 1, CAST(2000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (4, 1, 2, 2, CAST(20000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (5, 1, 3, 1, CAST(3000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (6, 1, 3, 2, CAST(30000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (7, 2, 1, 1, CAST(4000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (8, 2, 1, 2, CAST(40000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (9, 2, 2, 1, CAST(5000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (10, 2, 2, 2, CAST(50000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (11, 2, 3, 1, CAST(6000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (12, 2, 3, 2, CAST(60000.00 AS
Numeric(10, 2)))
GO
30
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (13, 3, 1, 1, CAST(7000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (14, 3, 1, 2, CAST(70000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (15, 3, 2, 1, CAST(8000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (16, 3, 2, 2, CAST(80000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (17, 3, 3, 1, CAST(9000.00 AS
Numeric(10, 2)))
GO
INSERT [dbo].[Payments] ([PaymentId], [CustomerTypeId], [LoadTypeId],
[ProductTypeId], [Payment]) VALUES (18, 3, 3, 2, CAST(90000.00 AS
Numeric(10, 2)))
GO
SET IDENTITY_INSERT [dbo].[Payments] OFF
GO
SET IDENTITY_INSERT [dbo].[Deports] ON
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (1,
N'Regional Deport 1')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (2,
N'Regional Deport 2')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (3,
N'Regional Deport 3')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (4,
N'Regional Deport 4')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (5,
N'Regional Deport 5')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (6,
N'Regional Deport 6')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (7,
N'Regional Deport 7')
GO
31
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (8,
N'Regional Deport 8')
GO
INSERT [dbo].[Deports] ([DeportId], [DeportName]) VALUES (9,
N'Regional Deport 9')
GO
SET IDENTITY_INSERT [dbo].[Deports] OFF
GO
2.1.2. Provide evidence of the use of a suitable IDE to create a simple interface to
insert, update and delete data in the database
32
Figure 2-2 Customer Type Table
33
Figure 2-7 Load Table
34
Figure 2-11 Jobs Table
Customers table ensures presence check with the use of NOT_NULL in attribute
definition.
35
2.1.3.2. Type Check
Jobs table ensures type check by using relevant data types for the attributes.
Payments table ensures range check by mentioning the range of applicable values to
the attribute.
36
2.1.3.4. Unique Identifier
Jobs table ensures format check with the use of data types such as datetime which
uses a specific format.
37
2.1.3.6. Length Check
Customers table ensures length check by defining lengths to the attributes with data
types such as nvarchar.
2.1.4. Display the details payment with the job details and the customer details
using Join queries
Figure 2-12 Job details and the Customer details using Join query
This would display the table along with the payment details with customer id and job
id.
Figure 2-13 Job details and the Customer details using Join query result
38
Activity 2.2
2.2.1 Explain the usage of DML with below mentioned queries by giving at least
one single example per each case from the developed database.
SELECT L.JobId,L.LoadId,LT.LoadType,PT.ProductType,(SELECT
EmployeeName FROM [dbo].[Employees] WHERE EmployeeId= T.DriverEmpId)
AS Driver,(SELECT EmployeeName FROM [dbo].[Employees] WHERE
EmployeeId= T.AssistantEmpId) AS
Assistant,T.LorryNo,T.ContainerNo,P.Payment FROM [dbo].[Loads] L
INNER JOIN [dbo].[LoadTypes] LT ON LT.LoadTypeId=L.LoadTypeId INNER
JOIN [dbo].[ProductTypes] PT ON PT.ProductTypeId=L.ProductTypeId
INNER JOIN [dbo].[Payments] P ON P.PaymentId=L.PaymentId INNER JOIN
[dbo].[TransportUnits] T ON T.TransportUnitId=L.TransportUnitId AND
L.Jobid="+cusId;
2.2.1.3 Update
The UPDATE statement is used to modify the existing records in a table. The WHERE
clause specifies which record(s) that should be updated. If the WHERE clause is
omitted, all records in the table will be updated (W3schools.com, 2019).
39
2.2.1.4 Delete
The DELETE statement is used to delete existing records in a table. The WHERE clause
specifies which record(s) that should be updated. If the WHERE clause is omitted, all
records in the table will be deleted (W3schools.com, 2019).
40
Activity 2.3
2.3.1. Explain how security mechanisms have been used and the importance of
these mechanisms for the security of the database. Implement proper
security mechanisms (EX: -User groups, access permissions) in the developed
database.
When a company collects any data about customers, suppliers, or the wider
community, it is stored on a database. This data may be sensitive and private, and
can be subject to strict privacy agreements.
Example: the customers may provide you with an email address, postal address, and
phone number when they purchase something from you.
However, if this data is accessed without authority, sold to third parties, or otherwise
misused, you could be subject to strict legal action from the people whose privacy
has been compromised (Systems, 2019).
Database security is any form of security used to protect databases and the
information they contain from compromise. Examples of how stored data can be
protected include:
▪ Software – software is used to ensure that people can’t gain access to the
database through viruses, hacking, or any similar process.
▪ Physical controls – an example of a physical component of database security
could be the constant monitoring of the database by company personnel to
allow them to identify any potential weaknesses and/or compromises.
▪ Administrative controls – this refers to things like the use of passwords,
restricting the access of certain people to certain parts of the database, or
blocking the access of some company personnel altogether.
(Systems, 2019).
41
2.3.1.2. Why is database security important?
Database security is more than just important: it is essential to any company with any
online component. Sufficient database security prevents data bring lost or
compromised, which may have serious ramifications for the company both in terms
of finances and reputation (Systems, 2019). Database security helps:
▪ Company’s block attacks, including ransomware and breached firewalls, which
in turn keeps sensitive information safe.
▪ Prevent malware or viral infections which can corrupt data, bring down a
network, and spread to all end point devices.
▪ Ensure that physical damage to the server doesn’t result in the loss of data.
▪ Prevent data loss through corruption of files or programming errors.
(Systems, 2019).
As you will see, database security places an obligation on you and your business to
keep sensitive data stored correctly, and used appropriately. Complying with
regulations and the applicable law not only reduces the risk of information being
mishandled, but it protects you from both costly legal ramifications and lost customer
confidence. Investment in Database security will ensure you have done your due
diligence in terms of data protection (Systems, 2019).
The risks involved with databases vary from organization to organization, depending
on the type of information and the amount of importance it holds for the company
itself. While credit card and social security numbers are certainly dangerous, so are
company plans, finances, sensitive employee info (Systems, 2019).
Therefore, it’s crucial to maintain solid security practices and defences to combat
attacks on your databases. Few database attacks are as follows.
i. SQL Injections
SQL injections are one of the biggest threats to databases, much like web apps.
They can be launched on either the database or the web app that acts as a front-
end to the database, yet due to the prevalence of SQL injection flaws in web
42
apps and how easy they are to exploit, they’re more common than attacking
the database. Many organizations have large databases hackers would like to
get their hands on – staying secure is essential to prevent embarrassing and
costly incidents.
Buffer Overflow vulnerabilities are the most common security problem for
databases, occur when a program tries to copy too much data in a memory
buffer, causing the buffer to ‘overflow’ and overwriting the data currently in
memory. Buffer overflow vulnerabilities pose an especially dangerous threat to
databases holding particularly sensitive info, as it could allow an attacker
exploiting the vulnerability to set unknown values to known values or mess with
the program’s logic.
DoS, attacks happen most through buffer overflows, data corruption or other
kinds of consumption of the server’s resources. DoS attacks crash the server,
making the database unreachable for however long the attack can be sustained.
v. Weak Authentication
43
2.3.1.4. Database Security Best Practices: Protecting Your Confidentiality, Integrity
& Availability
▪ Ensure your database administrators both understand the business value and
importance of ensuring your databases are secured and extending them the
resources to do so properly.
▪ Protect against SQL injections by using parameterized queries to keep malicious
queries out of your database.
▪ Static Code Analysis is an essential tool for organizations developing applications
as portals to databases to slash SQL injection, buffer overflow, and mis-
configuration issues.
▪ Maintain CIA by keeping your databases up to date, removing any unknown
components, and enforcing least privilege parameters to ensure the
confidentiality, integrity and availability of your databases.
▪ To maintain availability, employ an Uninterruptible Power Supply, or UPS, to
ensure any forced shutdown doesn’t cause data loss.
▪ Keep features and services only to what is essential for the company to work
smoothly with the databases – the more extras you have, the more you need to
stay up-to-date with, the more holes hackers have a chance to poke through.
▪ Data masking, or allowing users to access certain info without being able to view
it – credit card processing or during database testing and development, for
example, helps maintain the confidentiality of the database.
(Checkmarx, 2019)
44
2.3.1.5. Security Mechanisms in the Implementation
Setting login and password for sql authentician once you enter the username and
login it displays the server and database.
45
2.4 Activity 2.4
2.4.1. Explain the usage of the below SQL statements with the examples from the
developed database
2.4.1.1. Group by
The GROUP BY statement groups rows that have the same values into summary rows.
It is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the
result-set by one or more columns (W3schools.com, 2019).
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
2.4.1.2. Order by
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
It sorts the records in ascending order by default. To sort the records in descending
order, use the DESC keyword (W3schools.com, 2019).
SELECT[EmployeeId],[DeportId],[EmployeeName],[EmployementType],
[Address],[TelephoneNo] FROM [dbo].[Employees] ORDER BY [DeportId]";
46
2.4.1.3. Having
The HAVING clause was added to SQL because the WHERE keyword could not be
used with aggregate functions (W3schools.com, 2019).
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
2.4.1.4. Between
The BETWEEN operator selects values within a given range. The values can be
numbers, text, or dates. The BETWEEN operator is inclusive: begin and end values are
included (W3schools.com, 2019).
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
47
2.4.1.5. Where
The WHERE clause is used to filter records. The WHERE clause is used to extract only
those records that fulfill a specified condition (W3schools.com, 2019).
Operators such as = Equal, > Greater than, < Less than, >= Greater than or equal, <=
Less than or equal, <>, != Not equal, BETWEEN - Between a certain range, LIKE - Search
for a pattern, IN - To specify multiple possible values for a column (W3schools.com,
2019).
48
3 Activity 3
3.1 Activity 3.1
3.1.1 Provide a suitable test plan to test the system against user and system
requirements
For
SMARTMOVERS DATABASE
49
Table of Contents
1 INTRODUCTION ......................................................................................................................... 51
2 PROJECT OVERVIEW ................................................................................................................ 51
3 PROJECT AUDIENCE.................................................................................................................. 52
4 TEST OBJECTIVE......................................................................................................................... 52
5 TEST ASSUMPTIONS................................................................................................................. 52
6 TEST PRINCIPLES ....................................................................................................................... 53
50
1. Introduction
This test plan describes the testing approach and overall framework that will drive in
testing of the system “SMART MOVERS”.
The purpose of this test plan is to:
1. Outline the overall test approach
2. Identify the activities required in our database test
3. Define deliverables
2. Project Overview
The system “SMART MOVERS” is capable of handling the details regarding customers,
items which they are transporting and handling operations including insert, view, delete
and update. The functionality of this module spans through the entire system, making
information available anywhere, anytime.
3. Test Scope
We have identified that the following items are critical to the success of the
SMARTMOVERS DATABASE.
1. The accuracy of the data’s entered in to the database
2. Its speed (in order to provide quick checkouts)
3. Less number of errors and system crash
51
Speed of the data
1. Once the data is entered it should display the results immediately without causing
any delay.
2. It should also accept any amendments easily and display them quickly.
4. Test Responsibilities
Test lead: Responsible for creating this test plan, work assignment and review, review of
test queries, review and compile test results and review bug reports.
Tester: Responsible for reviewing requirements, developing and testing test queries,
execute tests, prepare individual test results, submit bug reports and re-test.
5. Audience
▪ Project team members perform tasks specified in this document, and provide input and
recommendations on this document.
▪ Project Manager Plans for the testing activities in the overall project schedule, reviews
the document, tracks the performance of the test according to the task herein
specified, approves the document and is accountable for the results.
6. Test Objective
The objective of the test is to verify that the functionality of SMART MOVERS works
according to the specifications.
7. Test Assumptions
▪ Exploratory Testing would be carried out once the build is ready for testing
▪ The project will provide test planning, test design and test execution support
▪ Test team will manage the testing effort with close coordination with Project
Pm/Business Analyst
▪ Project team has the knowledge and experience necessary, or has received adequate
training in the system, the project and the testing processes.
52
8. Test Principles
▪ Testing will be focused on meeting the business objectives, cost efficiency, and quality.
▪ There will be common, consistent procedures for all teams supporting testing activities.
▪ Testing processes will be well defined, yet flexible, with the ability to change as needed.
▪ Testing activities will build upon previous stages to avoid redundancy or duplication of
effort.
9. Test Deliverables
The testers will produce the following deliverables:
1. Test queries
2. Test results (describing the tests run, run time and pass/ fail for each test)
3. Bug reports
53
3.1.2 Provide relevant test cases for the database you have implemented
54
3.1.2.2 Actual Results when Testing the Database
55
Figure 3-5 Creating Deports Table
56
Figure 3-9 Creating Jobs Table
57
Figure 3-13 Creating Load Types Table
58
Figure 3-19 Creating Transport Unit Table
59
Figure 3-21 Alter Table
According to the results above, all the tables are created without any errors.
As the next step the user should be able insert data without any problem.
60
Figure 3-24 Adding Load Type Records
61
Figure 3-28 Deport Records
62
Figure 3-33 Payment Records
63
3.1.2.2.2 Bug reports
In the above scenario as we see the insert query has an invalid data type instead of entering
a product name a numbers has been entered even if it was mentioned as varchar above but
the system didn’t show any errors and accepted the entry and displayed the number in the
product name column, which is a unhealthy movement.
64
3.2 Activity 3.2
3.2.1. Explain how the selected test data in task 3.1 b) can be used improve the
effectiveness of testing.
Test data is the information used as the input of a test case and the static or
transactional information. It is a fact that data preparing is the time-consuming and
hardest phase. Test data management is a process of organizing this data to ensure
that it is input correctly and the results are also reported properly. This process defines
to ensure the accuracy, completeness, and integrity of test data. It also plays a critical
role in ensuring that sensitive information is processed securely during the testing
phase. In other words, test data management is one of the most important parts of any
product’s success. As the testing process can generate a huge volume of data, using
test data management can reduce costly and time-consuming errors and also help
testers clearly understand their jobs. Outcome can be estimated that one wishes to
achieve through test automation and accordingly the actions can be planned.
Reviewing helps to eliminate the old and outdated tests that are irrelevant to the
current test requirements which ultimately helps in reducing the costs and efforts. For
successful automation quality test data is of prime importance. Quality data set refers
to categorization of data sets into valid data, invalid data. Identifying the test process
will bring the best methods to perform the task effectively and efficiently
65
3.3 Activity 3.3
3.3.1. Get independent feedback on your database solution from the non-technical users and some developers (use
surveys, questioners, interviews or any other feedback collecting method) and make recommendations and
suggestions for improvements in a separate conclusion/recommendations section.
4 The software functions well on the computer and is free from bugs.
8 Both novice and expert users can use it without any difficulty
The system is easy to use and requires fewest steps to accomplish the desired
9
tasks.
66
3.3.1.2. Feedback Analysis
▪ 15 users have used the application and participated for the feedback collection task.
▪ Data collected at the evaluation and the analysis is included below.
Strong Strongly
Criteria Agree Moderate Disagree Total
Agree Disagree
4 The software functions well on the computer and is free from bugs. 15 0 0 0 0 15
8 Both novice and expert users can use it without any difficulty 12 2 1 0 0 15
The system is easy to use and requires fewest steps to accomplish the
9 10 4 1 0 0 15
desired tasks.
67
THE DIRECTIONS ARE CLEAR AND EASY TO USER INSTRUCTIONS HELPED ME TO
FOLLOW. UNDERSTAND THE SYSTEM.
Strong Agree Agree Moderate Disagree Strongly Disagree Strong Agree Agree Moderate Disagree Strongly Disagree
0% 0%
13%
33%
54%
33%
67%
SEARCHING FOR ITEMS IS SIMPLE AND THE SOFTWARE FUNCTIONS WELL ON THE
COMPLEX SEARCHES CAN BE DONE. COMPUTER AND IS FREE FROM BUGS.
Strong Agree Agree Moderate Disagree Strongly Disagree Strong Agree Agree Moderate Disagree Strongly Disagree
0% 0%
13%
87%
100%
68
INCLUDED IMAGES AND MULTIMEDIA THE USER LEVEL IS APPROPRIATE.
CONTENT ARE MEANINGFUL. Strong Agree Agree Moderate Disagree Strongly Disagree
Strong Agree Agree Moderate Disagree Strongly Disagree
0%
0%
27%
6%
67%
100%
IT IS EASY TO LEARN AND REMEMBER BOTH NOVICE AND EXPERT USERS CAN USE
Strong Agree Agree Moderate Disagree Strongly Disagree
IT WITHOUT ANY DIFFICULTY
Strong Agree Agree Moderate Disagree Strongly Disagree
0%
20%
7%0%
13%
80% 80%
69
THE SYSTEM IS EASY TO USE AND REQUIRES
FEWEST STEPS TO ACCOMPLISH THE DESIRED
TASKS.
Strong Agree Agree Moderate Disagree Strongly Disagree
6%0%
27%
67%
70
3.3.1.3. Recommendations
▪ The system must be updated with more easy steps in navigation.
▪ Include more multimedia and infographics to make system more graphical user
friendly.
▪ A help and instruction document should be integrated with the database system.
▪ Further, additional advanced features should be added to SMARTMovers
database system to continue their operations productive and effectively.
71
4 Activity 4
72
User
MANUAL
Page #
▪ System category:
General support system: provides general support for a variety of users and
applications
▪ Operational status:
▪ Partially Operational
▪ Under development
1.2.1. Information
The points of organizational contact (POCs) that may be needed by the document user
for informational and troubleshooting purposes.
1. IT Support and Networking Division
2. Administration Division
3. Transport Management Division
The list of organizations that require coordination between the project and its specific
support function (e.g., installation coordination, security, etc.)
1. IT Support and Networking Division
Help desk information including responsible personnel phone numbers for emergency
assistance.
Assistant Manager –
Mr. Tissa Vithana 0776032586 [email protected]
IT Support
1. Employee handling
2. Customer handling
3. Job handling
4. Transport unit handling
5. Load handling and
6. Mandatory reporting
The Primary user is the authorized user to add and modify data in the system.
This section provides a general walkthrough of the system from initiation through exit.
The logical arrangement of the information shall enable the functional personnel to
understand the sequence and flow of the system. Use screen prints to depict
examples of text under each heading.
3.2. Logging On
This section describes in general terms the system menu first encountered by the user,
as well as the navigation paths to functions noted on the screen. Each system function
should be under a separate section header, 3.2.1 - 3.2.x.
Employee interface allows to insert new employee, view all existing employees,
update employee details, delete employee records.
Customer interface allows to insert new customer, view all existing customers, update
customer details, delete customers records.
Job interface allows to insert new job, view all existing job, update job details, delete
job records.
Add Load
Transport Unit interface allows to insert new Transport Unit, view all existing
Transport Unit, update Transport Unit details, delete Transport Unit records.
Load interface allows to insert new load, view all existing loads, update load details,
delete load records.
Report interface allows to insert new load, view all existing loads, update load details,
delete load records.
Generate Report
Click on Exit.
94
4.2.3. Data Flow Diagram
95
Figure 4-10 Data Flow Diagram - Level 1
96
4.2.4. Activity Diagrams
97
Figure 4-12 Activity Diagram - Update Employee
98
Figure 4-13 Activity Diagram - Delete Employee
99
Figure 4-14 Activity Diagram - Insert Customer
100
Figure 4-15 Activity Diagram - Update Customer
101
Figure 4-16 Activity Diagram - Delete Customer
102
Figure 4-17 Activity Diagram - Insert Job
103
Figure 4-18 Activity Diagram - Update Job
104
Figure 4-19 Activity Diagram - Delete Job
105
Figure 4-20 Activity Diagram - Insert Transport Unit
106
Figure 4-21 Activity Diagram - Update Transport Unit
107
Figure 4-22 Activity Diagram - Delete Transport Unit
108
Figure 4-23 Activity Diagram - Insert Load
109
Figure 4-24 Activity Diagram - Update Load
110
Figure 4-25 Activity Diagram - Delete Load
111
Figure 4-26 Reporting
112
4.3 Activity 4.3
113
5 References
Checkmarx. (2019). The Importance of Database Security and Integrity. [online] Available at:
https://www.checkmarx.com/2016/06/24/20160624the-importance-of-database-
security-and-integrity/ [Accessed 22 Nov. 2019].
Computer Science GCSE GURU. (2019). Database Validation - Computer Science GCSE GURU.
[online] Available at: https://www.computerscience.gcse.guru/theory/database-
validation [Accessed 21 Nov. 2019].
GeeksforGeeks. (2019). SQL | DDL, DQL, DML, DCL and TCL Commands - GeeksforGeeks.
[online] Available at: https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-
commands/ [Accessed 22 Nov. 2019].
Parker, J. (2019). Business, User, and System Requirements - Enfocus Solutions Inc. [online]
Enfocus Solutions Inc. Available at: https://enfocussolutions.com/business-user-and-
system-requirements/ [Accessed 13 Nov. 2019].
SQL WORLD. (2019). Database Normalization Examples | Normalization in Database with
Examples | Database Normalization with Real Life Examples | Designing Normalized
Database. [online] Available at: https://www.complexsql.com/database-
normalization/ [Accessed 14 Nov. 2019].
Studytonight.com. (2019). SELECT Query and its Use in SQL | Studytonight. [online] Available
at: https://www.studytonight.com/dbms/select-query.php [Accessed 22 Nov. 2019].
Systems, G. (2019). What Is Database Security And Why Is It Important?. [online] GA Systems.
Available at: https://www.gasystems.com.au/database-security-important/
[Accessed 22 Nov. 2019].
Teach Computer Science. (2019). Database Validation | Data Validation & Verification.
[online] Available at: https://teachcomputerscience.com/database-validation/
[Accessed 21 Nov. 2019].
W3schools.com. (2019). SQL BETWEEN Operator. [online] Available at:
https://www.w3schools.com/sql/sql_between.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL DELETE Statement. [online] Available at:
https://www.w3schools.com/sql/sql_delete.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL GROUP BY Statement. [online] Available at:
https://www.w3schools.com/sql/sql_groupby.asp [Accessed 22 Nov. 2019].
114
W3schools.com. (2019). SQL HAVING Clause. [online] Available at:
https://www.w3schools.com/sql/sql_having.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL ORDER BY Keyword. [online] Available at:
https://www.w3schools.com/sql/sql_orderby.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL SELECT Statement. [online] Available at:
https://www.w3schools.com/sql/sql_select.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL UPDATE Statement. [online] Available at:
https://www.w3schools.com/sql/sql_update.asp [Accessed 22 Nov. 2019].
W3schools.com. (2019). SQL WHERE Clause. [online] Available at:
https://www.w3schools.com/sql/sql_where.asp [Accessed 22 Nov. 2019].
115