Databases
Databases
Chapter 18
What is a Database?
• A Database is an organized collection of data.
• A Database program is a software which stores and retrieves data
in a structured way.
• Databases store data using a system of files, records and fields.
• A field is a single item of data, such as firstname or date of birth.
• Each field could have a particular type of data for example
firstname would be text, Candidate number could have numbers
and date of birth could be date.
• A record is a collection of fields, for example all information for a
person. It may contain different data types.
What is a Database?
• A file is an organised collection of records, where all records are
oraganised together. A file could have more than one tables.
• There are two types of Databases: Flat-file databases & Relational
databases.
• A Flat-file database stores its data in one table which is organised by
rows and columns(fields). Each field has a data type.
What is a Relational Database?
• A Relational databases stores data in more than one linked
tables in a file.
• Relational databases are designed so as to avoid storing of
data many times.
• Most tables will have a primary key field that holds unique
data (no two records are the same in this field) and is the
field used to identify that record.
• A foreign key in one table will point to a primary key in
another table. Some tables will have one or more foreign key
fields.
• A foreign key is generally created to form relations(links)
between tables.
Flat file database
Relational file database
Why use a Relational Database?
• Storage space is saved by not storing data more than once.
• It is also much easier for users to produce reports from a relational database.
where data is held in two or more tables, than from two or more flat-file databases