P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 14 Using Relational Databases.

Slides:



Advertisements
Similar presentations
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Advertisements

By Mary Anne Poatsy, Keith Mulbery, Eric Cameron, Jason Davidson, Rebecca Lawson, Linda Lau, Jerri Williams Chapter 9 Fine-Tuning the Database 1 Copyright.
Accounting System Design
1 7 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 7 DBMS Functions.
Chapter 5 Normalization of Database Tables
QUERYING A DATABASE By: Dr.Ennis-Cole. OBJECTIVES: Learn how to use the Query window in Design view Create, run and Save queries Define a relationship.
Introduction to Structured Query Language (SQL)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 3: Data Modeling
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Terms - data,information, file record, table, row, column, transaction, concurrency Concepts - data integrity, data redundancy, Type of databases – single-user,
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Lesson 32: Designing a Relational Database. 2 Lesson Objectives After studying this lesson, you will be able to:  Identify and apply principles for good.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 9 Database Management
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
PHASE 3: SYSTEMS DESIGN Chapter 7 Data Design.
Chapter 5 Normalization of Database Tables
Discovering Computers Fundamentals, 2012 Edition Your Interactive Guide to the Digital World.
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
The University of Akron Dept of Business Technology Computer Information Systems DBMS Functions 2440: 180 Database Concepts Instructor: Enoch E. Damson.
© Paradigm Publishing Inc. 9-1 Chapter 9 Database and Information Management.
Objectives Overview Define the term, database, and explain how a database interacts with data and information Define the term, data integrity, and describe.
Concepts of Database Management, Fifth Edition
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Chapter 15: Using LINQ to Access Data in C# Programs.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
© Paradigm Publishing Inc. 9-1 Chapter 9 Database and Information Management.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Database Systems: Design, Implementation, and Management Tenth Edition
Concepts of Database Management, Fifth Edition
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
The Relational Model and Normalization R. Nakatsu.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
Objectives Overview Define the term, database, and explain how a database interacts with data and information Describe the qualities of valuable information.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Chapter 16: Using Relational Databases Programming Logic and Design, Third Edition Comprehensive.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Lesson 2: Designing a Database and Creating Tables.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
Work with Tables and Database Records Lesson 3. NAVIGATING AMONG RECORDS Access users who prefer using the keyboard to navigate records can press keys.
Data Resource Management Application Layer TPS A RCHITECTURE Data Layer Sales/MarketingHR Finance/Accounting Operations Spreadsheet Data MS Access Accounts.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
 2012 Pearson Education, Inc. All rights reserved.
Chapter Ten Managing a Database.
Chapter 4 Relational Databases
Relational Database Design
Presentation transcript:

P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 14 Using Relational Databases

O BJECTIVES In this chapter, you will learn about: Relational database fundamentals Creating databases and table descriptions Primary keys Database structure notation Adding, deleting, updating, and sorting records within a table 2 Programming Logic & Design, Sixth Edition

O BJECTIVES ( CONTINUED ) Creating queries Relationships between tables Poor table design Anomalies, normal forms, and normalization Database performance and security issues 3 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONAL D ATABASE F UNDAMENTALS Data hierarchy Characters Fields Records Files Database Holds files organization needs to support operations Called tables 4 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONAL D ATABASE F UNDAMENTALS ( CONTINUED ) Figure 14-1 A telephone book table 5 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONAL D ATABASE F UNDAMENTALS ( CONTINUED ) Primary key Uniquely identifies a record Often defined as a single table column Can be compound or composite Database management software functions Create table descriptions Identify keys Add, delete, and update records within a table 6 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONAL D ATABASE F UNDAMENTALS ( CONTINUED ) Arrange records within a table so they are sorted by different fields Write questions that combine information from multiple tables Create reports Keep data secure Relational database A group of database tables from which you can make these connections 7 Programming Logic & Design, Sixth Edition

C REATING D ATABASES AND T ABLE D ESCRIPTIONS Planning and analysis Create the database itself Name it and indicate the physical location Save a table Provide a name that begins with the prefix “tbl” tblCustomers Design the table Decide what columns your table needs and name them Provide a data type for each column 8 Programming Logic & Design, Sixth Edition

C REATING D ATABASES AND T ABLE D ESCRIPTIONS ( CONTINUED ) Figure 14-2 Customer table description 9 Programming Logic & Design, Sixth Edition

C REATING D ATABASES AND T ABLE D ESCRIPTIONS ( CONTINUED ) Text columns Hold any type of characters—letters or digits Numeric columns Hold numbers only Other possible column types Numeric subtypes Boolean Currency Can add descriptions 10 Programming Logic & Design, Sixth Edition

I DENTIFYING P RIMARY K EYS Primary key Column that makes each record different from all others Examples customerID Student ID number Important for several reasons Should be immutable 11 Programming Logic & Design, Sixth Edition

I DENTIFYING P RIMARY K EYS ( CONTINUED ) Figure 14-3 Table containing residence hall student records 12 Programming Logic & Design, Sixth Edition

U NDERSTANDING D ATABASE S TRUCTURE N OTATION Shorthand way to describe a table Table name followed by parentheses containing all the field names Primary key underlined Example tblStudents(idNumber, lastName, firstName, gradePointAverage) Provides a quick overview of the table’s structure Does not provide information about data types or range limits on values 13 Programming Logic & Design, Sixth Edition

A DDING, D ELETING, U PDATING, AND S ORTING R ECORDS WITHIN T ABLES Entering data Requires time and accuracy Method depends on database software Deleting and modifying data Keeping records up to date is vital 14 Programming Logic & Design, Sixth Edition

S ORTING THE R ECORDS IN A T ABLE Sort a table based on any column Or on multiple columns Group rows after sorting Add subtotals Create displays in the format that suits your needs 15 Programming Logic & Design, Sixth Edition

C REATING Q UERIES View subsets of data from a table you have created Examine only those customers with an address in a specific state Limit the columns that you view School administrator might only be interested in looking at names and grade point averages Query Question using the syntax that the database software can understand 16 Programming Logic & Design, Sixth Edition

C REATING Q UERIES ( CONTINUED ) Query by example Create a query by filling in blanks Write statements in Structured Query Language, or SQL SELECT-FROM-WHERE Basic form of the SQL statement Example SELECT custId, lastName FROM tblCustomer WHERE state = "WI" 17 Programming Logic & Design, Sixth Edition

C REATING Q UERIES ( CONTINUED ) Can use comparison operators Wildcards Examples SELECT * from tblCustomer WHERE state = "WI“ SELECT * FROM tblCustomer 18 Programming Logic & Design, Sixth Edition

C REATING Q UERIES ( CONTINUED ) Figure 14-5 Sample SQL statements and explanations 19 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONSHIPS BETWEEN T ABLES Most database applications require many related tables Relationship Connection between two tables Join operation Connecting two tables based on the values in a common column Virtual table Table that is displayed as the result of the query Three types of relationships 20 Programming Logic & Design, Sixth Edition

U NDERSTANDING R ELATIONSHIPS BETWEEN T ABLES ( CONTINUED ) Figure 14-6 Sample customers and orders 21 Programming Logic & Design, Sixth Edition

U NDERSTANDING O NE - TO -M ANY R ELATIONSHIPS One row in a table can be related to many rows in another table Most common type of relationship between tables Example tblCustomers(customerNumber, customerName) tblOrders(orderNumber, customerNumber, orderQuantity, orderItem, orderDate) One row in the tblCustomers table can correspond to, and be related to, many rows in the tblOrders table 22 Programming Logic & Design, Sixth Edition

U NDERSTANDING O NE - TO -M ANY R ELATIONSHIPS ( CONTINUED ) Base table : tblCustomers Related table : tblOrders customerNumber attribute Links the two tables together Nonkey attribute Foreign key When a column that is not a key in a table contains an attribute that is a key in a related table 23 Programming Logic & Design, Sixth Edition

U NDERSTANDING M ANY - TO -M ANY R ELATIONSHIPS Another example of a one-to-many relationship tblItems(itemNumber, itemName, itemPurchaseDate, itemPurchasePrice, itemCategoryId) tblCategories(categoryId, categoryName, categoryInsuredAmount) 24 Programming Logic & Design, Sixth Edition

U NDERSTANDING M ANY - TO -M ANY R ELATIONSHIPS ( CONTINUED ) Figure 14-7 Sample items and categories: a one-to-many relationship 25 Programming Logic & Design, Sixth Edition

U NDERSTANDING M ANY - TO -M ANY R ELATIONSHIPS ( CONTINUED ) Many-to-many relationship Multiple rows in each table can correspond to multiple rows in the other One specific row in the tblItems table can link to many rows in the tblCategories table Cannot continue to maintain the foreign key itemCategoryId in the tblItems table Simplest way to support a many-to-many relationship Remove the itemCategoryId attribute 26 Programming Logic & Design, Sixth Edition

U NDERSTANDING M ANY - TO -M ANY R ELATIONSHIPS ( CONTINUED ) Example tblItems(itemNumber, itemName, itemPurchaseDate, itemPurchasePrice) tblCategories(categoryId, categoryName, categoryInsuredAmount) New table tblItemsCategories(itemNumber, categoryId) 27 Programming Logic & Design, Sixth Edition

U NDERSTANDING M ANY - TO -M ANY R ELATIONSHIPS ( CONTINUED ) Figure 14-8 Sample items, categories, and item categories: a many-to-many relationship 28 Programming Logic & Design, Sixth Edition

U NDERSTANDING O NE - TO -O NE R ELATIONSHIPS Row in one table corresponds to exactly one row in another table Least frequently encountered Common reason you create a one-to-one relationship is security 29 Programming Logic & Design, Sixth Edition

U NDERSTANDING O NE - TO -O NE R ELATIONSHIPS ( CONTINUED ) Figure 14-9 Employees and salaries tables: a one-to-one relationship 30 Programming Logic & Design, Sixth Edition

R ECOGNIZING P OOR T ABLE D ESIGN Need to know the following information Students’ names Students’ addresses Students’ cities Students’ states Students’ zip codes ID numbers for classes in which students are enrolled Titles for classes in which students are enrolled Potential problems with simple table design 31 Programming Logic & Design, Sixth Edition

R ECOGNIZING P OOR T ABLE D ESIGN ( CONTINUED ) Figure Students table before normalization 32 Programming Logic & Design, Sixth Edition

U NDERSTANDING A NOMALIES, N ORMAL F ORMS, AND N ORMALIZATION Normalization Helps you reduce data redundancies and anomalies Types of anomalies Update Delete Insert 33 Programming Logic & Design, Sixth Edition

U NDERSTANDING A NOMALIES, N ORMAL F ORMS, AND N ORMALIZATION ( CONTINUED ) Three normal forms First normal form 1NF Second normal form 2NF Third normal form 3NF Each normal form is structurally better than the one preceding 34 Programming Logic & Design, Sixth Edition

F IRST N ORMAL F ORM Unnormalized Table that contains repeating groups 1NF Contains no repeating groups of data Sample table class and classTitle attributes repeat multiple times for some of the students Repeat the rows for each repeating group of data Create combined key of studentId and class 35 Programming Logic & Design, Sixth Edition

F IRST N ORMAL F ORM ( CONTINUED ) Figure Students table in 1NF 36 Programming Logic & Design, Sixth Edition

F IRST N ORMAL F ORM ( CONTINUED ) Atomic attributes Small as possible, containing an undividable piece of data 37 Programming Logic & Design, Sixth Edition

S ECOND N ORMAL F ORM Eliminate all partial key dependencies No column should depend on only part of the key Must be in 1NF All nonkey attributes must be dependent on the entire primary key Create multiple tables Each nonkey attribute of each table is dependent on the entire primary key for the specific table within which the attribute occurs 38 Programming Logic & Design, Sixth Edition

S ECOND N ORMAL F ORM ( CONTINUED ) Figure Students table in 2NF 39 Programming Logic & Design, Sixth Edition

S ECOND N ORMAL F ORM ( CONTINUED ) When breaking up a table into multiple tables Consider the type of relationship among the resulting tables Determine what type of relationship exists between the two tables 40 Programming Logic & Design, Sixth Edition

T HIRD N ORMAL F ORM Table must be in 2NF, and it has no transitive dependencies Transitive dependency Value of a nonkey attribute determines, or predicts, the value of another nonkey attribute Example: zip code determines city and state Remove the attributes that are determined by, or are functionally dependent on, the zip attribute 41 Programming Logic & Design, Sixth Edition

T HIRD N ORMAL F ORM ( CONTINUED ) Figure The complete Students database 42 Programming Logic & Design, Sixth Edition

D ATABASE P ERFORMANCE AND S ECURITY I SSUES Major issues Providing data integrity Recovering lost data Avoiding concurrent update problems Providing authentication and permissions Providing encryption 43 Programming Logic & Design, Sixth Edition

P ROVIDING D ATA I NTEGRITY Data integrity Set of rules that makes the data accurate and consistent Can enforce integrity between tables 44 Programming Logic & Design, Sixth Edition

R ECOVERING L OST D ATA Organization’s data can be destroyed in many ways Recovery Process of returning the database to a correct form that existed before an error occurred Periodically make a backup copy of a database and keep a record of every transaction 45 Programming Logic & Design, Sixth Edition

A VOIDING C ONCURRENT U PDATE P ROBLEMS Concurrent update Problem occurs when two database users need to modify the same record at the same time Lock Mechanism that prevents changes to a database for a period of time Do not allow users to update the original database at all Store transactions and then later apply to the database all at once, or in a batch 46 Programming Logic & Design, Sixth Edition

P ROVIDING A UTHENTICATION AND P ERMISSIONS Authentication techniques include: Storing and verifying passwords Using physical characteristics Permissions assigned Indicate which parts of the database the user can view, modify, or delete 47 Programming Logic & Design, Sixth Edition

P ROVIDING E NCRYPTION Encryption Process of coding data into a format that human beings cannot read Only authorized users see the data in a readable format 48 Programming Logic & Design, Sixth Edition

S UMMARY Database holds a group of files that an organization needs to support its applications Create tables Identify primary key Database operations Sort, add, edit, delete, query Table relationships One-to-many, many-to-many, one-to-one Normalization Database issues 49 Programming Logic & Design, Sixth Edition