You are on page 1of 15

DATABASES

DATABASES

■ Databases
■ Tables
■ Records
■ Fields
■ Data Types
■ Primary Key
■ Foreign Key
■ Flat Files Vs Relational Databases
■ Advantages and disadvantages of databases
■ When not to use a relational database
DATABASES

■ DEFINITION : Collection of data or information held together in an organised way.


■ Eg: School Register, Hospital records, Library management systems
TABLES

■ Databases store information in tables


■ A table is a collection of related information stored in rows and columns
■ Rows are called as records
■ Columns are called as fields
Student Table

Student ID Name Grade


1 Mark 9
2 Mary 7
3 John 8
RECORD

■ Definition : A record is all of the information about a single entity or thing


■ Eg: Details about a particular student, book details about a specific book, information
about a particular course

Book ID Book Name Author Publisher Category


1 The Herge Egmont Comics
Adventures of Publishers
Tintin –The
Shooting Star
FIELD

■ Definition : A field is one piece of information about an entity or thing.


■ Eg: Last Name, Phone number of customers, Date of Birth of students.
DATA TYPES

■ Data Type- Type of data stored

Type Example
Alphanumeric or text Names, Car numbers, Address
Smith, MH 02 A 2035, 21 Main Street
Number Marks, Average
82, 87.3
Currency Book Cost, Profit
$30, ₤ 10
Date/Time Date of Birth, Expiry Date
21/09/02, 31- March- 18
Autonumber IDs, Serial Number
Logical or Boolean or Yes/No Received, In-Stock
Y/N or 0/1
PRIMARY KEY

■ Definition : A column that uniquely identifies a row in a table.


■ Eg: Student ID, ISBN Number, Social Security number
■ A primary key is unique in a table
■ A primary key cannot be blank
FOREIGN KEY

■ Definition : A field in one table that is a primary key in another table

Patient Table

Patient ID Name DoctorID Date of Medical Additional


Visit Record ID Info
P2304 ABC 1 21-01-18 MR23
P5230 XYZ 6 17-08-17 MR32
FLAT File Vs. Relational Databases

Flat File Databases Relational Databases


All information in single table Information is split into different tables
Tables are joined by foreign keys

Advantages of Relational Databases


Information is not duplicated
Information can be searched easily
Complex searches and reports can be done
Less prone to errors while maintaining the database
ADVANTAGES OF DATABASES

■ Large amounts of data stored easily


■ Quick to search and retrieve information
■ Easy to maintain information
■ Easy to sort data
■ Data can be transferred to other forms easily
■ More than one person can view the same information at the same time
■ Data can be secured better
DISADVANTAGES OF DATABASES

■ Complexity of the system


■ Cost of buying hardware/software , maintaining databases
■ Recruiting special personnel like DBA, designers, developers
When not to use a Relational Database

■ Simple applications that do not change much over time


■ Multi-user access is not required
■ Cost of installing, maintaining is too high compared to benefits
Summary – Syllabus Objectives Met

■ define the terms flat-file database and relational database


■ explain where it would be appropriate to select a flat-file database or a relational database
■ assign appropriate data types to fields, including: text, numeric, (integer, decimal,
percentage, currency), date/time, Boolean/logical (–1/0, yes/no, true/false)
■ define and understand the terms primary key and foreign key and their role in a relational
database
■ discuss the advantages and disadvantages of using relational tables rather than a flat file
database
■ https://www.bbc.com/education/guides/z8yg87h/revision/1
Summary – Syllabus Objectives Met

■ explain that other field types like placeholders for media, including images, sound-bites
and video clips are used in commercial databases
■ use short, meaningful file and field names
■ format fields and identify sub-types, including: specifying the number of decimal
places, specifying a particular currency
■ identify the structure of external data with different file types, including: .csv, .txt, .rtf
■ locate, open and import data from an existing file
■ create a relationship between two or three tables

You might also like