0% found this document useful (0 votes)
6 views

Databases Student

This document provides an overview of databases, including their definition, advantages, and characteristics. It explains the structure of relational databases, the importance of primary and foreign keys, and the types of relationships between tables. Additionally, it discusses data types, database management systems, and the significance of minimizing data redundancy and ensuring data consistency.

Uploaded by

nowyfernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Databases Student

This document provides an overview of databases, including their definition, advantages, and characteristics. It explains the structure of relational databases, the importance of primary and foreign keys, and the types of relationships between tables. Additionally, it discusses data types, database management systems, and the significance of minimizing data redundancy and ensuring data consistency.

Uploaded by

nowyfernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Database

In this chapter you will learn;

 Definition of database

 Advantages of using a database

 Special characteristics of a database

 Using fields to create tables

 Identifying key fields

 Relational databases

 Relationships between tables

 Using queries to get data

 Using data forms

 Using reports to furnish information


Databases

In our day today life we come across large amount of data. And larger the data the ability to
remember and easily use them can be challenging, difficult and also time consuming.

....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................

What is a database?

....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................

Examples: Phone book, Student Database

Page | 2 Udula Priyankara 076 976 4532


Advantages of Electronic Database

 ....................................................................................................................................................

 ....................................................................................................................................................

 ....................................................................................................................................................

 ....................................................................................................................................................

 ....................................................................................................................................................

 ....................................................................................................................................................
- Changes to the database can be performed without having to change application
software.

Qualities of databases (Features)

1. Low redundancy of data

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

For example, if you have a Person table which includes Address as one of its data items and you
store the details of a number of people living at the same address, you will have that address
multiple times in your database.

Office Contact

ID Name Department Telephone House_No Street City Province


001 Jake HR 119 23 Guththila RD Panadra Kalutara
002 Amy Marketing 118 42/2 Udawatta RD Panadura Kalutara
003 Sudath Finance 117 50 Vijaya Street Gampaha Gampaha
004 Amara HR 989 23 Guththila RD Panadra Kalutara
005 Roy IT 911 23 Guththila RD Panadra Kalutara

As you can see on the above table same address has been repeated for the 3 brothers from same
house. This is data redundancy. To minimize this tables with related fields can be used.

Page | 3 Udula Priyankara 076 976 4532


Office Contact
ID Name Department Telephone Address-no
001 Jake HR 119 111
002 Amy Marketing 118 112
003 Sudath Finance 117 113
004 Amara HR 989 111
005 Roy IT 911 111

Address List
Address_no House_No Street City Province
111 23 Guththila RD Panadura Kalutara
112 42/2 Udawatta RD Panadura Kalutara
113 50 Vijaya Street Gampaha Gampaha

With the new relational database you can make relationships between tables by using reference
fields. And reduce data redundancy.

2. Data consistency
Data consistency means that the given data should be within the parameters of the database
structures. So same data stored in different tables can be related easily and they will be exactly
the same in all locations. Data consistency is easy to maintain when data redundancy is low.

3. Increases efficiency

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

In above situation if you want to change the “Guththila RD” to Guththila road” you only have to
change Address list. This leads to efficiency.

4. Increase accuracy

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

In the above example if more tables had to change in order to correct “Guththila RD” to Guththila
road” and a mistake occurs that will cause data inaccuracy.
..............................................................................................................................................................
..............................................................................................................................................................
Page | 4 Udula Priyankara 076 976 4532
..............................................................................................................................................................
..............................................................................................................................................................

5. Increase validity

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

Example
If you need a field to enter phone number. You can set that field to have 10 numbers. No less
no more.

6. Security

..............................................................................................................................................................
..............................................................................................................................................................

Encryption – ...............................................................................................................................
...............................................................................................................................

Page | 5 Udula Priyankara 076 976 4532


Computer based databases (electronic) VS Manual databases

Manual database Electronic database


Difficult to ensure data redundancy

Lower data consistency

Lower accuracy due to human errors

Difficult to validate because of human errors

Difficult to change the order of data entry

Difficult to update data

More physical space need to store data

More man power is required.

Difficult to delete unnecessary data

Page | 6 Udula Priyankara 076 976 4532


Relational Database

Parts of database can be divide as records, fields and tables.


Record ............................................................................................................................................
............................................................................................................................................

Field ............................................................................................................................................
............................................................................................................................................

Table ............................................................................................................................................
............................................................................................................................................
Ex - student table contains records related to students while teacher table contains records
related to teachers.

Database ............................................................................................................................................
............................................................................................................................................

Relational database is built step by step as; a collection of fields makes a record and collection of
records makes a table. And a collection of tables makes a relational database.

Example

Page | 7 Udula Priyankara 076 976 4532


Primary Key

....................................................................................................................................................................
....................................................................................................................................................................

Example  “Student ID No” field holds data which are unique to all students. These data are not
repetitive data.

Features of Primary key

 ..........................................................................................................

 ..........................................................................................................

Example

Composite Primary Key

....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................

When the primary key is consist of two or more fields it is called composite key.

Page | 8 Udula Priyankara 076 976 4532


Foreign Key

....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................

 Build a relationship between tables.


 Primary key of one table is foreign key of another table.

Data Duplication

....................................................................................................................................................................
....................................................................................................................................................................

Lyceum – First Term


Student No Name Date of Birth Marks Terms Year
001 Mahesh Senanayake 1992/02/01 99 1 2010
002 Senaka Bibile 1992/03/23 78 1 2010
003 Joshep Jones 1992/08/05 86 1 2010

Page | 9 Udula Priyankara 076 976 4532


Lyceum – Second Term
Student No Name Date of Birth Marks Terms Year
001 Mahesh Senanayake 1992/02/01 99 1 2010
002 Senaka Bibile 1992/03/23 78 1 2010
003 Joshep Jones 1992/08/05 86 1 2010
001 Mahesh Senanayake 1992/02/01 92 2 2010
002 Senaka Bibile 1992/03/23 82 2 2010
003 Joshep Jones 1992/08/05 56 2 2010

Disadvantages of data duplication

1. ..................................................................................................................................
2. ..................................................................................................................................
3. ..................................................................................................................................
- If you are entering the marks of the 3rd term then you will have to insert the same data
such as name, admission number and DOB. This reduce the efficiency.

4. ..................................................................................................................................
- When entering the same data again and again mistakes can occur. Ex: Senaka Bibile.

5. ..................................................................................................................................
- Since same data has to repeat again and again.

6. ..................................................................................................................................
- Might delete the wrong record. Since there are many records which looks like the same.

7. ..................................................................................................................................
- As there are several records need to be updated for same person.

These problems are occurred as a reason of data duplication and they can be minimized using breaking these
data into few other tables. Let’s break them in to a student information table and a result table.

Student information table


StudentNo Name Date of birth
001 Mahesh Senanayake 1992/02/01
002 Senaka Bibile 1992/03/23
003 Joshep Jones 1992/08/05

Marks table
StudentNo Marks Terms Year
001 99 1 2010
002 78 1 2010
003 86 1 2010
001 92 2 2010
002 82 2 2010
003 56 2 2010

Page | 10 Udula Priyankara 076 976 4532


Here by using the Student No as the primary key we are able to create two tables with minimum data
redundancy.

Creating Databases

Data types used in databases

 Integers : plus or minus whole numbers


 Real : Plus or minus numbers with Decimal numbers.
 Text : Letters, numbers, symbols and special characters.
 Currency : used to enter monetary values.
 Date/ Times : enter dates and times.
 Boolean : True or False Boolean values.

Exercise 01
Find the suitable data types for the fields,

Field Data type


Employee No
Employee name
Department name
Salary
Dependent
Address
Date of join

Database Management Software

A database management system (DBMS) is system software for creating and managing databases. DBMS
enables you to store, modify, and extract information from a database.

Example of DBMS

Software Build by
Access Microsoft Company
Base Document Foundation
Oracle Oracle Cooperation

Page | 11 Udula Priyankara 076 976 4532


Database’s relationship types,
There are 3 relationship types,

1. ...................................................................................

2. ...................................................................................

3. ...................................................................................

1. One-to-One Relationships

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

Student table Marks table


1
Student name Admission number
First name Exam
Last name Marks
1
Admission number

2. One-to-Many (or Many-to-One) Relationship

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................

Features of One-to-Many relationship

Table A Table B (Related table)


A record in Table A can be related to A record in Table B can be related to
several records in Table B. only one record in Table A.
There can be records which are not There cannot be records which are not
related to records of Table B. related to records of Table A.
Data in the column which includes the Data in the column which includes the
primary key cannot duplicate. foreign key can duplicate.
Having a record in Table B related to a It is mandatory to have at least one row in
record in Table A is not mandatory. Table A which is related to Table B.

Page | 12 Udula Priyankara 076 976 4532


If you look at the following table you can see that same student has done multiple payments yet one payment
receipt no is given to one student only.

So that relationship can be shown as followed.

Student Facility Fees


1
Admission_Number Receipt_Number
Name Payment_Date
Date_of_Birth Fees
∞ Admission_Number

Student table

Admission No Name Date of Birth

Facility Fees

Receipt_Number Payment_Date Fees Admission No

3. Many-to-Many Relationship

..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
In a many-to-many relationship, a row in table A can have many matching rows in table B, and row of
table “B” can have many matching rows in table “A”.

Page | 13 Udula Priyankara 076 976 4532


If we take the Student table and Sports table. They have a Many-to-Many relationship. Which means one
student can play many sports and same sport can be played by many students.

Student Table
Sports Table

In related databases. To create a Many-to-Many relationship between data. Both tables are converted in
to One-to-Many relationship type tables and another table with foreign keys from both tables are added
to create the Many-to-Many relationship.

Student Table

Students Sports Table

Sports Table

Page | 14 Udula Priyankara 076 976 4532


As yoou can see. The primary key of Student table (Admission_No) is a foreign key of Student Sport table
(3rd table) and also the primary key of Sport table (Sport_No) is also a foreign key of Student Sport table.
Thus creating a Many-to-Many relationship between Student table and Sport table.

Student table

Admission No Name Date of Birth

Student Sport Table

Admission No Sport No Team

Sport table

Sport No Sport Number of permanent members

Page | 15 Udula Priyankara 076 976 4532

You might also like