Chapter 5 Database Processing
WHAT IS THE PURPOSE OF A DATABASE? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
What Is the Purpose of a Database? Organize and keep track of things Keep track of multiple themes General rule: Single theme store in a spreadsheet Multiple themes require a database Basic purpose of a database is to organize and keep track of things. Databases are needed when you need to keep track of multiple themes, such as grades, students, office visits and email messages. General rule: Use a spreadsheet for lists of data involving single theme. Use a database for data with multiple themes.
A List of Student Grades Presented in a Spreadsheet – Single Theme Spreadsheet with a single theme – Grades.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Data Redundancy and Data Inconsistency Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Student Data Form With Multiple Themes Forms are difficult, if not impossible, to produce from a spreadsheet, but are easily produced with a database.
WHY DO WE NEED DATABASES Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Why we need databases Size Ease of Updating Accuracy Security Redundancy Importance Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall WHAT IS A DATABASE? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Components of a Database Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Tables Table or file: A group of records Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Tables (cont’d) Each table must have a unique identifier called the Primary Key (PK) Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Relational databases Relation More Special Terms Relationships among tables are created by using foreign keys Relation Formal term for a table Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Relationships Among Records Database has multiple tables (one for each theme) Values in one table may relate to records in other tables Field(s) that uniquely identify a record in a table Relational database Primary or Unique key Foreign key Each table must have a key A non-primary key in one table that is related to a primary key of a different table Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Primary and Foreign Keys Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Metadata Metadata Describes data by: Database: Self-describing collection of integrated records Metadata Data that describes data Makes databases more useful Makes databases easier to use Describes data by: Data type: text, number, date, etc. Field name Field properties Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Sample Metadata in Access Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Features of Relational Databases Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Features of Relational Databases (cont’d) Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall WHAT IS A DBMS? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
What Is a DBMS and What Does It Do? Database management system (DBMS) Program that creates, processes, and administers databases Examples: Database Collection of tables, relationships, and metadata DBMS A software program Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Components of a Database Application System Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Processing the Database Four DBMS operations Read Insert Modify Delete data These operations are requested in applications that call upon the DBMS in different ways.
Structured Query Language (SQL) SQL (see-quell) International standard Used by most popular DBMS Structured Query Language (SQL) is used for processing the database. SQL is an international standard language for creating databases and database structures, and processing databases. SQL is used by all popular DBMS products.
Structured Query Language (SQL) Structured Query Language (SQL) is used for processing the database. SQL is an international standard language for creating databases and database structures, and processing databases. SQL is used by all popular DBMS products.
WHAT IS A DATABASE APPLICATION? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Database Applications Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Forms, Reports, and Queries Used to read, insert, modify, and delete data Show data in structured context May compute values such as Totals, within a report Are a means of getting answers from database data Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
How Are Database Application Systems Developed? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
How Are Database Application Systems Developed? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
What Are the Components of the Entity-Relationship Data (ERD) Model? Something users want to track Order, customer, salesperson, item, volunteer, donation Entities Describe characteristics of an entity OrderNumber, CustomerNumber, VolunteerName, PhoneNumber Attributes Attribute that uniquely identifies one entity instance from other instances Student_ID_Number Identifier Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Creating ERDs Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Student Data Model Entities Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Example of Department, Adviser, and Student Entities and Relationships A department may have many advisers An adviser works in one department An adviser advises many students A student may have one or more advisers 1:N relationships N:M relationships Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Example of Department, Adviser, and Student Entities and Relationships N:M 1:N Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Entity Relationship Diagram (ERD) ― Version 1 Crow’s Feet 1:N N:M 1:N = one-to-many relationships One department can have many advisers, but an adviser is in only one department N:M = many-to-many relationships One adviser can have many students and one student can have many advisers Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Entity Relationship Diagram (ERD) – Version 2 “Crow’s Foot” N:M = many-to-many relationship A department has many advisors and an advisor may advise for more than one department 1:N = one-to-many relationship A student has only one advisor, but an adviser may advise many students Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Defining one-to-many relationships Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
How Are Database Application Systems Developed? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Transforming a Data Model into a Database Design Represent each entity with a table Entity identifier becomes table key Entity attributes become table columns Normalize tables as necessary Represent relationships Use foreign keys Create additional tables for N:M relationships Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Representing 1:N Relationships Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Exploring many-to-many relationships Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Representing an N:M Relationship: Strategy for Foreign Keys Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
How Are Database Application Systems Developed? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
What Is the Difference Between an Enterprise DBMS and a Personal DBMS? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
What Is the Difference Between an Enterprise DBMS and a Personal DBMS? Processes large organizational and workgroup databases Supports many users (thousands plus) Examples: DB2, SQL Server, Oracle, MySQL Personal DBMS Designed for smaller, simpler database applications Supports fewer than 100 users (mostly 1–10 users) Examples: Access, dBase, FoxPro, R-Base Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall