Professional Documents
Culture Documents
Database Design AND Implementation Using Visual Basic
Database Design AND Implementation Using Visual Basic
University of Baghdad
College of sciences
Computer sciences
Department
DATABASE DESIGN
AND
IMPLEMENTATION
USING
VISUAL BASIC
By:
Mohannad Taha & Saad fadhil
Supervised by:
AmEnah Dahim Abood
Acknowledgement
Context
Chapter 1 (Database) ……..………………………… 1
1.1 Introduction …………………………………………… 1
1.2 Database Management System (DBMS) .……………. 2
1.3 DBMS Functions ………………………………………. 3
1.4 Database Models ………………………………………. 4
1.4.1 Conceptual Models ……………………………….………… 4
1.4.2 Implementation Models ……………………... ........................................5
III
Chapter1
Database
1.1 Introduction:
In the recent past, a manger of almost any small organization was able to keep
track of necessary data by using a manual file system. Such a file system was
traditionally composed of a collection of file folders; each properly tagged and
kept in a filing cabinet [1].
Organization of the data within the file folders was determined by the data’s
expected use [1].
Ideally, the content of each file folders where logically related. For example,
a file folder in a doctor’s office might contain patient data, one folder for each
patient. All the data in that file older described only that particular patient’s
medical history [1].
As long as a data collection relatively small and an organization’s
mangers had few reporting requirements, the manual system served its role well
as a data repository. However, as organizations grew and as
reporting requirements became more complex, keeping track of data in a manual
file system became more difficult. In fact, finding and using data in growing
collection of file folders became such a time-consuming and cumbersome task
that it became less and less likely that such data would ever generate useful
information [1].
Unfortunately, report generation from a manual file system can be
slow and cumbersome. In fact, some business mangers faced
government-imposed reporting requirements that require weeks of
intensive effort each quarter, even when a well-designed manual system
was used. Consequently, the pressure built design a computer based
system that would track and produce required reports [1].
The problems inherent in file systems make using a database system
very desirably. Unlikely the file system, with its many separate an
unrelated files, the database consists of logically related data stored in a
single data repository. Therefore; the database represents a change in the
way end user data are stored, accessed, and managed. The database
1
management system (DBMS) provides numerous advantages over file system
management, by making it possible to eliminate most of the file system’s data
inconsistency, data dependency, and structural dependency problems [1].
Remember that the DBMS is just one of several crucial components of a
database system [1].
Perhaps it is even appropriate to refer to the DBMS as the database
system’s heart. However, just as it takes more than a heart alone to make a
human being function, it takes more than a DBMS to make a database system
function [1].
Database is a collection of data or information that can be stored, sorted,
organized and retrieved. Your local telephone book, your Rolodex file,
and the card catalog at your local library are all examples of a database.
Traditionally databases are organized by fields, records, and files tables
[1].
A is single piece of information; a record is a one complete set of
fields; a file is a collection of records. For example, a telephone book is
analogous to a file. It contains a list of records, each of which consists of three
fields: name, address, and telephone number [1].
To access information form a database, you need a database
management system (DBMS). This is a collection of programs that
enables you to enter, organize, and select data in a database [1].
2
In effect, the DBMS serves as the intermediary between the user and the
database by translating user requests into the complex code required to fulfill those
requests. The DBMS hides much of the database’s internal complexity from the
application programs that use the database. The application
program might be written by a programmer, using a programming language such as
COBOL, Microsoft Access, and Oracle or it might be created
through a DBMS utility program [1].
3
4
the M:N relationship label for the relationship expressed
by”STUDENT takes COURSE.”
• One-to-one relationship: each record in a table is related to one
record in another table .Dean of the collage us related with collage in 1:1
relationship , each collage has one Dean and each Dean is
managed one Collage.
As seen this relation benefit, but in this project found that making this
relationship between tables will add over head to the system
.therefore; this relation ship not used this project.
5
Chapter 2
Database System
Available space
6
2.2 Features of DBMS [2]:-
• Store, retrieve, and update data.
• Provide integrity services to enforce database control.
• Provide a user accessible catalog of data description.
• Control concurrent processing.
• Support logical transaction.
• Recover from failure.
• Provide security facilities.
• Interface with communication control programs.
• Provide utility service.
Transaction manger
Scheduler
Recovery manger
Cache manger
Database
7
In order to study a concurrent control and recovery, we need to suggest a
model of the internal structure of database system as shown above.
8
Input data from user
Massages
Flowchart (2.2)
9
This project dealing with library management in this project database includes many tables,
these are:
1. Four tables _to save books information, this table is [books, auther,
publisher, and book_auther].
2. One table_ to save the users information and there authorize. this table is[admin].
3. One table_ to save the information about borrower. this table is[borrow].
10
11
Now admin table contains five fields as we show in Fig. (1.2)
Fig. (1.2)
Note that :
GCreateUser ,Gedit and Gadd to add and delete authorize to users
Also Fig. (1.3) a,(1,3)b showing the books and book_auther tables respectively whichs contains details
about books
Fig. (1.3) a
12
Fig (1,3)b
Note that :
This table show the authors' how authoring the book(s) according to
ISBN
The two tables publisher and author contains information about each like Id, name , and phone
Fig (1,4)
13
Fig(1,5)
Finally
we have borrow table which contains information about borrower
id , name , (borrow and retrieve date) , and bookno .
show Fig(1,6)
Fig(1,6)
14
3.2 How communicate with the Database (D.B.) through the
Visual Basic:
There is different type of technique used to make connection between the visual
basic and database (Access), like:
1. DAO
2. ADO
3. RDO
4. OO4O
Where the data base project used is (Microsoft Access) version2003
In this project the technique used is the ADO technique because it is the best.
And the ADO term mean (Active X Data Object).
From this technique the user can access to the data base and control it like (add,
delete, modify …).
So, if the user wants to communicate with data base using the ADO
technique, the following steps must be done (after run the visual basic
program):
• From the (project) list choose the (References).as the shown in the
fig. below:
• The following fig. will appear, and then the user must choose the
(Microsoft Active X Data Objects 2.7), the number not important but the
(2.7) prefer.
Fig. (3.7)
Then, when the user writes the code of the frame that wants to
communicate with data base. The user must define a public variable. The
benefit of this variable is to make connection with specific data base table.
And give to this variable any name, in this project this variable’s name is
(DB).
Then the user must define another variable, the benefit of this variable is (open
table, add record, delete, modify…). And give to this variable any name, in this
project this variable’s name is (RS).
Fig. (3.8)
16
Then , in the frame that want to communicate with data base. The user must
write the following code in the load of this frame:
DB.Provider = "Microsoft.JET.OLEDB.4.0";
Here define the type of the communicate with the base DB.Provider
If the user want to communicate with data base the following code must be used:
Microsoft.JET.OLEDB.4.0
And the provider that can make communicate with data base through it, is the
following:
Also, in this project another method used to make communication with data base.
And this method accomplished through the (Adodc) tool. This tool can be added
by doing the following steps:
17
1.
Fig. (3.9)
2.
Fig. (3.11)
18
3.
Fig. (3.12)
4. the user must type the following code in [load] of the frame which want to
communicate with data base:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
App.Path +"\Data.mdb;Persist Security Info=False"
Adodc1.ConnectionString
Note that the ADODC tools will the information that brings to it, to use this
information in another situation.
19
Chapter 4
System Testing
20
4.1 Testing the program:
Start
No
Show the [Log in] form
Is the table
Fig (2). empty?
No Exit from the [Log in] form _fig(2). Show the main Form. Fig (3).
21
Fig (1).
fig(2).
Fig(3) [ Main form}
22
When the program run, the first form will work is the [create user]
form_ Fig (1). this form make access to the data base to read the content of
the [User]table .the read operation will not read the content of this table,
but the reading operation represent by return the number of the records exist
in this table .
If this number equal to zero: that mean the current user is the first user run this
program. So, this user will access to this program as a manger of the
system. So when the current user enters his information, this information
will save will save in the [user] table and give this user all authorize {the
authorize here is: creating another user, modifying student information, add
student and printing}. After this , the main Form_ Fig(3).will appear ,and
since the current user have all authorize, so all buttons in the main Form_
Fig(3). Will be active.
If the number of records not equal to zero: that mean the current user is not
the first user run this program. So, the [create user] form_ Fig (1).will make
[Login] form _fig(2).running instead of it.
When [Log in] form _fig(2).run it will ask the user to enter user
name and password. so, when this data enter from the user, access
operation to the data base will done, to read the content of the
[user]table(the read operation here is to retrive data, not to return the record
number exist in this table). Then, compare operation will done between the
entering data and the data existing in the [User]table, if matching exist,then
read operation on the user autherize will done,and then main Form_ Fig(3)
will run .according to the user authorize, the buttons in the main Form_
Fig(3) will be active.
23
4.2 Administrator:
When click the Administrator( fig 4 ) button we can create user(s) , user modify and change password
As we show in the following figures 5 , 6 ,7 respectively :
Fig(4)
Fig(5)
24
According to the following flow chart :
4.3 Creating User:
Is the username
Reseved before
No
Yes
Save Save anewdata
the new datain inthe
the Admin
Show
Show the message
error massagetototell the Table
usertell
thatthe
theuser
user name
that the reseved
For another user try with
user name reserved for
another name
another user.try with Flowchart (4.6)
We can also modify the authorized(Add or Delete) , name , and password for any
user in The [Admin] table : show figure ( Fig 5 )
Fig(5)
26
4.4 User Modification:
Is the
Save the data in the No name
[Admin] table change
or not
No
yes
yes
Another option we can change the password for the user see Fig(6)
Fig(6)
Notice that the new password is entered in the [Admin] table as update for
That user .
28
4.5 log in:
To log in a program( if the admin table not empty) the log in form will appear
Fig (7) .
Fig (7)
It work according to (4.8) flow chart
Make check on the user name and password in the [Admin] table
Again return to the main form if you clicked "Add book " the
addbook form will appear see Fig (8),Fig(9)
Fig (8)
We can add the book after entered the information about book, some
information must entered ,and another its optional
Fig (9) 30
4.7 Editing(update,insert,delete) :
Also we can insert, update, search and delete from the books tables
see Fig(10),Fig(11)
Fig(10)
Fig(11)
4.8 Searching:
Show Fig(12)
Fig (12)
32
4.9 Borrowing :
Fig(13)
33
4.10 Retrieving:
Fig (14)
34
4.11 About the program:
Finally
The log out command will logout from a user without exit from
the program , another user can login the program by enter a
user name and password.
The help command will display some help about the program
The exit command will quit from the program
35
4.12 References :