Chapter 6: Databases and Data Warehouses
description
Transcript of Chapter 6: Databases and Data Warehouses
![Page 1: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/1.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/2.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/3.jpg)
![Page 4: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/4.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/7.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/10.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/11.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/12.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/13.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/14.jpg)
Ms Access
Main elements in Ms Access– Tables
Fields and records– Queries– Forms– Reports
14
![Page 15: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/16.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/17.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/18.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/19.jpg)
19
![Page 20: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/20.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/21.jpg)
21
![Page 22: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/22.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/23.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/24.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/25.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/26.jpg)
Designing: Step 3
Assign data types to each characteristics
– Text– Number– Date– Logical– Currency
26
![Page 27: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/27.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/28.jpg)
![Page 29: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/29.jpg)
Relational Model Diagram:
![Page 30: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/30.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/31.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/32.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/33.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/34.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/35.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/36.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/37.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/38.jpg)
![Page 39: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/39.jpg)
39
Form:
![Page 40: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/40.jpg)
40
Entering Data:
![Page 41: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/41.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/42.jpg)
42
Instance of relational database:
EMPLOYEE
![Page 43: Chapter 6: Databases and Data Warehouses](https://reader035.fdocuments.in/reader035/viewer/2022062310/56815c8c550346895dca9e68/html5/thumbnails/43.jpg)
43