Database Systems
Database Systems
What is a Database?
• “A set of information held in a
computer”
Oxford English Dictionary
• “One or more large structured sets of
persistent data, usually associated with
software to update and query the data”
Free On-Line Dictionary of Computing
• “A collection of data arranged for ease
and speed of search and retrieval”
Dictionary.com
Databases
• Web indexes • Train timetables
• Library catalogues • Airline bookings
• Medical records • Credit card details
• Bank accounts • Student records
• Stock control • Customer histories
• Personnel systems • Stock market prices
• Product catalogues • Discussion boards
• Telephone directories • and so on…
File System vs Database
Systems
Database Systems
• A database system • Database systems
consists of allow users to
• Data (the database) • Store
• Software • Update
• Hardware • Retrieve
• Users • Organise
• We focus mainly on • Protect
the software their data.
Database Users
• End users • Database
• Use the database Administrator (DBA)
system to achieve • Designs & manages
some goal the database system
• Application • Database systems
developers programmer
• Write software to • Writes the database
allow end users to software itself
interface with the
database system
Database Management
Systems
• A database is a • Examples:
collection of • Oracle
information • DB2 (IBM)
• A database • MS SQL Server
management system • MS Access
(DBMS) is the • Ingres
software than • PostgreSQL
controls that • MySQL
information
What the DBMS does
• Provides users with • DBMS provides
• Data definition • Persistence
language (DDL) • Concurrency
• Data manipulation • Integrity
language (DML) • Security
• Data control language • Data independence
(DCL)
• Data Dictionary
• Often these are all
• Describes the
the same language database itself
Data Dictionary - Metadata
• The dictionary or • The dictionary holds
catalog stores • Descriptions of
information about database objects
the database itself (tables, users, rules,
views, indexes,…)
• This is data about • Information about
data or ‘metadata’ who is using which
• Almost every aspect data (locks)
of the DBMS uses • Schemas and
mappings
the dictionary
File Based Systems
• File based systems • Problems:
• Data is stored in files • No standards
• Each file has a specific • Data duplication
format • Data dependence
• Programs that use • No way to generate
these files depend on ad hoc queries
knowledge about that • No provision for
format security, recovery,
concurrency, etc.
Relational Systems
• Problems with early • Then, in 1970,
databases E. F. Codd wrote “A
• Navigating the Relational Model of
records requires Data for Large
complex programs Shared Databanks”
• There is minimal data and introduced the
independence
relational model
• No theoretical
foundations
Relational Systems
• Information is stored • The relational model
as tuples or records covers 3 areas:
in relations or tables • Data structure
• There is a sound • Data integrity
mathematical theory • Data manipulation
of relations
• Most modern DBMS
are based on the
relational model
Database Model
Name
Microsoft Access
19
Microsoft Office
Access 2013
Table Basics
• A table is a collection
of data about a
specific topic
• The data is organized
into rows and
columns
• Each column is a field
and each row is a
record
20
Microsoft Office
Access 2013
Planning Tables
• A well-planned database • Remember that a table
ensures that data is should store data about
complete, unique and one thing, and only one
accurate thing
• Be sure to have a clear
picture of how the
database will be used
• Begin by listing the data
you want to capture
– The subject matter
categories that are
generated in your list will
become the tables
21
Microsoft Office
Access 2013
Planning Fields
• Use the smallest fields that
make sense – this allows
you great flexibility for
sorting and searching the
data
• Remember that it is easier
to build in flexibility during
the design stage than it is to
redesign tables after records
have been added or queries
and reports have been
created based on table data
22
Microsoft Office
Access 2013
23
Microsoft Office
Access 2013
24
Microsoft Office
Access 2013
Data Types
• The properties of a field describe the characteristics and
behavior of the data entered into that field
• A field’s data type determines the type of data the field
can store
• A field can contain only type of data
• You set the data type for a field in Table Design view
25
Microsoft Office
Access 2013
26
Microsoft Office
Access 2013
27
Microsoft Office
Access 2013
28
Microsoft Office
Access 2013
29
Microsoft Office
Access 2013
30
Microsoft Office
Access 2013
31
Microsoft Office
Access 2013
Table Views
• Datasheet view – used primarily for working with table
data (although you can create tables in Datasheet view).
This is the “open” view for a table
• Design view – used to create, view or edit a table’s
structure. You cannot see the data in Design view.
32
Microsoft Office
Access 2013
33
Microsoft Office
Access 2013
34
Microsoft Office
Access 2013
Primary Keys
• A primary key is a field (or combination of fields) that
uniquely identifies each record stored in a table
• No two records in a table may be exact duplicates – two
records may, however, contain duplicate data other than
the primary key
• Primary key must be unique
• Primary key cannot contain a null value
35
Microsoft Office
Access 2013
36
Microsoft Office
Access 2013
Importing Data
• You can import data to: • You can import data from:
– A new table – Access databases
– An existing table – SQL Server databases
– A linked table – Excel spreadsheets
– Text files
– XML files
– HTML documents
– Outlook folders
– SharePoint lists
37
Microsoft Office
Access 2013
38
Microsoft Office
Access 2013
39
Microsoft Office
Access 2013
40
Microsoft Office
Access 2013
41
Microsoft Office
Access 2013
42
Microsoft Office
Access 2013
43
Microsoft Office
Access 2013
44
Microsoft Office
Access 2013
45
Microsoft Office
Access 2013
Table Relationships
• A column in a table
that references the
primary key of
another table is
called a foreign key
• Foreign keys and
primary keys
represent data
relationships
46
Microsoft Office
Access 2013
Table Relationships
• A relationship is made by matching data in key fields
between two tables
• When creating relationships, remember:
– Related fields may or may not have the same name but
must have the same data type
– When related fields are Number fields, they must have the
same Field Size property setting
– To define a relationship using an AutoNumber primary key
field, the foreign key must be a Number field with a Field
Size property setting of Long Integer
47
Microsoft Office
Access 2013
Relationship Types
One-to-one A relationship in which each record in Table A can have only
one matching record in Table B, and vice versa.
One-to-many A relationship in which a record in Table A can have many
Parent-child matching records in Table B, but a record in Table B has
only one matching record in Table A. The relationship is
established only if the common field is the primary key in
Table A and the foreign key in Table B.
48
Microsoft Office
Access 2013
49
Microsoft Office
Access 2013
50
Microsoft Office
Access 2013
51
Microsoft Office
Access 2013
52
Microsoft Office
Access 2013
53
Microsoft Office
Access 2013
54
Microsoft Office
Access 2013
Review Questions
1. For a relationship between fields in two tables to be created, the
fields must:
a. have the same data type.
b. have the same name.
c. be stored in separate databases.
d. be defined as lookup fields.
2. Which of the following is the smallest Field Size setting that will
allow a number field to store the value 1,452,137.5?
a. Integer
b. Long Integer
c. Single
d. Double
55
Microsoft Office
Access 2013
Review Questions
3. What is the default Field Size setting for a Short Text field in
Access?
a. 12
b. Single
c. Double
d. 255
4. A primary key:
a. should use social security numbers whenever possible
b. cannot be a composite key.
c. should be null whenever possible.
d. should be a value that will never change.
56
Microsoft Office
Access 2013
Review Questions
5. Kevin needs to update a field in a table that is linked to data in an
Excel workbook. He should:
a. delete the source data file so that it does not interfere with the
linked table.
b. adjust the value directly in the linked table.
c. adjust the value in the source data file.
d. run the linked table update manager.
57