information systems and databases
DESCRIPTION
Notes for the IS&DB topicTRANSCRIPT
Information Systems and
Databases
IPT HSC Topic 2
Databases
Database
★An electronic means to organise raw data
(facts)
★Transaction: an event that generates or
modifies data that is eventually stored in an
information system
Organisation Methods
1. Database a. Flat file
b. Relational
2. Online
a. webpage contents laid out
Flat File Databases
★One file system (one table) ○ eg. contacts, photo app
Relational Database
★More than one file that are related ○ eg. shopping scenario
stock
customer
purchases
suppliers
orders
receiving
Relational Database
Database Design
Stock Purchases Owner Order Supplier Customer
- Item name
- Quantity
- Item name
- Quantity
- Date
- Time
- Total
- Payment method
- First name
- Last name
- DOB
- Street
- Phone number
- Suburb
- Post code
- City
- Business name
- Item name
- Quantity
- Company number
- Phone number
- Address
- Company name
- Phone no.
- Address
- First name
- Last name
- Phone no.
- Street no
- Street name
- Suburb name
- Post code
- City
Schema/Entity-Relationship Diagram
Product
barcode
description
cost
price
image
perishable
Purchase
customer ID
barcode
date
time
total owning
quantity
payment method
Customer
customer ID
f name
s name
mobile
sex
address
entity
transaction entity
Schema/Entity-Relationship Diagram
Supplier
supplier ID
name
contact f name
contact s name
address/suburb
phone number
address
Delivery
supplier ID
barcode
store ID
date
time
store
quantity
Product
barcode
description
price
cost
image
perishable
entity transaction entity
Schema/Entity-Relationship Diagram
Store
store ID
business name
address/suburb
postcode
contact f name
contact s name
phone number
Order
order ID
barcode
supplier ID
store ID
date
time
quantity
Product
barcode
description
cost
price
image
perishable
entity transaction entity
Supplier
supplier ID
name
contact f name
contact s name
address/suburb
postcode
phone number
email address entity
Example 1: School Timetable System
Student
student ID
student f name
student s name
year
dob
student timetable
Timetable
student ID
query results
teacher ID
teacher location
School Admin System
query results
teacher name
teacher location
student ID
student details
entity transaction entity
Admin Staff
teacher name
teacher location
entity
Example 2: Video Store
Member
membership number
member f name
member s name
dob
Borrowing
membership number
movie barcode
date borrowed
time borrowed
return date
EFT card details
PIN
Bank
PIN
EFT card details
transaction
entity transaction entity
Example 3: RTA
Customer
customer f name
customer s name
address/suburb
photograph
Borrowing
membership number
movie barcode
date borrowed
time borrowed
return date
EFT card details
PIN
Bank
PIN
EFT card details
transaction
entity
transaction entity
Schema for Purchasing a Product
Product
barcode
.
.
.
Purchase
customer ID
barcode
date
time
payment type
Customer
customer ID
.
.
.
.
entity transaction entity
PK
PK
PK
PK
Keys
★enable designer to link tables together in a
relational database
○ primary
○ foreign
○ composite
Keys: Primary
★Unique code that identifies each instance of
that entity and/or transaction
○ eg. barcode is the primary key for the product’s table
★ Instance: one set of data recorded for the
entity or transaction
Keys: Foreign
★Code that acts as a link to a primary key in
another table
○ eg. barcode in purchases table
★ It can have duplicates
Keys: Composite
★Primary key that is made up of more than
one field/data item
★One field alone cannot be unique ○ eg. a customer can make a purchase of the same product
several times in a day therefore a primary key for the
purchases table must include the following data items:
customer ID, barcode, date of purchase and time of purchase
Relationships
★one-to-one (1-1)
★one-to-many (1-∞)
★many-to-one (∞-1)
★many-to-many (∞-∞)
Q21 HSC 2002
Location
room number
location
phone extension
Computer
computer number
computer RAM
computer hard disk
room number
entity entity
blue = primary key
red = foreign key
Q21 HSC 2002 b) Identify the data redundancy in Mr. Ferrano’s database and outline the
problems it may cause as the database increases in size. Redundancy is the unnecessary repetition of data within a database. For Mr. Ferrano’s database,
the room number and phone extension are unnecessarily duplicated. As the database increases
in size, the redundant data will take up space in the database and cause longer processing time
thus slowing down the database. If changes were made to the room number or phone extension
then each record containing either the room number or phone extension will need to be edited
individually otherwise inconsistencies will occur.
Q23 HSC 2012 a) Describe TWO problems that could arise from using this flat-file structure
as a database and propose a solution for each.
When an item is searched, not only will the item details be displayed but also the borrower’s details
will be shown. In order to correct this problem, separating the borrower details from the item detail
will rectify the problem. Another problem is that there are two fields relating Item and Borrower
and the borrower’s full name will be displayed in one field. Normalising the database will correct
this problem as it will separate the borrower’s full name into first name and surname.
Q23 HSC 2012 c) A new library has all of its books, periodicals and audio-visual materials
stored in a large automated storage area located under the building.
Recommend and justify the most appropriate way to store each item to
allow for ease of retrieval.
The most appropriate way to store each item for easy retrieval is to organise the item by their item
number. The item number should correspond with details about the item such as item’s location in
the storage area or item size. Also using the ‘number of time borrowed’ field to place the items in
locations that will allow for faster retrieval i.e closer to the retrieval area.
Stages of Normalising
★ 1st Normal Form: ○ separate field with more than one piece of information
★ 2nd Normal Form: ○ remove redundancies by designing a relational schema
★ 3rd Normal Form: ○ add primary and foreign key
★Domain key normal form: ○ add relationship
Q23 HSC 2012
Loan
item number
date borrowed
date returned
borrower ID
number of times
borrowed
Item
item number
item
type
entity transaction
Borrower
borrower ID
borrower f name
borrower s name
entity
PK
FK
FK PK PK
Labelling a Database
field
name
data record/tuple
type: text
length: 30
type: text
length: 6
type: text
length: 25 type: text
length: 15
type:
date/time
length: 6
type:
date/time
length: 6
type:
number
length: 2
Defining Fields
1. name
2. datatype: text, data/time, number, object,
boolean (yes/no)
3. length
Data Dictionary
Field Data type Length Description
Student ID Text 8 Student’s ID
Student first name Text 30 First name of student
Student last name Text 30 Last name of student
Female Boolean 1 If student is female
Year Number 4 Year student is enrolled in
DOB Date/time 6 Student’s date of birth
Family ID Text 8 Family ID of student
Eg. Student: Data Dictionary
A model that defines each data element that will be stored in the database. It is presented in tabular
form and specifies the name of the data element (field), its data type, length and a description of the
type of data that will be entered into that field.
Calculate the size of a database
★500 loans
○ 1. size: calculate the size of 1 record
30 + 6 + 25 + 15 + 6 + 6 + 2
= 90
○ 2. multiply size of 1 record by number of records
90 x 500
= 45 000 bytes/1024
= approx 45 bytes
Important note!
Foreign and primary keys that link
together in a relationship MUST
be defined in the SAME way:
both the data type and length are
the same
Loan
item number
date borrowed
date returned
borrower ID
number of times
borrowed
Vehicle
Rego ID
Description
Cylinder
Capacity
Year
CTP Insurer
Owner
Owner ID
borrower f name
borrower s name
Querying Databases
★Data Independence: where data in
database is stored separately from the
system managing the data (DBMS)!!!
Querying Databases
★Query: a question to the database ○ eg.
1. Which customers live in the St. George area?
2. Which customers in the St George area make
purchases over >$100?
Querying Databases
★A query is construct that draws out relevant
information from a database. It comprises of
4 key words (syntax)
SQL - Structured Query Language
SELECT: lists the fields to extract from the
database
FROM: lists the table names
WHERE: specify the criteria
ORDER BY: sort the list
Structured Query Language
1. Which customers live in the St. George area?
SELECT customer.Firstname,
customer.Surname
FROM CUSTOMER
WHERE customer.suburb=“Hurstville”
ORDER BY customer.surname ASC DSC
Structured Query Language
2. Which customers in the St George area make
purchases over >$100?
SELECT customer.firstname, customer.surname,
SUM(purchases.price)
FROM PURCHASES, CUSTOMER
WHERE customers.suburb=“Hurstville” AND
SUM(purchase.price)>100
ORDER BY SUM(purchases.price)DESC,
customer.surname
Set 2G - Question 12
a) Return all customers who live in NSW sorted on their last name
SELECT Customers.FirstName,
Customers.LastName
FROM Customers
WHERE customer.Town= “Frogtown”
ORDER BY customer.surname DSC
Set 2G - Question 12
b) Return the number of different products for each unique order number
SELECT Products.ProductID, InvoiceProducts.Units
FROM Products, InvoiceProducts
WHERE Products.ProductID= “ ”
SUM(InvoiceProducts.Units, Products.ProductID)
ORDER BY Products.ProductID DSC
SQL - WHERE
★LIKE
★BEGINS WITH
★CONTAINS
Wildcards ★* - any characters, any number of characters
○ surname=“P*” - a surname beginning with P with any
number of characters following.
★? - any character, only 1 character ○ surname=“Riz??” - surnames beginning with Riz and
ending in 1 or 2 more characters.
○ postcode BEGINS WITH “20”
= “20??” - postcode beginning with 20 and ending in
2 more characters (digits)
Comparative / Logic Operators in SQL
Comparative Operators
> greater than
< less than
= equal or identical to
>= greater or and equal to
<= less than or equal to
eg. price >=100
Logic Operators
AND
NOT
OR
SQL Example: All clients living in St George
SELECT client.surname, client.firstname,
client.street, client.suburb, client.postcode
FROM client
WHERE client.postcode=“22??” AND
client.age>=18 AND client.age<=30
ORDER BY client.surname
Data Independence
Views of a Database ★ Different roles in an organisation use the
database in different ways that suit their
responsibilities
○ eg. secretary
■ data entry of resources/products,
clients
■ modification of data to reflect change
of details
○ manager
■ salary details of employees
■ same access as secretary
Authentication Procedures
★ Authentication procedures determine the exact user and
their related access levels to the system
○ People with less access have Read + Execute
access.
○ People with slightly higher levels are able to Edit,
Add new, Read + Execute
○ People with maximum levels can Delete, Edit, Add
new, Read + Execute