Databases Student
Databases Student
Definition of database
Relational 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?
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
- Changes to the database can be performed without having to change application
software.
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
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
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.
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 – ...............................................................................................................................
...............................................................................................................................
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
....................................................................................................................................................................
....................................................................................................................................................................
Example “Student ID No” field holds data which are unique to all students. These data are not
repetitive data.
..........................................................................................................
..........................................................................................................
Example
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
When the primary key is consist of two or more fields it is called composite key.
....................................................................................................................................................................
....................................................................................................................................................................
....................................................................................................................................................................
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.
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
Creating Databases
Exercise 01
Find the suitable data types for the fields,
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
1. ...................................................................................
2. ...................................................................................
3. ...................................................................................
1. One-to-One Relationships
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
..............................................................................................................................................................
Student table
Facility Fees
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”.
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
Sports Table
Student table
Sport table