DATABASES
AND SQL
BY ALICIA AND MICHEAL
WHAT IS A DATABASE
A database is made
A database is useful
up of either one or
It allows easy when working with
A Database is an multiple tables which
storage, retrieval, large amounts of
organised collection are made up of fields
and management of data, databases are
of data and records to
information stored on secondary
organise how it
storage
stores data
A database is often
stored on remote Data can be sorted
servers so multiple and searched
They are more secure
users can access it at efficiently, making
than text files
the same time, use of more
useful for online advanced structures
systems
FIELDS AND
RECORDS
• A field is one piece of information
relating to one person, item or object
• A field is represented in a database by a
column,
• A record is a collection of fields relating
to one person, item or object
• A record is represented in a database by
a row
TEXT FILES
• A text file is useful when working with small
amounts of data, text files are stored on
secondary storage and 'read' into a program
when being used
• They are used to store information when the
application is closed
• Each entry is stored on a new line or
separated with a special identifier, for
example, a comma (',')
• It can be difficult in text files to know where
a record begins and ends
VALIDATION
• When a table is created, validation rules
can be assigned to the different fields
• A validation rule controls what data can
be entered into that field
• There are different types of validation
checks used to limit what data can be
entered into each field
• The validation checks that are used are
the same as those that appear in section
7: Algorithm Design & Problem-Solving
VALIDATION
CHECKS
EXAMPLES
DATA TYPES
A data type is the
type of data that
Examples of
What is a data can be held in a Integer - whole Real - decimal
common
type? field and is defined number number
datatypes are:
when designing a
table
In the table cars
below, the
Text/alphanumeric Boolean - true or
Character - single Date/Time following
- text data false values
datatypes would
be used:
make: model: colour:
car_id: integer price: rea
text/alphanumeric text/alphanumeric text/alphanumeric
PRIMARY KEYS
• A primary key is a unique field that can be used to identify
a record in a table
• customer_id is the primary key for the customers table
below
• Other examples of primary keys in database tables would
include:
• Student_ID in a school database
• Car_Registration in a car database
• Product_ID in a shop database
SQL
• SQL (Structured Query Language) is a
programming language used to interact with a
DBMS.
• The use of SQL allows a user to:
• Select data
• Order data
• Sum data
• Count data
SELECTING
COMMANDS
EXAMPLES
THE END