Top Banner
5-1 Chapter 5 Database Processing
47
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter 5 Database

5-1

Chapter 5

Database Processing

Page 2: Chapter 5 Database

SPREADSHEET VS DATABASE PACKAGES

Spreadsheet Features:

1. Provides an intuitive and user friendly interface that is easy for users to work with in building applications

2. Allows relatively complex mathematical and statistical computations to be performed including comparisons of individual and summary values.

5-2

Page 3: Chapter 5 Database

3. Allow extensive user interaction with applications and user control of parameters for “what if” analysis.

4. Allows very flexible formatting and layout of data for reporting.

5. Allows presentation of results in graphical form.

6. Allows the rapid entry and use of small amounts of data that do not need to be maintained for repeated long term use.

5-3

Page 4: Chapter 5 Database

Limitations of spreadsheets:

- handling of data which are not particularly effective in handling large amounts of data

- to produce many different reports from selected portions of a common set of data

5-4

Page 5: Chapter 5 Database

Key Database Features

1. Allows controlled entry and maintenance of data that is needed for sets of data that will be accumulated and used over time.

2. Allows data to be made available in a variety of sorted orders and selected subsets that might be required for different applications.

3. Allows logically related data from multiple files to be linked together.

5-5

Page 6: Chapter 5 Database

4. Allows logically related data from multiple files to be linked together.

5. Allows the same data to be used, in different forms and sorted in different ways, in a variety of different output documents.

5-6

Page 7: Chapter 5 Database

Working with her consultant, Dee selected an application program called Movable Type for her blog.

Than Don mentioned that she would need to install MySQL.

“You need a DBMS to store your blog entries,” he explained.

“A What?” asked Dee. “Oh right,” explained Don, “a database management system– a DBMS”

5-7

Page 8: Chapter 5 Database

So Dee asked the IT Department, but they only had Oracle.

So Don insisted to install MySQL since it was easy to use.

But again, if you can make a problem difficult, why make it easy?

The IT Department resisted the idea, so she had to have the knowledge of this chapter to make them understand and willing to install the program.

5-8

Page 9: Chapter 5 Database

Study QuestionsQ1 What is the purpose of a database?Q2 What is a database?Q3 What are the components of a database application

system?Q4 How do database applications make databases more

useful?Q5 How are data models used for database development?Q6 How is a data model transformed into a database design?Q7 What is the user's role in the development of databases?Q8 What are the responsibilities for database administration?

5-9

Page 10: Chapter 5 Database

5-10

Q1 – What is the purpose of a database?

As a database user, you play a crucial role in developing database applications for your business or organization.

Spreadsheets are good for tracking items with just one theme (as shown below) versus a database that tracks things involving more

than one theme (as shown on the next slide).

Fig 5-1 List of Student Grades, Presented in a Spreadsheet

Page 11: Chapter 5 Database

5-11

Q1 – What is the purpose of a database?

Fig 5-2 Student Data Shown in a Form, from a Database

Page 12: Chapter 5 Database

5-12

Q2 – What is a database?

These are terms you’ll need to know when working with databases. A database is a self-describing

collection of integrated records. Bytes, characters of data, are

grouped into columns which are also called fields.

The fields are grouped into rows which are also called records.

A table is a group of similar rows or records which is also called a file.

Fig 5-3 Student Table (also called a file)

Page 13: Chapter 5 Database

5-13

Q2 – What is a database?

Fig 5-4 Hierarchy of Data Elements

This figure shows the hierarchy of data elements working from the smallest at the bottom to the largest at the top.

Page 14: Chapter 5 Database

5-14

Q2 – What is a database?

Fig 5-5 Components of a Database

A database is more than just a group of tables. It includes tables or files plus the relationships among rows in the tables and metadata that describes the database’s structure.

Page 15: Chapter 5 Database

5-15

Q2 – What is a database?

Fig 5-6 Example of Relationships Among Rows

This diagram shows relationships among rows of different tables.

The Student Number value in the first row of the top table,1325, relates to the same Student Number value in a row in the second table.

Both that Student Number value and that of 4867 in the second table relate to those in the third.

Page 16: Chapter 5 Database

5-16

Q2 – What is a database?

Keys are a column that identifies a unique row in a table. In the Student Table, the primary key is Student Number.

A primary key, Student Number, can act as a foreign key in a different table, like the Office Visit Table.

A relational database

carries data in the

form of tables and

uses foreign keys

to represent relationships

Page 17: Chapter 5 Database

5-17

Q2 – What is a database?

Fig 5-7 Sample Metadata (in Access)

Metadata are data that describe data and makes databases easy to use. Metadata is always a part of a database.

The Field Name, Data Type, and Description at the top of this diagram are part of the database’s metadata.

The additional

field properties

at the bottom

are also

considered

metadata.

Page 18: Chapter 5 Database

5-18

Q3 – What are the components of a database application system? By itself, a database is not very useful because there’s no way to

easily manage the data and turn it into useful information.

A database application system makes database data more accessible and useful by using forms, formatted reports, queries, and application programs to provide useful information to users.

Fig 5-8 Components of a Database Application System

Page 19: Chapter 5 Database

5-19

Q3 – What are the components of a database application system?

A DBMS program is used to create, process, and administer a database. Popular DBMS products include:

DB2 from IBM Access from Microsoft (for personal computers) SQL Server from Microsoft (for large computer systems) Oracle from Oracle Corporation MySQL, an open-source product that’s license-free

It’s easy to confuse a DBMS, which is a software program, with a database, which is a collection of tables, relationships and metadata. But, they are two different concepts.

Page 20: Chapter 5 Database

5-20

Q3 – What are the components of a database application system?

A DBMS is used to create or modify tables, relationships, and other structures in a database.

This figure shows how the metadata in an existing table is modified to add a new field labeled “Response?”

Fig 5-9 Adding a New Column to a Table (in Access)

Page 21: Chapter 5 Database

5-21

Q3 – What are the components of a database application system?

DBMSs are used to process databases by reading, inserting, modifying, or deleting data. The Structured Query Language (SQL), is an international

standard language used by most major DBMS programs for processing databases.

A DBMS includes tools to help you administer a database. You can

Set up a security system that includes permissions and passwords.

Back up the data to prevent it from being lost or compromised. Improve the performance of applications by adding structures. Remove data that’s no longer needed.

Page 22: Chapter 5 Database

5-22

Q4 – How do database applications make databases more useful?

A database application includes forms, reports, queries, and applications programs available to one or more users.

This figure shows three different applications stemming from a

single DBMS and a single database.

Fig 5-10 Use of Multiple Database Applications

Page 23: Chapter 5 Database

5-23

Q4 – How do database applications make databases more useful?

Data entry forms are used to read, insert, modify, and delete data.

Reports are used to show data in a structured context as the example to the right shows.

Fig 5-11 Example of a Student Report

Page 24: Chapter 5 Database

5-24

Q4 – How do database applications make databases more useful?

Fig 5-12 (a) & (b) Sample Query and Results

A query form helps the user quickly find answers to questions. In this case, the words “barriers to entry” were found in Baker’s record.

Page 25: Chapter 5 Database

5-25

Q4 – How do database applications make databases more useful? Database application programs process logic specific to a given

business need. For example, a program could track backordered

items and hold a customer order until the items are ready to ship. Application programs enable database processing over the Internet

as the figure below shows. Users access the applications programs on a Web server, which in turn accesses a single DBMS and database.

Fig 5-13 Four Application Programs on a Web Server Computer

Page 26: Chapter 5 Database

5-26

Q4 – How do database applications make databases more useful?

This figure depicts multi-user database processing. The system must be managed properly to avoid the following problems: Potential update loss because two users update same data at the

same time Potential locking problems Possible data conflicts

Page 27: Chapter 5 Database

5-27

Q4 – How do database applications make databases more useful?

Here’s a comparison of an Enterprise DBMS versus a Personal DBMS.

Enterprise DBMS Large organizational and

workgroup databases Thousands of users Many different database

applications 24/7 operations DB2, SQL Server, Oracle

Personal DBMS Smaller, simpler

applications Personal or small

workgroup applications Fewer than 100 users Microsoft Access is both

a DBMS and application development product as this figure depicts.

Fig 5-14 Personal Database System

Page 28: Chapter 5 Database

5-28

Q5 – How are data models used for database development?

User involvement is critical for database development for these reasons: A database’s design depends on how users view their business

environment and how they do their jobs. Database developers do not and cannot know what to include because

they don’t work with the data everyday. They must rely on users to tell them what data are important and how they’re used.

A data model is similar to blueprints for a house. It’s a logical representation of database data that describes data and their relationships.

Fig 5-15 Database Development Process

Page 29: Chapter 5 Database

5-29

Q5 – How are data models used for database development?

An entity-relationship data model helps developers define things (entities) that will be stored in the database as they are building a data model. It also defines relationships among those entities.

Entities are things users want to track. It can be a physical object (inventory items) or a logical transaction (sales order). The names are always singular.

Each entity has attributes that describe its characteristics. The entity “Order” has attributes like “OrderNumber” and “OrderDate”.

An identifier is an attribute whose value is associated with one and only one entity instance. “OrderNumber” is the identifier for the “Order” entity because there should only be one number for each order.

Page 30: Chapter 5 Database

5-30

Q5 – How are data models used for database development?

Fig 5-16 Student Data Model Entities

Student, Department, Advisor, Email, and Office_Visit are the entity names in this model.

The entity identifiers are StudentNumber, DeptName, and AdvisorName. Not all entities require an identifier.

Page 31: Chapter 5 Database

5-31

Q5 – How are data models used for database development?

Relationships join one entity to another entity One-to-one – 1:1 One-to-many – 1:N Many-to-many – N:M

This diagram shows that each Department Entity can have multiple Adviser Entities in a one-to-many relationship. Adviser Entities can have a many-to-many relationship with Student Entities.

Page 32: Chapter 5 Database

5-32

Q5 – How are data models used for database development?

The line style between entities describes the type of relationship as shown in the entity-relationship diagram below.

This diagram depicts crow’s feet between the entities to describe the relationships. It shows a one-to-many (1:M) relationship between Department and Adviser and a many-to-many (N:M) relationship between Adviser and Student entities.

Fig 5-19 Sample Relationships – Version 1

Page 33: Chapter 5 Database

5-33

Q5 – How are data models used for database development?

Fig 5-19 Sample Relationships – Version 2

The entity-relationship diagram below shows a many-to-many (N:M) relationship between Department and Adviser and a one-to-many (1:M) relationship between Adviser and Student.

Because relationships among entities can vary, only the user can describe the entity-relationship. That’s why it’s so important for users to help design databases.

Page 34: Chapter 5 Database

5-34

Q5 – How are data models used for database development?

Fig 5-20 Sample Relationships Showing Maximum/Minimum Cardinality

Maximum cardinality represents the maximum number of entities that can be involved in a relationship.

Minimum cardinality represents the minimum number of entities that can be involved in a relationship.

The vertical bar below indicates that at least one entity is required between Department and Adviser and between Adviser and Student.

The oval below indicates that an entity is optional and doesn’t require a relationship.

Page 35: Chapter 5 Database

5-35

Q6 How is a data model transformed into a database design?

Fig 5-21 Poorly Designed Employee Table

Converting a poorly structured table into two or more well-structured tables is called normalization.

The table below is poorly designed because it includes the DeptName as part of the Employee record, making it difficult to update.

It also creates data integrity

problems because

the DeptName is not

consistent throughout

the table after the

data were updated.

Page 36: Chapter 5 Database

5-36

Q6 How is a data model transformed into a database design?

Normalizing the tables by splitting the Department data into a separate table, as shown below, allows each table to describe a single topic or theme. The tables have been transformed into a normal form.

By eliminating the duplicate data, you eliminate data integrity problems. That’s called

normalizing for data integrity. Now, the department

name only needs to

be updated in one place

in the normalized tables.

Page 37: Chapter 5 Database

5-37

Q6 How is a data model transformed into a database design?

This chart shows the necessary steps to transform a data model into a relational database design.

Fig 5-23 Transforming a Data Model into a Database Design

Page 38: Chapter 5 Database

5-38

Q6 How is a data model transformed into a database design?

The figures below and on the next slide depict the steps used to create a well structured database that will produce useful

information. The figure on the left represents the relationship between tables.

The figure on the right shows a normalized table for each entity.

From Figure 5-24 Representing a 1:N Relationship

Page 39: Chapter 5 Database

5-39

Q6 How is a data model transformed into a database design?

The figure below shows how relationships are represented using foreign keys. It’s the last step in transforming a data model into a database design.

From Figure 5-24 Representing a 1:N Relationship

Page 40: Chapter 5 Database

5-40

Q7 – What is the user's role in the development of databases?

Your role in the database development process is to decide what data should be included and how records should relate to one another.

The best time to change a database structure is during the data modeling stage. It’s easier and cheaper to change your mind before anything is actually built. The costs of correcting the database in time and money later on may be very high.

Each entity must contain all the data you need to do your job.

Each relationship must accurately reflect the appropriate view of your business.

You must be the final judge of how well the database will serve your needs. Do not go forward until the data model is accurate.

Page 41: Chapter 5 Database

5-41

Q8 – What are the responsibilities for database administration?

Databases are an important resource for most businesses.

As databases touch more aspects of systems and business functions, the utility of a database increases as do potential problems.

Database administration manages the development, operation, and maintenance of databases.

Database administration must protect the database and maximize its availability for authorized use.

Page 42: Chapter 5 Database

5-42

Q8 – What are the responsibilities for database administration?

Fig 5-26 Summary of Database Administration Tasks

Database administration tasks are divided into four categories as shown below and on the next slide.

Page 43: Chapter 5 Database

5-43

Q8 – What are the responsibilities for database administration?

Fig 5-26 Summary of Database Administration Tasks, continued

Page 44: Chapter 5 Database

Samantha Green owns and operates Twigs Tree Trimming Service. Recall that Samantha has a degree from a forestry program and recently opened her business in St. Louis, Missouri. Her business consists of many one-time operations (e.g., remove a tree or stump), as well as recurring services (e.g., trimming customers’ trees every year or two). When business is slow, Samantha calls former clients to remind them of her services and of the need to trim their trees on a regular basis.

a. Name and describe tables of data that Samantha will need to run her business. Indicate possible fields for each table.

5-44

Page 45: Chapter 5 Database

b. Could Samantha use a spreadsheet to keep track of this data? What would be the advantage and disadvantages of doing so?

c. Using your answer to question a, give an example of two relationships that Samantha needs to track. Show the keys and foreign keys for each.

d. Which of the following components of a database application is Samantha likely to need: data entry, forms, reports, queries, or application program? Explain one use for each that she needs.

e. Will this application be for one user or for multiple users? Will she need a personal DBMS or an enterprise DBMS? If a personal DBMs, which product will she use?

5-45

Page 46: Chapter 5 Database

FiredUp, Inc is a small business owned by Curt and Julie Robards. Based in Brisbane, Australia, FiredUp manufactures and sells FiredUp, a light-weight camping stove. Recall that Curt used his previous experience as an aerospace engineer to invent a burning nozzle that enables the stove to stay lit in very high winds. Using her industrial design training, Julie designed the stove so that it is small, lightweight, easy to set up, and very stable. Curt and Julie sell the stove directly to their customers over the Internet and via phone. The warranty on the stove covers 5 years of cost-free repair for stoves used for recreational purposes.

FiredUp wants to track every stove and the customer who purchased it. They want to know which customers own which stoves in case they need notify customers of safety problems or need to order a stove recall. Curt and Julie also want to keep track of any repairs they have performed

5-46

Page 47: Chapter 5 Database

a. Name and describe tables of data that FiredUp will need. Indicate possible fields for each table.

b. Could FiredUp use a spreadsheet to keep track of this data? What would be the advantages and disadvantages of doing so?

c. Using your answer to question a, give an example of two relationships that FiredUp needs to track. Show the keys and foreign keys for each.

d. Which of the following components of a database application is FiredUp likely to need: data entry forms, reports, queries, or application program? Explain one use for each needed component.

e. Will this application be for one user or for multiple users? Will FiredUp need a personal DBMS, which product will it use? If an enterprise DBMS, which product cant they obtain licence-free?

5-47