Databases
Databases
One of the main benefits of computer databases is that they make it easy
to store information, so its quick and easy to find.
Databases are also used to store data about weather patterns - which can
then be used with software models to predict future events. Even data
from internet search terms can be useful. For example, the Google
Analytics database helped to successfully predict flu outbreaks around
the world.
Flat-file databases
contact details
product details
When you build a database you are organising data about entities.
An entity is any item that has its attributes stored as data. An entity
could be anything, eg a book, a person, a film, a country or a football
team.
Attributes
Database structure
Table
The table contains all of the fields and the records for one type of entity. A database
may contain more than one table.
Records
Records contain a collection of data for each entity, usually recorded as a row in the
table.
Fields
The column headings are called the fields. Each field contains a different attribute.
For every entity, a unit of data will be entered into each field. Each column might
require different data types. For example, the 'Title' column will require data entered
as text and the 'Certificate' column will need data entered as numbers.
Unit of data
Each individual piece of data entered is a unit of data. These units are also called
data elements.
The primary key contains a unique identifier for each record. To make each record in
a database unique we normally assign them a primary key. Even if a record is
deleted from a database, the primary key will not be used again. The primary key
can be automatically generated and will normally just be a unique number or mix of
numbers and letters.
Data types
The actual units of data that are entered into a database give the attributes for
each entity. These units of data are also called data elements.
When you create a database you need to set data types for each field. For example,
in a film database you might need alphabetical characters for 'Titles', but numbers for
'Duration'. Fields are usually restricted to a certain data type.
Data typing is a way of classifying data values that have common properties.
Different kinds of data values also need different amounts of memory to store them,
and have different operations that can be performed upon them.
floating point numbers (with decimal points, sometimes called real numbers,
or floats), for example: 4.2, 27.4, 56.8
Data structure
The structure of the database is also called the schema or dictionary. When you
design a database you need to create a schema to explain what type of data is being
stored. There are key areas to consider about the data:
Title Text 20 No
Certificate Integer 2 No
Genre Text 20 No
Database integrity
Verification – checks that the data is actually the data you want.
Database fields should have validation rules to make sure the data entered follows
the expected format.
Validation
How it works Example
type
Presence Checks that data has been In most databases a key field
check entered into a field cannot be left blank
Checks that a value has not A primary key value can only be
Duplicate
been repeated entered once
A DBMS needs to use concurrency. However, the database needs to prevent two
people using the data in a conflicting way. For example, two people visiting an online
shop might try to buy the final product in store. The database would need to make
sure only one person could buy it.
ACID rules
Consistency - any change must not break the database. It must be consistent
with how it was before the change.