43
1 Chapter 6: Databases and Data Warehouses Page 219-228 Data Concepts Introduction to MS Access Introduction to Relational Databases

Chapter 6: Databases and Data Warehouses

  • Upload
    rowa

  • View
    53

  • Download
    1

Embed Size (px)

DESCRIPTION

Chapter 6: Databases and Data Warehouses. Page 219-228 Data Concepts Introduction to MS Access Introduction to Relational Databases. Introduction. To retrieve data or information, data must be stored in an organized manner - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 6: Databases and Data Warehouses

1

Chapter 6: Databases and Data Warehouses

Page 219-228Data ConceptsIntroduction to MS AccessIntroduction to Relational Databases

Page 2: Chapter 6: Databases and Data Warehouses

2

Introduction

To retrieve data or information, data must be stored in an organized manner

Meaning data resources must be structured in some logical manner so that– Can be accessed easily– Processed efficiently– Retrieved quickly– Managed effectively

Page 3: Chapter 6: Databases and Data Warehouses
Page 4: Chapter 6: Databases and Data Warehouses

Example: p224

What is the phone number of customer John Smith?

Who is the customer who rented copy number 4780-3?

What is the phone number of the customer who rented ‘The Ring II’?

4

Page 5: Chapter 6: Databases and Data Warehouses

Consequences:

We could ONLY answer the above questions because the data was well organized.

Organization starts with good database design.

Database software make it possible to handle such questions or queries.

5

Page 6: Chapter 6: Databases and Data Warehouses

6

Data Storage Hierarchy:

Data in storage is organized as a hierarchy:– Bits– Bytes– Fields– Records– Files– Database

Page 7: Chapter 6: Databases and Data Warehouses

7

Hardware deals with:

Bit: 0 or 1 Byte: Letter A is represented as:

0100 0001 Bits and bytes are the building blocks for

representing data: whether in processing, storage, or telecommunications

Page 8: Chapter 6: Databases and Data Warehouses

8

Users deals with: (control by SW)

Field: unit of data consisting of one or more characters (bytes). Example:– Your Name– Your Address– Your Student number

Page 9: Chapter 6: Databases and Data Warehouses

9

Users perspective (cont.):

Record: is a collection of related fields Name + Address + Student number Student Record:

– A. B. Buthelezi– J Section– Esikhaweni– 2009012345

Page 10: Chapter 6: Databases and Data Warehouses

10

Users perspective (cont.):

File: is a collection of related records The file of all students, described by their Names

Addresses and Student numbers Database: is an organized collection of

integrated files:– UZ database will contain files on Student records,

Employee records, Payroll data, Financial Records, etc

Page 11: Chapter 6: Databases and Data Warehouses

11

Key Field

A key field: is a field that is chosen to uniquely identify a record so that it can be easily retrieved and processed:

Surname Initials Student#Buthelezi AB 2009012345Buthelezi BA 2009012347

Page 12: Chapter 6: Databases and Data Warehouses

Summary:

Most businesses and organizations rely on information based on data stored in databases

Its critical to access information– Timely– Complete– Accurate– Valid – And relevant

12

Page 13: Chapter 6: Databases and Data Warehouses

Ms Access

Ms Access is DBMS (database management system) that allows you to– Create databases– Add, change and delete data– Sort, filter and search data in database

13

Page 14: Chapter 6: Databases and Data Warehouses

Ms Access

Main elements in Ms Access– Tables

Fields and records– Queries– Forms– Reports

14

Page 15: Chapter 6: Databases and Data Warehouses

Key concepts:

Understand what a db is Difference between data and information How a db is organized Know some uses of large scale db

– Airline booking systems– Government departments– Banks– Hospitals

15

Page 16: Chapter 6: Databases and Data Warehouses

Table

It contains data related to a SINGLE subject Each field contains ONE ELEMENT of data Each field data element is associated with an

APPROPRIATE data TYPE Fields have field properties like

– Size– Format– Default value, etc.

Primary key16

Page 17: Chapter 6: Databases and Data Warehouses

Relationships:

Reason is to minimizing duplication of data Is constructed between two tables by the use of

TWO FIELDS that contain the same data– Have the same field names– Create a link between the tables MATCHING

VALUES 1:1 1:M M:N17

Page 18: Chapter 6: Databases and Data Warehouses

1:1

Each record in the first table have only ONE match in the second table

AND Each record in the second table have only ONE

match in the first table

18

Page 19: Chapter 6: Databases and Data Warehouses

19

Page 20: Chapter 6: Databases and Data Warehouses

1:M

Each record in the first table can have more than one matching record in the second table

AND Each record in the second table have only ONE

match in the first table

20

Page 21: Chapter 6: Databases and Data Warehouses

21

Page 22: Chapter 6: Databases and Data Warehouses

M:N

Each record in the first table have MORE than one match in the second table

AND Each record in the second table have MORE

than one match in the first table

22

Page 23: Chapter 6: Databases and Data Warehouses

23

Example using MS Access:

We like to store data of employees and their insurance detail.

Question: Is there an association between the entities ‘employee’ and ‘insurance’?

Question: What info do we need for employee Question: What info do we need for insurance

Page 24: Chapter 6: Databases and Data Warehouses

Designing: Step 1

Association:– An employee has many insurances– An insurance is taken by an employee

This is a ONE to MANY relationship between employee and insurance

1:M

24

Page 25: Chapter 6: Databases and Data Warehouses

Designing: Step 2

Determine the characteristics of each entity or ATTRIBUTES

What describe an Employee? What describe an Insurance?

25

Page 26: Chapter 6: Databases and Data Warehouses

Designing: Step 3

Assign data types to each characteristics

– Text– Number– Date– Logical– Currency

26

Page 27: Chapter 6: Databases and Data Warehouses

Designing: Step 4

Create a data base SCHEMA representing all the information of the previous steps.

See next slide

27

Page 28: Chapter 6: Databases and Data Warehouses
Page 29: Chapter 6: Databases and Data Warehouses

Relational Model Diagram:

Page 30: Chapter 6: Databases and Data Warehouses

Designing: Step 5

Represent Step 4 with a MS Visio diagram A model must be presented graphical

because it– Emphasizes understanding– Communication tool

30

Page 31: Chapter 6: Databases and Data Warehouses

31

Employee:

Surname Salary What about a key field? Staff number Employee record:

– Jones– R100 000– 101

Page 32: Chapter 6: Databases and Data Warehouses

32

Insurance:

Insurance Company (Can companies have the same name?) How to identify a company?

Who are they insuring? Employee ID The amount Insurance record:

– Company code– Company name– Employee ID– Amount

Page 33: Chapter 6: Databases and Data Warehouses

33

Joining Files/Tables:

Why?– What is the address of AB Buthelezi, who was

insured by the company Six Feet Under Relational DB:

– More than one table are used AND each table contains data about one ASPECT

– Tables are connected: the UNIQUE field of one table will appear in the other

Page 34: Chapter 6: Databases and Data Warehouses

34

MS Access:

Create a database: human_resource SAVE it in the C-Drive Create Table: employee using the ‘Design View’Emp_surname as TextEmp_salary as CurrencyEmp_number as Number Key Field?????

Page 35: Chapter 6: Databases and Data Warehouses

35

Enter Data:

Enter data by ‘Double-Clicking’ on table Employee

Use the tab key to move between fields Data:

– Ndlovu, 100000, 101– Mfeka, 110000, 102– Ngubane, 120000, 103

Page 36: Chapter 6: Databases and Data Warehouses

36

Table ‘Insurance’

Create Table: insurance using the ‘Design View’Ins_code as NumberIns_name as TextIns_amount as CurrencyEmp_number as Number

Page 37: Chapter 6: Databases and Data Warehouses

37

Forms:

Enter data in table Insurance using a Form! This is very unique to Access and very

POTENT! 1, six_feet_under, 1000000, 101 2, hambakahle, 2500000, 102 3, sos, 1500000,103

Page 38: Chapter 6: Databases and Data Warehouses
Page 39: Chapter 6: Databases and Data Warehouses

39

Form:

Page 40: Chapter 6: Databases and Data Warehouses

40

Entering Data:

Page 41: Chapter 6: Databases and Data Warehouses

41

Summary: (Database Schema)

Database: human_resource Employee(Emp_surname, Text;Emp_salary,

Currency;Emp_number, Number) Insurance (Ins_code, Number; Ins_name,

Text;Ins_amount, Currency;Emp_number, Number)

Page 42: Chapter 6: Databases and Data Warehouses

42

Instance of relational database:

EMPLOYEE

Page 43: Chapter 6: Databases and Data Warehouses

43