1. 1 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Assignment Front Cover Sheet
PART 1 – To be completedby the student
StudentName IoanTuns
StudentIDNumber LON291101243
Module Name
(e.g.:BusinessEnvironment)
Data AnalysisandDesign
Course (e.g.HNDBusiness) HND inCOMP & SD (Year2, SemesterA)
AssignmentTitle Designa database fora banking institution
Module Lecturer George K. Lekeas,MohammedAwais
Numberof Words 3460
AssignmentDue Date 06/05/2014
SubmissionDate 06/05/2014
Firstsubmission Resubmission(as perlecturer’sinstruction)
No cheating, dishonesty or plagiarism will be accepted from any learner who enrols for a
qualification/course.All sourcesmustbe properlyreferencedusingthe HarvardReferencingSystem.
Failure toproperlyreference anysource constitutes plagiarism whereby the learner will be subject
to disciplinary action, and will likely refer (fail) a unit.
All assignments must be submitted in electronic format through http://moodle.lsbm.org.uk. This
allows the College to check for plagiarism.
PART 2 – Studentdeclaration
By submitting this work to LSBM, I confirm that I have read and understood the Dishonesty and
Plagiarism Policy that is applicable to all assessments and assignments submitted by me.
I also confirm further that the work submitted here is my own work, save for where indicated by
properreferencing.ShouldInotabide by the policy and be found guilty of plagiarism by my course
lecturer or any other LSBM or appointed staff member I shall be bound by the decision of that
lecturer and/or staff member as well as the terms of the Dishonesty and Plagiarism Policy.
Please save your document in the following format before submitting through
Moodle:
Firstname- Surname–Course–Unit–Assignment-date.doc
E.g.:Rubin Gurung-APDMS-BO-Assignment-3Dec 09.doc
This page must be page 1 of your assignment. Start your work on page
2. 2 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Design database for
London Student Bank
(LSB)
3. 3 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Table of Contents
0. Introduction.......................................................................................................................4
1. Database Design for London Student Bank (LSB) ....................................................4
a) Assumptions about system .....................................................................................4
b) ERD for LSB ..............................................................................................................6
2. Database development ..................................................................................................7
a) Creting Table.............................................................................................................7
b) Database structure ...................................................................................................9
c) Database populating............................................................................................. 21
d) Database Queries.................................................................................................. 24
Aggregation................................................................................................................... 24
Sub query ...................................................................................................................... 24
Join................................................................................................................................. 25
Self-Join......................................................................................................................... 26
e) Create views........................................................................................................... 27
Account Details............................................................................................................. 27
Enrolment Student Details .......................................................................................... 28
3. Database review and testing ...................................................................................... 29
f) Test plan..................................................................................................................... 30
Elements of the system under testing....................................................................... 30
Type of testing .............................................................................................................. 30
Data used ...................................................................................................................... 31
g) Review and test ..................................................................................................... 31
h) Verification and validation .................................................................................... 35
i) Control mechanism ................................................................................................... 36
j) User documentation.................................................................................................. 36
4. Improvements ............................................................................................................... 37
5. Conclusion..................................................................................................................... 37
6. Bibliography................................................................................................................... 39
APPENDIX ............................................................................................................................ 40
a) LSB Database........................................................................................................ 41
4. 4 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
0. Introduction
“To run a successful business, a company must have a good understanding of its
customers, its employees, market competition, product performance, and the
research of new products. … Reliable information is often based on data collected
from a business process. The type of data from a business process may include text,
charts, sound, image, and other multimedia data types.” (Chao, 2006)
1. Database Design for London Student Bank (LSB)
a) Assumptions about system
A university runs more than one course; this is why having a table called university.
The same course, with the same degree, and duration can run to more than one
university and can be assigned to more than one student and course details are
stored in course table.
Connections between student, university, and course are made in student_details
table. Has choose this option because enable the system to trace the student by
university or course faster, without server overloading.
For each account, account table, must to have an account number, account_no field
like primary key, account holder, provided from student_details table like foreign key,
account type, standard or premium, provided by account_type table like foreign key
which enable overdraft attribute and decide the interest rate, stored in interest_rate
field.
In card table stores card details. Card no is stored in card_no field like primary key.
Other details about card are provided by account_no, foreign key, from account
table, and card holder details provided by card_holder field, foreign key, from person
table because a card holder can be anyone, not just a student.
Web users are stores in web_user table. This table contain a user ID, primary key,
username, current password provided by password history table via password_id,
than foreign key, and card_no field, foreign key, to provide associated card no and
card holder.
Password table contain on ID, primary key, password value stored in password field,
setup date and time, and employee_id, foreign key to provide details about the how
change the password.
To access an account each users is connect thru a session table. Here are stored
the connection ID, unique for each connection, remote card details, card_no field as
foreign key, details of user how intend to connect by web_user_id as foreign key,
5. 5 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
IP’s of devices used to connect in ip field, date and time of starting connection, also
session length.
The application is processed by application_file table. This table contain: value of
provided services on amount field, application status, in process, accepted and
rejected presented by status_id, foreign key from status table, the employee how
processed the application, foreign key from employee table, the guarantor for
applications, guarantor_id is an foreign key from guarantor table, kind of services
what is application for, student account, loan or mortgage, provided by
service_type_id which is foreign key from services_type table, student details
provided by student_details_id, as well foreign key from student_details table, also
each application is connected to an account by account_no from account table.
System_transaction table store all transactions initiated inside of the system. Table
contain an ID field which is a primary key, transaction_nature_id field, foreign key,
used to provide details about transaction like pay interest, account fee, monthly
amount, loan, mortgage or card fare, transaction_type_id, foreign key, field store the
kind of transactions, paying ore receiving because inside of the system can find boat
of them, payment value is store on amount field, and the transactions date on date
field, predecessor field, foreign key inside of table, is used in case of mortgages and
loans to show up the value of contract paid to the student at the beginning,
reference_id, like foreign key from application file to provide tracking of application
and account_no, foreign key, to associate transaction to an account. When a
transaction is initiated by system_transaction the transaction is made in behalf of
LSB, showed automatically on the system.
Income table store all received transactions out of the system.
Outcome table store all sent payments out of the system.
I have considered treating mortgage and loan like an attribute to allow them easier to
trace like income and outcome of account.
Has decide to split transactions on more than one table to make them easier to trace
and to reduce server overloading in case of interrogation intended to create reports
about transactions inside of LSB.
At this time LSB do not provide support for any kind of services like direct debit ore
standing order.
6. 6 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
b) ERD for LSB
7. 7 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
2. Database development
All database source code can be finding in appendix.
a) Creting Table
Person table syntax:
Course table syntax:
Student table syntax
create table person(
id int not null,
name varchar(40) not null,
address varchar(40) not null,
mobile_phone varchar(11) not null,
email varchar(40) not null,
primary key (id)
);
create table course(
id int not null,
type varchar(40) not null,
degree varchar(40) not null,
duration real,
start_date date not null,
end_date date not null,
primaty key (id)
);
8. 8 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Guarantor table syntax:
create table student(
id int not null auto_increment,
student_id int not null,
university_id int not null,
course_id int not null,
primary key (id),
foreign key (student_id) references person (id),
foreign key (university_id) references university (id),
foreign key (course_id) references course (id)
);
create table guarantor(
id int not null,
person_id int not null,
primary key (id),
foreign key (person_id) references person (id)
);
9. 9 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
b) Database structure
Table comments: account
Column Type Null Default Links to Comments MIME
account_no int(11) No
account_type_id int(11) No account_type ->id
student_details_id int(11) No student_details -> id
10. 10 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
interest_rate double Yes NULL
overdraft int(11) Yes NULL
Indexes
Keyname Type Unique Packed Column Cardinality Collation Null Comment
PRIMARY BTREE Yes No account_no 0 A No
account_type_account BTREE No No account_type_id 0 A No
student_details_account BTREE No No student_details_id 0 A No
Table comments: account_type
Column Type Null Default Comments MIME
id int(11) No
type varchar(40) No
Indexes
Keyname Type Unique Packed Column Cardinality Collation Null Comment
PRIMARY BTREE Yes No id 0 A No
Table comments: application_file
Column Type Null Default Links to Comments MIME
id int(11) No
amount decimal(10,0) No
status_id int(11) No status ->id
employee_id int(11) No employee -> id
guarantor_id int(11) No guarantor ->id
service_type_id int(11) No services_type ->id
student_details_id int(11) No student_details -> id
account_no int(11) No account ->account_no
Indexes
11. 11 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Keyname Type
Uniq
ue
Pack
ed
Column
Cardin
ality
Collati
on
Nu
ll
Comm
ent
PRIMARY
BTR
EE
Yes No id 0 A No
employee_application
_file
BTR
EE
No No employee_id 0 A No
guarantor_application
_file
BTR
EE
No No guarantor_id 0 A No
services_type_applica
tion_file
BTR
EE
No No
service_type
_id
0 A No
student_details_applic
ation_file
BTR
EE
No No
student_det
ails_id
0 A No
account_application_fi
le
BTR
EE
No No account_no 0 A No
status_application_file
BTR
EE
No No status_id 0 A No
Table comments: branch
Column Type Null Default Comments MIME
id int(11) No
name varchar(40) No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: card
Column Type Null Default Links to Comments MIME
12. 12 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
card_no int(11) No
account_no int(11) No account -> account_no
card_holder int(11) No person -> id
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinalit
y
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No card_no 0 A No
account_car
d
BTRE
E
No No
account_n
o
0 A No
person_car
d
BTRE
E
No No
card_hold
er
0 A No
Table comments: course
Column Type Null Default Comments MIME
id int(11) No
type varchar(40) No
degree varchar(40) No
duration double Yes NULL
start_date date No
end_date date No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
13. 13 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Table comments: customer
Column Type Null Default Comments MIME
id int(11) No
name varchar(40) No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: employee
Column Type Null Default Links to Comments MIME
id int(11) No
employee_name varchar(40) No
branch_id int(11) No branch -> id
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinalit
y
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
branch_employ
ee
BTRE
E
No No
branch_i
d
0 A No
Table comments: guarantor
Column Type Null Default Links to Comments MIME
id int(11) No
14. 14 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
person_id int(11) No person -> id
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinalit
y
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
person_guarant
or
BTRE
E
No No
person_i
d
0 A No
Table comments: income
Column Type Null Default Links to Comments MIME
id int(11) No
amount decimal(10,0) No
date date No
customer_id int(11) No customer -> id
account_no int(11) No
account ->
account_no
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinali
ty
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
account_incom
e
BTRE
E
No No
account_n
o
0 A No
customer_inco
me
BTRE
E
No No
customer_
id
0 A No
Table comments: outcome
15. 15 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Column Type Null Default Links to Comments MIME
id int(11) No
amount decimal(10,0) No
date date No
customer_id int(11) No customer -> id
account_no int(11) No
account ->
account_no
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinali
ty
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
account_outco
me
BTRE
E
No No
account_n
o
0 A No
customer_outco
me
BTRE
E
No No
customer_
id
0 A No
Table comments: password
Column Type Null Default Links to Comments MIME
id int(11) No
password varchar(40) No
setup_date date No
setup_time time No
employee_id int(11) No employee -> id
Indexes
16. 16 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Keyname Type
Uniqu
e
Packe
d
Column
Cardinali
ty
Collati
on
Nu
ll
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
employee_pass
word
BTRE
E
No No
employee
_id
0 A No
Table comments: person
Column Type Null Default Comments MIME
id int(11) No
name varchar(40) No
address varchar(40) No
mobile_phone varchar(11) No
email varchar(40) No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: services_type
Column Type Null Default Comments MIME
id int(11) No
type varchar(40) No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
17. 17 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: session
Column Type Null Default Links to Comments MIME
id int(11) No
ip varchar(15) No
accessing_date datetime No
accessing_time time No
card_no int(11) No card -> card_no
web_user_id int(11) No web_user -> id
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinali
ty
Collatio
n
Nul
l
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
card_session
BTRE
E
No No card_no 0 A No
web_user_sess
ion
BTRE
E
No No
web_user
_id
0 A No
Table comments: status
Column Type Null Default Comments MIME
id int(11) No
status varchar(40) No
18. 18 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: student_details
Column Type Null Default Links to Comments MIME
id int(11) No
student_id int(11) No person -> id
university_id int(11) No university -> id
course_id int(11) No course -> id
Indexes
Keyname Type
Un
iq
ue
Pac
ked
Column
Cardina
lity
Collati
on
Null
Comm
ent
PRIMARY BTREE
Ye
s
No id 0 A No
university_stude
nt_details
BTREE No No
university
_id
0 A No
course_student_
details
BTREE No No course_id 0 A No
person_student_
details
BTREE No No
student_i
d
0 A No
Table comments: system_transaction
Column Type Null Default Links to Comments MIME
id int(11) No
19. 19 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
amount double No
date date No
transaction_nature_id int(11) No
transaction_nature
-> id
transactions_type_id int(11) No
transaction_type ->
id
predecessor int(11) Yes NULL
system_transaction
-> id
reference_id int(11) Yes NULL
application_file ->
id
account_no int(11) No
account ->
account_no
Indexes
Keyname
Typ
e
Uni
que
Pac
ked
Column
Cardin
ality
Colla
tion
N
ull
Com
ment
PRIMARY
BTR
EE
Yes No id 0 A
N
o
account_system_transact
ion
BTR
EE
No No account_no 0 A
N
o
transaction_nature_syste
m_transaction
BTR
EE
No No
transaction_n
ature_id
0 A
N
o
transaction_type_system
_transaction
BTR
EE
No No
transactions_
type_id
0 A
N
o
system_transaction_syst
em_transaction
BTR
EE
No No predecessor 0 A
Y
es
application_file_system_t
ransaction
BTR
EE
No No reference_id 0 A
Y
es
Table comments: test
20. 20 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Column Type Null Default Comments MIME
id decimal(10,0) No
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: transaction_nature
Column Type Null Default Comments MIME
id int(11) No
description varchar(40) Yes NULL
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: transaction_type
Column Type Null Default Comments MIME
id int(11) No
name varchar(40) Yes NULL
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: university
21. 21 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Column Type Null Default Comments MIME
id int(11) No
name varchar(40) Yes NULL
Indexes
Keyname Type
Uniqu
e
Packe
d
Colum
n
Cardinalit
y
Collatio
n
Nul
l
Commen
t
PRIMAR
Y
BTRE
E
Yes No id 0 A No
Table comments: web_user
Column Type Null Default Links to Comments MIME
id int(11) No
user_name varchar(40) No
password_id int(11) No password -> id
card_no int(11) No card -> card_no
Indexes
Keyname Type
Uniqu
e
Packe
d
Column
Cardinali
ty
Collati
on
Nu
ll
Comme
nt
PRIMARY
BTRE
E
Yes No id 0 A No
password_web_
user
BTRE
E
No No
password
_id
0 A No
card_web_user
BTRE
E
No No card_no 0 A No
c) Database populating
Person table
22. 22 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Course table
University table
23. 23 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Student_details table
Application file
Account file
24. 24 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
d) Database Queries
Aggregation
Like aggregation example have closed COUNT (*) function. At this example are
presented all applications associated to an account. COUNT (*) function count and
return a total value of each line of WHERE statement true.
Sub query
A sub query is a nested query. In this example WHERE statement uses more
condition to be true, one of them is other function aimed to determinate average
amount of all applications and displays all applications over average together with
student id, student name, and account no.
SELECT account.account_no, COUNT( * )
FROM account, application_file
WHERE application_file.account_no = account.account_no
GROUP BY account.account_no;
SELECT student_details.id, person.name, account.account_no, application_file.amount
FROM student_details, person, account, application_file
WHERE application_file.account_no = account.account_no
AND student_details.id = account.student_details_id
AND person.id = student_details.student_id
AND application_file.amount > ( SELECT AVG( application_file.amount )
FROM application_file );
25. 25 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Join
The JOIN clause is a combination of rows from more than one table, using common
fields between them. In SQL can find different kinds of JOIN clause with different
functions, these are: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN.
INNER JOIN
This query example is aimed to presents all students along with student id, extract
from database all rows with WHERE statement true.
select student_details.id, person.name
from student_details
INNER JOIN person
where person.id = student_details.student_id
order by student_details.id;
equivalent of
select student_details.id, person.name
from student_details, person
where person.id = student_details.student_id
order by student_details.id;
26. 26 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
RIGHT JOIN
This example present all rows from the person table associated to student id, where
student id is not associated is display null.
Self-Join
It is a reference to join a table to itself. Tis example present associated file id which
preceded them.
select student_details.id, person.name
from student_details
right JOIN person
on person.id = student_details.student_id
order by student_details.id;
equivalent of
select student_details.id, person.name
from person
left outer JOIN student_details
on person.id = student_details.student_id
order by student_details.id;
27. 27 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
e) Create views
A view is a virtual table based on query results of one or more tables. To create a
view in MySQL call CREARE VIEW statement. Process involves to provide a name
for view followed by the AS and SELECT statement.
Account Details
Tables used to create this view are student_details, person, account, account_type,
card.
select system_transaction.id, system_transaction.amount, system_transaction.date,
system_transaction.predecessor
from system_transaction
where system_transaction.predecessor is not NULL;
create view account_details as
select student_details.id, person.name, account.account_no, account_type.type,
card.card_no
from student_details, person, account, account_type, card
where student_details.student_id = person.id
and student_details.id = account.student_details_id
and account.account_no = card.account_no
and account.account_type_id = account_type.id
order by student_details.id;
28. 28 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Enrolment Student Details
Tables used to create this view are student_details, person, course,university.
29. 29 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
3. Database review and testing
create view student_enrol AS
select student_details.id,
person.name,course.type,course.degree,course.duration,course.start_date,cours
e.end_date,university.u_name
from student_details, person, course,university
where student_details.student_id = person.id and university.id =
student_details.university_id and student_details.course_id = course.id
order by student_details.id;
30. 30 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Database testing is an important part of life cycle development. It is aimed to check
database rules or right business rules implementation, data integrity, data accessing,
code correctness, data validity, performance, and security of the software under
development.
Database testing is running over ODBC helping by the following functions:
SQLOpen, SQLClose, SQLError, SQLRetrieve, SQLRetrieveToFile, SQLExecQuery,
SQLGetSchema and SQLRequest.
For relevant testing results, for each test is important to develop a test plan.
f) Test plan
Each test plan must to contain required steps. Before to start it is important to know
what will be tested, how will be tasted and which kind of data are used in testing
process.
Elements of the system under testing
According to TTCN-3 standards was decide to test:
1. Database
a. Database name
b. Database allocation space
2. Tables, columns, column types and rules
a. The name of all tables
b. Column names of each table
c. Data type of each column
d. If a column allows NULL or not
e. Rule definitions
3. Keys and indexes
a. Primary fey of each table
b. Foreign keys
c. Foreign key data types and associated column
4. Data integrity and consistency
a. Data validation before insertion, updating and deletion
b. Tray to insert a child data before inserting its parent’s data
c. Try to delete a record that is still referenced by data in other table
d. Try to insert different data type then what was defined
Type of testing
Like tests have more concepts, depending by area which supposed to be used has
more testing methods. Like database tests can find black-box, with-box and
WHODATE approaches.
This test will use With-box testing and assume to evaluate:
Database functions, views, queries
31. 31 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Validates database tables, data models, database schema
Referential integrity
Database consistency
Tools used on testing process: TSQLUnit and LiquiBase.
Data used
Can use three different types of test data values that shoul be used to fully test a
database system:
- Normal values
- Extreme values
- Exceptional values
Each value of test data it is selected to determinate if the system process them
correctly. The developer must to know, before to proceed to test, what is expecting
to return to can compare against of data testing output. It is required to store boat of
them in idea to identify when processing errors have occurred.
Just when the testing data and expected output are clear selected can proceed to
test.
account table
Column
Database data
Type
case 1 case 2 case 3
expected
results
account_no int(11) 1.5 a ‘’ error
account_type_id int(11) 1.5 a ‘’ error
student_details_id int(11) 1.5 a ‘’ error
interest_rate double a a ‘’ error
overdraft int(11) 1.5 a ‘’ error
person table
Column
Database data
Type
case 1 case 2 case 3
expected
results
id int(11) a 2.2 null error
name varchar(40) a 2.2 null error
address varchar(40) a 2.2 null error
mobile_phone varchar(11) a 2.2 null error
email varchar(40) a 2.2 null error
g) Review and test
Startups test result was found:
Account table tests
Case 1
32. 32 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Results:
Case 2
Results:
insert into account
values (1.5,1.5,1.5, 'a', 1.5 );
insert into account
values ('a','a','a', 'a', 'a' );
33. 33 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Case 3
Results:
Person table tests
Case 1
insert into account
values ('','','', '', '' );
insert into person
values ('a','a','a', 'a', 'a' );
34. 34 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Results:
Case 2
Results:
insert into person
values ('2.2','2.2','2.2', '2.2', '2.2' );
35. 35 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
Case 3
Results:
Review
Database accept meet the testing requirements at test 1- Database, test 2 - Tables,
columns, column types and rules, test 3 - Keys and indexes, and partial test 4 - Data
integrity and consistency.
Fail result are: test 4.a - Data validation before insertion, updating and deletion, test
4.d - Try to insert different data type then what was defined
h) Verification and validation
One of the biggest problem with database system is that is very easy to insert wrong
data into them. If wrong data are inserted will produce incorrect outputs, garbage in
garbage out (GIGO).
Have to main techniques to avoid these problems.
Verification
Verification process ensures that the data inserted into a database system are
accurate. It can be made in two ways, on-screen prompt, when after each inserted
row system return a massage to confirm if data are correctly inserted or not. The
second way use to different operators to insert data, into two different databases
insert into person
values ( null ,null ,null ,null ,null );
36. 36 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
which are compared, in case of any inconsistency process is repeated. This process
is called Dual Input.
Validation
It is a process of checking data sensitivity. Can be care out by software without data
correctness concerns. Like validations method are identified: presence check, type
check, length check, range check, format check, check digit, and parity check.
Developed database misses to pass the verification and validation test.
i) Control mechanism
Like control mechanism in this development was decide to use the optimistic
concurrency control, rather than pessimistic control, because of less conflicts
possibilities. Pessimistic Control looks more appropriate for a banking institution was
chose to not use this kind of control mechanism for that to allow users to change
data as it is built only for students and the data inserted for students is unsure
because as a student the address can be changed often, mobile number, type of
account and many other things.
j) User documentation
End user documentation is a success key of any database development. The quality
of end-user documentation can alter the implementation assessment of the new
system.
In our case, end-user documentation is equivalent with code documentation. It is
very important that the user documentations to be very well organized, to not be
confusing and to hold an elaborate index. In documentation proses are three
approaches of documentation organizing. Tutorial approach, most useful for a new
user, is a guideline step-by-step of accomplishing a particular task. Thematic
approach, each chapter cover a particular area of interest, presents a general using
concepts and is addressed to intermediate users. Referencing list approach, where
commands or tasks are listed alphabetically, is aimed to be used by advanced users
who know exactly what kind of information they are looking for.
End user documentations can be presented in forms of online documents, PDFs
files, videos ore printed manuals.
End User Manual
account Store and provide all account details
account_details
Extract from database all account holders, card
number, card type and associated card no
account_type
provide attributes for account, like standard or
premium, and enable overdraft attribute and decide
the interest rate
application_file Keep and provide application tracking
37. 37 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
branch Store and provide branch details
card Store and provide all cards details
course Store and provide course details
customer Here are all customerdetails
employee All employee details are find here
guarantor
Make connections between persontable and
application file aimed to provide guarantor attribute
for a personand allow to trace them
income All incoming operations out of the system
outcome All outgoing operations outside of the system
password store password and password history
person store all details for a human
services_type
provide kind of services,like student account, loan,
mortgage,for a transaction
session Store webs sessiondetails
status
Store and provide attributes for application
process,such as Acceptedor Rejected
student_details
For a personto becomea student must to have
associated some details, like university and course.
This association is made hear
student_enrol Extract from database all student details
system_transacti
on
Store and provide all transactions details which
insoles the LSB system
transaction_natur
e
Provide details about transaction like pay interest,
account fee,monthly amount, loan, mortgage or
card fare
transaction_type
field store the kind of transactions, paying ore
receiving because inside of the system can find
boat of them
university Store and provide universities details
web_user
Store all username details along with associated
cards and accounts
4. Improvements
Like improvement of LSB database is recommend to reevaluate all design to enforce
data integrity and consistency.
5. Conclusion
A relational database is a wonderful tool aimed to storing and organising large
amounts of data efficiently. This piece of work is aimed to present stages of
development and implementations, from conceptual design to preparing end-user
documentation.
38. 38 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
39. 39 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
6. Bibliography
Chao, L., 2006. Database Development and Management.. Auerbach Publications
ed. s.l.:Boca Raton.
Connolly, T. M. and Begg, C. E., 2005. Database systems. A proactical approch to
design, implementation, and management. 4-th ed. London: Pearson Education
Limited.
Elmasri, R. and Navathe, S., 2009. Grundlagen von Datenbanksystemen. 3-th ed.
s.l.:Pearson Deutschland.
Fortier, P. J. and Michel, H. E., 2003. Computer Systems Performance Evaluation
and Prediction. Burlington: Digital Press.
Hoffer, J. A. and Prescott, B. M. and McFadden, R. F., 2006. Modern Databace
Management. 8-th ed. s.l.:Pearson Education.
Kendall, K. E. and Kendall, J. E., 2010. Systems analysis and design. 8th ed.
s.l.:Prentice Hall.
Kroenke, D. M. and Auer, D. J., 2013. Database Concepts. 6-th ed. s.l.:Pearson.
Microsoft, n.d. Description of the database normalization basics. [Online]
Available at: http://support.microsoft.com/
[Accessed 08 08 2013].
Özsu, M. T. and Valduriez, P., 2011. Principles of Distributed Database Systems. 3rd
ed. New York: Springer Science + Business Media.
Ritchie, C., 2008. Database principles and design. 3rd ed. s.l.:Cengage Learming
EMEA.
40. 40 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
APPENDIX
41. 41 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
a) LSB Database
-- phpMyAdmin SQL Dump
-- version 4.0.4.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: May 06, 2014 at 03:40 AM
-- Server version: 5.5.32
-- PHP Version: 5.4.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `dad`
--
CREATE DATABASE IF NOT EXISTS `dad` DEFAULT CHARACTER SET latin1
COLLATE latin1_swedish_ci;
USE `dad`;
-- --------------------------------------------------------
--
-- Table structure for table `account`
--
CREATE TABLE IF NOT EXISTS `account` (
`account_no` int(11) NOT NULL,
`account_type_id` int(11) NOT NULL,
`student_details_id` int(11) NOT NULL,
`interest_rate` double DEFAULT NULL,
`overdraft` int(11) DEFAULT NULL,
PRIMARY KEY (`account_no`),
KEY `account_type_account` (`account_type_id`),
KEY `student_details_account` (`student_details_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `account`
--
42. 42 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
INSERT INTO `account` (`account_no`, `account_type_id`, `student_details_id`,
`interest_rate`, `overdraft`) VALUES
(2, 2, 2, 0, 2),
(221, 1, 4, 2.2, 1000),
(223, 2, 5, 3.1, 0),
(225, 2, 6, 4.2, 100),
(227, 1, 7, 2.2, 1000),
(229, 2, 8, 3.1, 0),
(231, 1, 9, 4.2, 100),
(233, 2, 10, 10, 0);
-- --------------------------------------------------------
--
-- Stand-in structure for view `account_details`
--
CREATE TABLE IF NOT EXISTS `account_details` (
`id` int(11)
,`name` varchar(40)
,`account_no` int(11)
,`type` varchar(40)
,`card_no` int(11)
);
-- --------------------------------------------------------
--
-- Table structure for table `account_type`
--
CREATE TABLE IF NOT EXISTS `account_type` (
`id` int(11) NOT NULL,
`type` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `account_type`
--
INSERT INTO `account_type` (`id`, `type`) VALUES
(1, 'standard'),
(2, 'premium');
-- --------------------------------------------------------
--
-- Table structure for table `application_file`
--
CREATE TABLE IF NOT EXISTS `application_file` (
43. 43 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
`id` int(11) NOT NULL,
`amount` decimal(10,0) NOT NULL,
`status_id` int(11) NOT NULL,
`employee_id` int(11) NOT NULL,
`guarantor_id` int(11) NOT NULL,
`service_type_id` int(11) NOT NULL,
`student_details_id` int(11) NOT NULL,
`account_no` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `employee_application_file` (`employee_id`),
KEY `guarantor_application_file` (`guarantor_id`),
KEY `services_type_application_file` (`service_type_id`),
KEY `student_details_application_file` (`student_details_id`),
KEY `account_application_file` (`account_no`),
KEY `status_application_file` (`status_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `application_file`
--
INSERT INTO `application_file` (`id`, `amount`, `status_id`, `employee_id`,
`guarantor_id`, `service_type_id`, `student_details_id`, `account_no`) VALUES
(1, '100', 1, 4, 1, 1, 1, 221),
(2, '120', 1, 3, 2, 1, 2, 223),
(3, '140', 2, 2, 1, 2, 1, 221),
(4, '160', 2, 1, 4, 1, 3, 225),
(5, '180', 1, 5, 3, 3, 5, 227),
(6, '200', 1, 2, 3, 3, 6, 229),
(7, '220', 1, 3, 2, 2, 7, 231),
(8, '240', 2, 4, 2, 2, 7, 231),
(9, '260', 1, 4, 1, 1, 5, 223),
(10, '280', 1, 5, 5, 1, 6, 225);
-- --------------------------------------------------------
--
-- Table structure for table `branch`
--
CREATE TABLE IF NOT EXISTS `branch` (
`id` int(11) NOT NULL,
`name` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `branch`
--
44. 44 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
INSERT INTO `branch` (`id`, `name`) VALUES
(1, 'Branch1'),
(2, 'Branch2'),
(3, 'Branch3'),
(4, 'Branch4'),
(5, 'Branch5');
-- --------------------------------------------------------
--
-- Table structure for table `card`
--
CREATE TABLE IF NOT EXISTS `card` (
`card_no` int(11) NOT NULL,
`account_no` int(11) NOT NULL,
`card_holder` int(11) NOT NULL,
PRIMARY KEY (`card_no`),
KEY `account_card` (`account_no`),
KEY `person_card` (`card_holder`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `card`
--
INSERT INTO `card` (`card_no`, `account_no`, `card_holder`) VALUES
(1, 221, 5),
(2, 223, 6),
(3, 225, 7),
(4, 221, 8),
(5, 227, 9),
(6, 221, 10);
-- --------------------------------------------------------
--
-- Table structure for table `course`
--
CREATE TABLE IF NOT EXISTS `course` (
`id` int(11) NOT NULL,
`type` varchar(40) NOT NULL,
`degree` varchar(40) NOT NULL,
`duration` double DEFAULT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
45. 45 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
--
-- Dumping data for table `course`
--
INSERT INTO `course` (`id`, `type`, `degree`, `duration`, `start_date`, `end_date`)
VALUES
(1, 'under-graduate', 'BSc', 1, '2012-10-20', '2013-10-20'),
(2, 'post-graduate', 'BSc', 1, '2013-10-21', '2014-10-21'),
(3, 'under-graduate', 'BSc', 2, '2013-03-27', '2015-03-27'),
(4, 'masters', 'MSc', 3, '2014-10-11', '2017-10-10'),
(5, 'under-graduate', 'BSc', 4, '2014-07-14', '2018-07-13'),
(6, 'post-graduate', 'BSc', 3, '2012-10-20', '2015-10-20'),
(7, 'under-graduate', 'BSc', 2, '2014-10-20', '2016-10-19'),
(8, 'under-graduate', 'BSc', 2, '2015-09-20', '2017-09-19'),
(9, 'masters', 'MSc', 1, '2011-11-20', '2012-11-19'),
(10, 'masters', 'MSc', 2, '2012-04-02', '2014-04-02');
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
CREATE TABLE IF NOT EXISTS `customer` (
`id` int(11) NOT NULL,
`name` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customer`
--
INSERT INTO `customer` (`id`, `name`) VALUES
(1, 'Customer1'),
(2, 'Customer2'),
(3, 'Customer3'),
(4, 'Customer4'),
(5, 'Customer5');
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE IF NOT EXISTS `employee` (
`id` int(11) NOT NULL,
`employee_name` varchar(40) NOT NULL,
`branch_id` int(11) NOT NULL,
46. 46 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
PRIMARY KEY (`id`),
KEY `branch_employee` (`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`id`, `employee_name`, `branch_id`) VALUES
(1, 'Employee1', 1),
(2, 'Employee2', 1),
(3, 'Employee3', 2),
(4, 'Employee4', 3),
(5, 'Employee5', 4);
-- --------------------------------------------------------
--
-- Table structure for table `guarantor`
--
CREATE TABLE IF NOT EXISTS `guarantor` (
`id` int(11) NOT NULL,
`person_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `person_guarantor` (`person_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `guarantor`
--
INSERT INTO `guarantor` (`id`, `person_id`) VALUES
(1, 1),
(3, 2),
(4, 3),
(5, 4),
(2, 5);
-- --------------------------------------------------------
--
-- Table structure for table `income`
--
CREATE TABLE IF NOT EXISTS `income` (
`id` int(11) NOT NULL,
`amount` decimal(10,0) NOT NULL,
`date` date NOT NULL,
`customer_id` int(11) NOT NULL,
47. 47 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
`account_no` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `account_income` (`account_no`),
KEY `customer_income` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `income`
--
INSERT INTO `income` (`id`, `amount`, `date`, `customer_id`, `account_no`)
VALUES
(1, '50', '0000-00-00', 1, 221),
(2, '70', '0000-00-00', 1, 223),
(3, '90', '0000-00-00', 1, 221),
(4, '110', '0000-00-00', 2, 225),
(5, '130', '0000-00-00', 2, 225);
-- --------------------------------------------------------
--
-- Table structure for table `outcome`
--
CREATE TABLE IF NOT EXISTS `outcome` (
`id` int(11) NOT NULL,
`amount` decimal(10,0) NOT NULL,
`date` date NOT NULL,
`customer_id` int(11) NOT NULL,
`account_no` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `account_outcome` (`account_no`),
KEY `customer_outcome` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `outcome`
--
INSERT INTO `outcome` (`id`, `amount`, `date`, `customer_id`, `account_no`)
VALUES
(1, '20', '0000-00-00', 1, 221),
(2, '30', '0000-00-00', 1, 223),
(3, '90', '0000-00-00', 1, 225),
(4, '60', '0000-00-00', 2, 227),
(5, '40', '0000-00-00', 2, 221);
-- --------------------------------------------------------
--
48. 48 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
-- Table structure for table `password`
--
CREATE TABLE IF NOT EXISTS `password` (
`id` int(11) NOT NULL,
`password` varchar(40) NOT NULL,
`setup_date` date NOT NULL,
`setup_time` time NOT NULL,
`employee_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `employee_password` (`employee_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `password`
--
INSERT INTO `password` (`id`, `password`, `setup_date`, `setup_time`,
`employee_id`) VALUES
(1, 'pass1', '2014-03-02', '10:15:00', 1),
(2, 'pass2', '2014-03-03', '10:20:00', 1),
(3, 'pass3', '2014-03-04', '10:24:00', 1),
(4, 'pass4', '2014-03-05', '10:15:00', 2),
(5, 'pass5', '2014-03-06', '10:20:00', 2);
-- --------------------------------------------------------
--
-- Table structure for table `person`
--
CREATE TABLE IF NOT EXISTS `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) NOT NULL,
`address` varchar(40) NOT NULL,
`mobile_phone` varchar(11) NOT NULL,
`email` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=559 ;
--
-- Dumping data for table `person`
--
INSERT INTO `person` (`id`, `name`, `address`, `mobile_phone`, `email`) VALUES
(1, 'John Smith', '20 Street Rd', '7831199300', 'email.gmail.com'),
(2, 'Smith Clerk', '31 Road', '7831199301', 'email2@gmail.com'),
(3, 'Student 1', '35 Station Road', '7831199302', 'email.gmail.com'),
(4, 'Student 2', '1 Essex Rd', '7831199303', 'email2@gmail.com'),
(5, 'Student 3', '21 Street Rd', '7831199304', 'email.gmail.com'),
49. 49 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
(6, 'Student 4', '32 Road', '7831199305', 'email2@gmail.com'),
(7, 'Student 5', '36 Station Road', '7831199306', 'email.gmail.com'),
(8, 'Student 6', '2 Essex Rd', '7831199307', 'email2@gmail.com'),
(9, 'Student 7', '22 Street Rd', '7831199308', 'email.gmail.com'),
(10, 'Student 8', '33 Road', '7831199309', 'email2@gmail.com'),
(11, 'person1', 'dsadsa', '7831199310', 'email2@gmail.com'),
(12, 'person2', 'dsasa', '7831199311', 'email.gmail.com'),
(13, 'person3', 'dsadsa', '7831199312', 'email2@gmail.com'),
(557, 'a', 'a', 'a', 'a');
-- --------------------------------------------------------
--
-- Table structure for table `services_type`
--
CREATE TABLE IF NOT EXISTS `services_type` (
`id` int(11) NOT NULL,
`type` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `services_type`
--
INSERT INTO `services_type` (`id`, `type`) VALUES
(1, 'Student Account'),
(2, 'Loan'),
(3, 'Mortgage');
-- --------------------------------------------------------
--
-- Table structure for table `session`
--
CREATE TABLE IF NOT EXISTS `session` (
`id` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`accessing_date` datetime NOT NULL,
`accessing_time` time NOT NULL,
`card_no` int(11) NOT NULL,
`web_user_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `card_session` (`card_no`),
KEY `web_user_session` (`web_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
50. 50 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
-- Dumping data for table `session`
--
INSERT INTO `session` (`id`, `ip`, `accessing_date`, `accessing_time`, `card_no`,
`web_user_id`) VALUES
(1, '192.168.10.1', '0000-00-00 00:00:00', '10:15:00', 1, 1),
(2, '192.168.10.2', '0000-00-00 00:00:00', '10:20:00', 2, 2),
(3, '192.168.10.3', '0000-00-00 00:00:00', '10:24:00', 1, 1),
(4, '192.168.10.4', '0000-00-00 00:00:00', '10:15:00', 3, 3),
(5, '192.168.10.5', '0000-00-00 00:00:00', '10:20:00', 4, 4);
-- --------------------------------------------------------
--
-- Table structure for table `status`
--
CREATE TABLE IF NOT EXISTS `status` (
`id` int(11) NOT NULL,
`status` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `status`
--
INSERT INTO `status` (`id`, `status`) VALUES
(1, 'Accepted'),
(2, 'Rejected');
-- --------------------------------------------------------
--
-- Table structure for table `student_details`
--
CREATE TABLE IF NOT EXISTS `student_details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`student_id` int(11) NOT NULL,
`university_id` int(11) NOT NULL,
`course_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `university_student_details` (`university_id`),
KEY `course_student_details` (`course_id`),
KEY `person_student_details` (`student_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
--
-- Dumping data for table `student_details`
51. 51 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
--
INSERT INTO `student_details` (`id`, `student_id`, `university_id`, `course_id`)
VALUES
(1, 1, 2, 3),
(2, 2, 3, 4),
(3, 3, 4, 5),
(4, 4, 5, 6),
(5, 5, 6, 7),
(6, 6, 7, 8),
(7, 7, 8, 9),
(8, 8, 9, 10),
(9, 9, 10, 1),
(10, 10, 1, 2);
-- --------------------------------------------------------
--
-- Stand-in structure for view `student_enrol`
--
CREATE TABLE IF NOT EXISTS `student_enrol` (
`id` int(11)
,`name` varchar(40)
,`type` varchar(40)
,`degree` varchar(40)
,`duration` double
,`start_date` date
,`end_date` date
,`u_name` varchar(40)
);
-- --------------------------------------------------------
--
-- Table structure for table `system_transaction`
--
CREATE TABLE IF NOT EXISTS `system_transaction` (
`id` int(11) NOT NULL,
`amount` double NOT NULL,
`date` date NOT NULL,
`transaction_nature_id` int(11) NOT NULL,
`transactions_type_id` int(11) NOT NULL,
`predecessor` int(11) DEFAULT NULL,
`reference_id` int(11) DEFAULT NULL,
`account_no` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `account_system_transaction` (`account_no`),
KEY `transaction_nature_system_transaction` (`transaction_nature_id`),
KEY `transaction_type_system_transaction` (`transactions_type_id`),
KEY `system_transaction_system_transaction` (`predecessor`),
52. 52 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
KEY `application_file_system_transaction` (`reference_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `system_transaction`
--
INSERT INTO `system_transaction` (`id`, `amount`, `date`, `transaction_nature_id`,
`transactions_type_id`, `predecessor`, `reference_id`, `account_no`) VALUES
(1, 200, '0000-00-00', 4, 1, NULL, 1, 221),
(2, 30, '0000-00-00', 1, 2, 1, 1, 221),
(3, 200, '0000-00-00', 3, 2, 1, 1, 221),
(4, 400, '0000-00-00', 5, 1, 2, 2, 227),
(5, 40, '0000-00-00', 2, 2, 1, 2, 227),
(6, 500, '0000-00-00', 5, 1, NULL, 5, 233);
-- --------------------------------------------------------
--
-- Table structure for table `transaction_nature`
--
CREATE TABLE IF NOT EXISTS `transaction_nature` (
`id` int(11) NOT NULL,
`description` varchar(40) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `transaction_nature`
--
INSERT INTO `transaction_nature` (`id`, `description`) VALUES
(1, 'Interest'),
(2, 'Account fee'),
(3, 'Loan return'),
(4, 'Loan'),
(5, 'Mortgage');
-- --------------------------------------------------------
--
-- Table structure for table `transaction_type`
--
CREATE TABLE IF NOT EXISTS `transaction_type` (
`id` int(11) NOT NULL,
`name` varchar(40) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
53. 53 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
--
-- Dumping data for table `transaction_type`
--
INSERT INTO `transaction_type` (`id`, `name`) VALUES
(1, 'Received'),
(2, 'Sent');
-- --------------------------------------------------------
--
-- Table structure for table `university`
--
CREATE TABLE IF NOT EXISTS `university` (
`id` int(11) NOT NULL,
`u_name` varchar(40) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `university`
--
INSERT INTO `university` (`id`, `u_name`) VALUES
(1, 'LSB'),
(2, 'LSBM'),
(3, 'University 1'),
(4, 'University 2'),
(5, 'University 3'),
(6, 'University 4'),
(7, 'University 5'),
(8, 'University 6'),
(9, 'University 7'),
(10, 'University 8');
-- --------------------------------------------------------
--
-- Table structure for table `web_user`
--
CREATE TABLE IF NOT EXISTS `web_user` (
`id` int(11) NOT NULL,
`user_name` varchar(40) NOT NULL,
`password_id` int(11) NOT NULL,
`card_no` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `password_web_user` (`password_id`),
54. 54 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
KEY `card_web_user` (`card_no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `web_user`
--
INSERT INTO `web_user` (`id`, `user_name`, `password_id`, `card_no`) VALUES
(1, 'user1', 2, 1),
(2, 'user2', 3, 2),
(3, 'user3', 4, 3),
(4, 'user4', 5, 4),
(5, 'user5', 1, 5);
-- --------------------------------------------------------
--
-- Structure for view `account_details`
--
DROP TABLE IF EXISTS `account_details`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY
DEFINER VIEW `account_details` AS select `student_details`.`id` AS
`id`,`person`.`name` AS `name`,`account`.`account_no` AS
`account_no`,`account_type`.`type` AS `type`,`card`.`card_no` AS `card_no` from
((((`student_details` join `person`) join `account`) join `account_type`) join `card`)
where ((`student_details`.`student_id` = `person`.`id`) and (`student_details`.`id` =
`account`.`student_details_id`) and (`account`.`account_no` = `card`.`account_no`)
and (`account`.`account_type_id` = `account_type`.`id`)) order by
`student_details`.`id`;
-- --------------------------------------------------------
--
-- Structure for view `student_enrol`
--
DROP TABLE IF EXISTS `student_enrol`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY
DEFINER VIEW `student_enrol` AS select `student_details`.`id` AS
`id`,`person`.`name` AS `name`,`course`.`type` AS `type`,`course`.`degree` AS
`degree`,`course`.`duration` AS `duration`,`course`.`start_date` AS
`start_date`,`course`.`end_date` AS `end_date`,`university`.`u_name` AS `u_name`
from (((`student_details` join `person`) join `course`) join `university`) where
((`student_details`.`student_id` = `person`.`id`) and (`university`.`id` =
`student_details`.`university_id`) and (`student_details`.`course_id` = `course`.`id`))
order by `student_details`.`id`;
--
-- Constraints for dumped tables
55. 55 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
--
--
-- Constraints for table `account`
--
ALTER TABLE `account`
ADD CONSTRAINT `account_type_account` FOREIGN KEY (`account_type_id`)
REFERENCES `account_type` (`id`),
ADD CONSTRAINT `student_details_account` FOREIGN KEY
(`student_details_id`) REFERENCES `student_details` (`id`);
--
-- Constraints for table `application_file`
--
ALTER TABLE `application_file`
ADD CONSTRAINT `account_application_file` FOREIGN KEY (`account_no`)
REFERENCES `account` (`account_no`),
ADD CONSTRAINT `employee_application_file` FOREIGN KEY (`employee_id`)
REFERENCES `employee` (`id`),
ADD CONSTRAINT `guarantor_application_file` FOREIGN KEY (`guarantor_id`)
REFERENCES `guarantor` (`id`),
ADD CONSTRAINT `services_type_application_file` FOREIGN KEY
(`service_type_id`) REFERENCES `services_type` (`id`),
ADD CONSTRAINT `status_application_file` FOREIGN KEY (`status_id`)
REFERENCES `status` (`id`),
ADD CONSTRAINT `student_details_application_file` FOREIGN KEY
(`student_details_id`) REFERENCES `student_details` (`id`);
--
-- Constraints for table `card`
--
ALTER TABLE `card`
ADD CONSTRAINT `account_card` FOREIGN KEY (`account_no`) REFERENCES
`account` (`account_no`),
ADD CONSTRAINT `person_card` FOREIGN KEY (`card_holder`) REFERENCES
`person` (`id`);
--
-- Constraints for table `employee`
--
ALTER TABLE `employee`
ADD CONSTRAINT `branch_employee` FOREIGN KEY (`branch_id`)
REFERENCES `branch` (`id`);
--
-- Constraints for table `guarantor`
--
ALTER TABLE `guarantor`
ADD CONSTRAINT `person_guarantor` FOREIGN KEY (`person_id`)
REFERENCES `person` (`id`);
56. 56 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
--
-- Constraints for table `income`
--
ALTER TABLE `income`
ADD CONSTRAINT `account_income` FOREIGN KEY (`account_no`)
REFERENCES `account` (`account_no`),
ADD CONSTRAINT `customer_income` FOREIGN KEY (`customer_id`)
REFERENCES `customer` (`id`);
--
-- Constraints for table `outcome`
--
ALTER TABLE `outcome`
ADD CONSTRAINT `account_outcome` FOREIGN KEY (`account_no`)
REFERENCES `account` (`account_no`),
ADD CONSTRAINT `customer_outcome` FOREIGN KEY (`customer_id`)
REFERENCES `customer` (`id`);
--
-- Constraints for table `password`
--
ALTER TABLE `password`
ADD CONSTRAINT `employee_password` FOREIGN KEY (`employee_id`)
REFERENCES `employee` (`id`);
--
-- Constraints for table `session`
--
ALTER TABLE `session`
ADD CONSTRAINT `card_session` FOREIGN KEY (`card_no`) REFERENCES
`card` (`card_no`),
ADD CONSTRAINT `web_user_session` FOREIGN KEY (`web_user_id`)
REFERENCES `web_user` (`id`);
--
-- Constraints for table `student_details`
--
ALTER TABLE `student_details`
ADD CONSTRAINT `course_student_details` FOREIGN KEY (`course_id`)
REFERENCES `course` (`id`),
ADD CONSTRAINT `person_student_details` FOREIGN KEY (`student_id`)
REFERENCES `person` (`id`),
ADD CONSTRAINT `university_student_details` FOREIGN KEY (`university_id`)
REFERENCES `university` (`id`);
--
-- Constraints for table `system_transaction`
--
ALTER TABLE `system_transaction`
57. 57 | I o a n T u n s - H N D C S D - D A D - 0 6 / 0 5 / 2 0 1 4
ADD CONSTRAINT `account_system_transaction` FOREIGN KEY (`account_no`)
REFERENCES `account` (`account_no`),
ADD CONSTRAINT `application_file_system_transaction` FOREIGN KEY
(`reference_id`) REFERENCES `application_file` (`id`),
ADD CONSTRAINT `system_transaction_system_transaction` FOREIGN KEY
(`predecessor`) REFERENCES `system_transaction` (`id`),
ADD CONSTRAINT `transaction_nature_system_transaction` FOREIGN KEY
(`transaction_nature_id`) REFERENCES `transaction_nature` (`id`),
ADD CONSTRAINT `transaction_type_system_transaction` FOREIGN KEY
(`transactions_type_id`) REFERENCES `transaction_type` (`id`);
--
-- Constraints for table `web_user`
--
ALTER TABLE `web_user`
ADD CONSTRAINT `card_web_user` FOREIGN KEY (`card_no`) REFERENCES
`card` (`card_no`),
ADD CONSTRAINT `password_web_user` FOREIGN KEY (`password_id`)
REFERENCES `password` (`id`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET
CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;