Today We Are Going To Learn ;
1. What is a Database & DBMS.
2. The Advantages of Using a Database.
3. Special Characteristics Of a Database.
4. Most Commonly Used DBMS software.
5. Creating a Table and Using Fields.
6. Identifying Key Fields.
7. Relational Data Bases.
8. Relationships between tables.
9. Using Queries to get Data.
10.Using Data forms.
11.Using Reports to furnish information.
WHAT IS A DATABASE AND DBMS ?
The collection of all inter related information about an organization , etc… which is used to ensure its
efficiency and smooth functioning can be called database. Simply, a database is an
organized collection of data.
It is more than a simple table. A database can give a use true command of the data included allowing the
user to do various actions like , analyzing , retrieving , sorting and summarizing .
We can either manually maintain data organizing them in text written by hand which is known as manual
database or we can maintain the data on Electronic medium where we use a Database Management System
or Software(DBMS) is known as Electronic Database.
Thus a DBMS can be defined as a program which manages databases easily , efficiently , and accurately.
Advantages of Databases
More efficient in retrieving information
Required information can found out very quickly, data is properly organized.
Easy to obtain Copies.
Smaller physical space to store data.
Data analysis can be carried out efficiently.
Only necessary data can be selected and processed.
Data can be shared.
Independence of data.
Though databases & software are connected , database tables can be updated without
changes to the application software.
FEATURES OF a DATA
• BASE.
Reduce Data Redundancy.
IT reduces duplication of data.
• Data Consistency.
By minimizing data redundancy , the same data being saved in various tables can be reduced
or prevented. This enables maintenance of data consistency.
• Increases Efficiency.
Efficiency of databases are higher as they are well organized.
• Increases Accuracy.
Since data redundancy can be minimized in a database , data consistency is maintained. This
increase accuracy.
• Increases Validity.
Properties of fields can be assigned when a database is planned. Validity can be checked at the
data entry stage. This increases the validity of the database,
• Security.
Unauthorized access can be controlled by using a password or encrypting the data base.
Comparison between Manual and Electronic
Data bases.
Manual Databases Electronic
Databases
Less Efficient More Efficient
Less Accurate More Accurate
Less Credible More Credible
Difficult to analyze Easy to Analyze
Difficult to delete and update Easy to delete and update data
data
More space is needed Less space is needed
More man power is needed Less man power is needed
RELATIONAL DATABASES
• A collection of Fields related to one person or object is called a record.
• A collection of records is called a data table.
A collection of related tables is called a Relational database
Field1 + Field2 + Filed 3….(Fields)
Relational Database
Record Field
Student Name Date of Date of
Number Birth Admission
100 Manoj Dayarathne 2/9/2008 G. Dayarathne
Record1 + Record2 + Record3….(Records)
101 FirosaLai Rafeeqa 4/2/2008 K. Fais
Table Student Book Borrowed Return
Number Number Date Date
Tables
Table1 + Table 2 + Table 3…. (Tables) 101 2222 2/9/2014 16/9/2014
100 3333 3/9/2014 17/9/2014
101 1111 3/9/2014 17/9/2014 Records
Relational Database 100 3333 4/9/2014 18/9/2014
• A Column (or a combination of columns) which enables to
PRIMARY identify a record uniquely is called a PRIMARY KEY
KEYSpecial Attributes.
• Should Not Be empty(Data being there is mandatory)
• No Duplicate Values (Same Values Don’t Exist)
Composite Primary Key • The Primary Key which consists of two or more
columns of a table uniquely identifies a record is
called Composite Primary Key.
Foreign KEY • If a field (or combination of fields ) of one table can be used to
uniquely identify rows of another table, then this/these filed/s
is/are called the foreign key.
• Builds a connection between two tables.
Special Features. • The related data of the primary key field exist in the other table.
• Foreign key of one table is the primary key of the other table.
EXAMPLES
When considering the tables 9.11
and 9.12, Registration Number is
the primary key of 9.11 - Student
Table where as Registration
Number is the foreign key of 9.12 -
Subject Table. Further, a separate
primary key is available for subject
table and that is candidate number
PRIMARY KEY
For
ei g
nK
ey
Creating A Simple Database Manually.
• You can create a database manually on media such as paper using pen and pencil.
• Mainly Created by drawing tables.
To create any database , specially electronic but also including manual databases, we must know what data
types we must use. Let us learn some Data Types
Numeric: used for calculations. Exists in several forms.
Integer: plus or minus whole numeric figures.
(E.g.: 12, -23)
Real: plus or minus numbers with decimal places. (E.g.: 8.125, -2.64, 4.00)
Text: composed of letters, numbers or special characters (E.g. - %, *, -).
Though numbers are used, it is not used for calculations.
(E.g.: National identity card number –889534731V Telephone number –0112785123, 0112 –
985123)
Currency: used to indicate monetary values.
(E.g.: $12.45, Rs.35.00)
Date / Time: indicates dates and time
(E.g.: 12/23/2013, 7.35 a.m.)
EXAMAPLE
• Data type related to the field should be identified when the table is created.
Field Name Data Type
Accession number of the book Text
Title Text
Author’s Name Text
Price of Book Currency
Number of Books Number
Converting a Manual Database
to an Electronic Medium • Use of DBMS software allows us to
convert the manual database into an
electronic Database
What is A DMBS Software ?
• A collection of objects which Tables
facilitates planning and
maintenance of the database
to the user is called a
Database Management Reports DBM Queries
System (DBMS). This S
consists of several objects
like tables, queries, forms
and reports. Forms
Popular DBMS Software
Software Manufacturing Company
Access Microsoft Company
Base The Document Foundation
Oracle Oracle Cooperation
WE WILL NOW DISCUSS HOW TO USE
DBMS SOFTWARE.
We will be discussing on how to use
Microsoft Office Access and LibreOffice Base.
(Please note that the commands used to run software
can be different according to the operating system.)
Starting DBMS software
Planning a Data Table
Exa
mpl
e
Creating the Primary Key for a Data Table
For LibreOffice Base''''
For Microsoft OfficeAccess'''
Give field name and data type adjust
Give field name and data type → Select the
row/ rows that should be made as Primary key properties → Right click on the line
→ Click on Primary key → save the which contains the field need making
table. primary key → Select Primary key →
save the table.
Ex
a mp
le
Entering Data to the Table
• The table view
should be changed
to input data to a
prepared table.
PLE Enter data into the Library Table as shown
M
EXA
Creating a Relational Database
• Rather than keeping all the data in a single table, it is easier, more efficient
and productive to input, update and delete data if those are recorded
separately in different tables.
Let us study this section well to break a data table into
several simple tables and to build relationships between
these.
• When creating a relational databases, several type of relations can exist among tables .They
are known as ;
1. One-to-one.
2. One-to-many.
3.Many-to-many.
One-to-one Relationship
• If only a row of a table is related to a row of another table, it is called
a one-to-one relationship.
Example
Given below is Table 9.19 which includes the marks students scored of the Grade 5 scholarship
exam. Let us tabulate data in this table
into two tables:
– Student Table and Table 9.19– Scholarship Marks
– Marks Table.
Admission No Name Date of Index No Marks
Birth
1426 Kavindu Prabashwara 2005'05'23 23234 151
1427 Meenadevi Ramanathan 2005'08'12 23876 186
1428 Mohommad Malikkar 2005'02'07 23758 172
1429 Rashmi Janodara 2005'06'16 23765 193
Student Table Marks Table
• A record of the Marks Table is related to only one record of the Student Table. A record of the
Student Table is related to only one record of the Marks Table as well.
•
• The primary key of the Student Table is the Admission Number and it is the foreign key of the
Marks Table. The Primary key of the Marks Table is the Index Number. The relationship built
between these two tables through the foreign key is one-to-one.
An arrow is drawn from the foreign key to the primary key
to indicate the relationship.
One-to-many Relationship
• If each record of a table is related to several records of the other table, this is called a one-to-many relationship.
FEATURES OF A One-to-many Relationship
Table A Table B (Related table)
A record in Table A can be A record in Table B can be related
related to to This is how a one too many relationship
will be sown in a DBMS software
several records in Table B. only one record in Table A.
There can be records which are There cannot be records which are
not not
related to records of Table B. related to records of Table A.
Data in the column which Data in the column which includes
includes the the
primary key cannot duplicate. foreign key can duplicate.
Having a record in Table B It is mandatory to have at least one
related to a row
record in Table A is not in Table A which is related to Table
mandatory. B.
Many-to-many Relationship
• If a record of a table is related to several records of another table and if a record
of that related table is related to several records of the other table, there is a many-
to-many relationship between those two tables.
Representing two tables with many-to-many
relationships as two one-to-many relationship
Thus,
• There is a one-to-many relationship between the Student Table and the Students Sports Table.
• There is a one-to-many relationship between Sports Table and Students Sports Table.
• Hence, by using an extra table, many-to-many relationships can be converted to one-to-many relationships.
Creating a Relational Database Using Database
Management System Software
Build up relationship between tables
SPECIAL FEATURES IN REALATED TABLES
As soon as the values of a primary key field of the Student Table are updated using
'Referential Integrity,' the foreign key field values of the related table are automatically
changed.
Further, when a record of the Student Table is deleted, the related records of the related
table are automatically deleted.
First, data should be entered to the student Table. After that, data can be entered to the
Marks Table.
After entering the marks to the Student Table, data can be entered to the Marks Table
through it.
For this, click on the + mark which is in front of the Admission Number of the Student
Table. Then data can be entered to Marks Table easily.
Creating Forms to Entering and Displaying Data
Forms are used to enter data to a table in Database Management Systems. Further, forms are used
to display entered data as well.
Building a Data FormBuilding a Data Form
For Mi crosoft Offi ce Access '''
Create → Form Design → Add Existing Fields → Show tables → Select the required
table → Drag table fields to the form (Refer Figure 9.21)
Showing Table Records in Data Form
Showing Table Records in Data Form
For Microsoft Office Access '''
Home Tab → View → Form View (Refer Figure 9.22)
(Refer Picture Below)
Entering
3' Entering Control Wizards to a Wizards
Control Form to a Form
For Microsoft Office Access '''
Design Tab → Select 'Control Wizards' (Refer Figure 9.23) → Select the button indicated as
XXXX → Establish the button in data form → Select Record Operation in Command Button
Wizard (Refer Figure 9.24) → Select the Action which should be entered (E.g.: Add New
Record) → Give a proper name to the button → Finish
Designing Query to Get Information
• Let us use a query to obtain necessary information from the data of related
tables
Designing a Query given below is the information received after running the
query.
Designing Reports to Present Information
Reports are used to obtain printed copies of important information received from the
data of related tables. Both tables and queries can be used to design reports.
Report Wizard can be used to design reports.
For Microsoft Office Access...
Create Tab → Report Wizard → Select the necessary table or query (Refer Figure 9.34) → The Report
Select the fields needed for the report from the table or query → Design the report as you
need clicking Next button → Finish. Then you will get a report as shown in Figure 9.35.
Printing the Report
Change the 'Report View' to 'Print Preview'. -> Click on the tool shown below to print the number of copies you
need.
THANK YOU FOR
WATCHING…!