Chapter 4 Relational Databases.

Slides:



Advertisements
Similar presentations
Relational Database and Data Modeling
Advertisements

Chapter 12 File Processing and Data Management Concepts
Technology Guide 3 Data and Database T3-1. IT for Management Prof. Efraim Turban T3-2 File Management Hierarchy of data for a computer-based file Record.
Relational Databases Chapter 4.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
© 2006 Prentice Hall Business Publishing Accounting Information Systems, 10/e Romney/Steinbart1 of 95 C HAPTER 4 Relational Databases.
Organizing Data & Information
© 2008 Prentice Hall Business Publishing Accounting Information Systems, 11/e Romney/Steinbart1 of 96 C HAPTER 4 Relational Databases.
Introduction to Databases Transparencies
© 2008 Prentice Hall Business Publishing Accounting Information Systems, 11/e Romney/Steinbart1 of 96 C HAPTER 4 Relational Databases.
Information Technology in Organizations
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
© 2008 Prentice Hall Business Publishing Accounting Information Systems, 11/e Romney/Steinbart1 of 96 C HAPTER 4 Relational Databases.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Relational Databases Chapter 4.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Relational Databases Chapter 4.
PHASE 3: SYSTEMS DESIGN Chapter 7 Data Design.
The Relational Database Model
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Database Technical Session By: Prof. Adarsh Patel.
STORING ORGANIZATIONAL INFORMATION— DATABASES CIS 429—Chapter 7.
Database Management Systems Accounting Information Systems, 5 th edition James A. Hall COPYRIGHT © 2007 Thomson South-Western, a part of The Thomson Corporation.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Technology Guide 3 Data & Databases.
Concepts and Terminology Introduction to Database.
FILE VS. DATABASES Let’s examine some basic principles about how data are stored in computer systems. – An entity is anything about which the organization.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
I Information Systems Technology Ross Malaga 4 "Part I Understanding Information Systems Technology" Copyright © 2005 Prentice Hall, Inc. 4-1 DATABASE.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Accounting Information Systems 9 th Edition Marshall.
Data Models and Relational Databases Chapter 2. Learning Objectives Identify primary and foreign keys for each entity and relevant relationships in the.
Storing Organizational Information - Databases
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
Relational Database. Database Management System (DBMS)
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
 2001 Prentice Hall Business Publishing, Accounting Information Systems, 8/E, Bodnar/Hopwood A field may be a single character or number, or it.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
Chapter 13 Designing Databases Systems Analysis and Design Kendall & Kendall Sixth Edition.
© 2006 Prentice Hall Business Publishing Accounting Information Systems, 10/e Romney/Steinbart1 of 95 C HAPTER 4 Relational Databases.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
CHAPTER 4 Relational Databases. Learning Objectives Explain the importance and advantages of databases Describe the difference between database systems.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
IS 320 Notes for April 15, Learning Objectives Understand database concepts. Use normalization to efficiently store data in a database. Use.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Essentials of Systems Analysis and Design Fourth Edition Joseph S. Valacich Joey F.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
Copyright (c) 2014 Pearson Education, Inc. Introduction to DBMS.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
© 2008 Prentice Hall Business Publishing Accounting Information Systems, 11/e Romney/Steinbart1 of 96 C HAPTER 4 Relational Databases.
6.1 © 2007 by Prentice Hall Chapter 6 (Laudon & Laudon) Foundations of Business Intelligence: Databases and Information Management.
Chapter 3: Relational Databases
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
RELATIONAL DATABASES SYSTEMS Unit 3. This unit shift attention to database as an important component of AIS. Understanding the fundamentals of database.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
© 2006 Prentice Hall Business Publishing Accounting Information Systems, 10/e Romney/Steinbart1 of 95 C HAPTER 4 Relational Databases.
HAPTER 4 Relational Databases.
Relational Databases Chapter 4.
Chapter 4 Relational Databases
Chapter 9 Designing Databases
Basic Concepts in Data Management
Accounting Information Systems 9th Edition
Relational Databases Chapter 4.
Presentation transcript:

Chapter 4 Relational Databases

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Learning Objectives Explain the importance and advantages of databases Describe the difference between database systems and file-based legacy systems. Explain the difference between logical and physical views of a database. Explain fundamental concepts of database systems such as DBMS, schemas, the data dictionary, and DBMS languages. Describe what a relational database is and how it organizes data. Create a set of well-structured tables to store data in a relational database. Perform simple queries using the Microsoft Access database.

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Data Hierarchy Field Attributes about an entity Record Related group of fields File Related group of records Database Related group of files

Data Redundancy / Independence Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Data Redundancy / Independence File Approach Database Approach A, B, C, D Sales A, B, C, D, E, F, G A, C, E, F Shipping Database Management System A, D, E, G Billing Sales Shipping Billing

Advantages of Database Systems Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Advantages of Database Systems Data Integration Files are logically combined and made accessible to various systems. Data Sharing With data in one place it is more easily accessed by authorized users. Minimizing Data Redundancy & Data Inconsistency Eliminates Reduces the same data being stored in multiple files, thus reducing inconsistency in multiple versions of the same data. Data Independence Data is separate from the programs that access it. Changes can be made to the data without necessitating a change in the programs and vice versa. Cross-Functional Analysis Relationships between data from various organizational departments can be more easily combined.

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Database Terminology Database Management System (DBMS) Interface between software applications and the data in files. Database Administrator (DBA) Person responsible for maintaining the database Data Dictionary Information about the structure of the database Field names, descriptions, uses

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Logical Vs. Physical Physical View Depends on explicitly knowing: How is the data actually arranged in a file Where is the data stored on the computer Logical View Conceptual Organization of Data Separates storage of data from use of the data Unnecessary to explicitly know how and where data is stored.

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Schemas Describe the logical structure of a database Conceptual Level Organization wide view of the data External Level Individual Users view of the data Each view is a subschema Internal Level Describes how data are stored and accessed Description of: Records, Definitions, Addresses & Indexes

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall DBMS Languages Data Definition Language (DDL) Builds the data dictionary Creates the database Describes the subschema Specifies record and/or field security constraints Data Manipulation Language (DML) Changes the content in the database Updates, Insertions and Deletions Data Query Language (DQL) Enable the retrieval, sorting, & display of data from the database

Types of Database Structures Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Types of Database Structures Hierarchical Data is organized in a tree like structure Each Child has only 1 parent, but each parent can have many children Network allows each record to have multiple parent and child records Object-Oriented information is represented in the form of objects database and applications are not independent Associated … Relational

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Relational Database Relational Data model represents the conceptual and external level schemas as if data are stored in tables Table Each Row, a Tuple, contains data about one instance of an entity This is equivalent to a Record Each Column, contains data about one attribute of an entity This is equivalent to a Field

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall A Relational Table Row (Record) Column (Field) Each row contains multiple attributes describing an instance of the entity. In this case inventory. Same type of data

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Attributes Primary Key An attribute or combination of attributes that can be used to Uniquely identify a specific row(record) in a table. Foreign Key An attribute in one table that is a Primary key in another table. Used to link the two tables.

Each row is called a tuple, which rhymes with “couple.”

Each row contains data about a specific occurrence of the type of entity in the table.

Each column in a table contains information about a specific attribute of the entity.

A primary key is the attribute or combination of attributes that uniquely identifies a specific row in a table.

In some tables, two or more attributes may be joined to form the primary key.

STUDENTS Student ID Last Name First Name Phone No. Advisor No. 333-33-3333 Simpson Alice 333-3333 1418 111-11-1111 Sanders Ned 444-4444 123-45-6789 Moore Artie 555-5555 1503 ADVISORS Advisor No. Last Name First Name Office No. 1418 Howard Glen 420 1419 Melton Amy 316 1503 Zhang Xi 202 1506 Radowski J.D. 203 A foreign key is an attribute in one table that is a primary key in another table.

Foreign keys are used to link tables together. STUDENTS Student ID Last Name First Name Phone No. Advisor No. 333-33-3333 Simpson Alice 333-3333 1418 111-11-1111 Sanders Ned 444-4444 123-45-6789 Moore Artie 555-5555 1503 ADVISORS Advisor No. Last Name First Name Office No. 1418 Howard Glen 420 1419 Melton Amy 316 1503 Zhang Xi 202 1506 Radowski J.D. 203 Foreign keys are used to link tables together.

STUDENTS Student ID Last Name First Name Phone No. Advisor No. 333-33-3333 Simpson Alice 333-3333 1418 111-11-1111 Sanders Ned 444-4444 123-45-6789 Moore Artie 555-5555 1503 ADVISORS Advisor No. Last Name First Name Office No. 1418 Howard Glen 420 1419 Melton Amy 316 1503 Zhang Xi 202 1506 Radowski J.D. 203 Other non-key attributes in each table store important information about the entity.

Database Design Errors Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Database Design Errors If the database is not designed properly data errors can occur: Update Anomaly Changes to existing data are not correctly recorded Due to multiple records with the same data attributes Insert Anomaly Unable to add a record to the database Delete Anomaly Removing a record also removes unintended data from the database

In the above, simplified example, a number of problems arise. Student ID Last Name First Name Phone No. Course No. Section Day Time 333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM FIN-3213 3 Th 11:00 AM MGMT-3021 11 12:00 PM 111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM 5 W 8:00 AM ANSI-1422 7 F 123-45-6789 Moore Artie 555-5555 In the above, simplified example, a number of problems arise.

This problem is referred to as an update anomaly. Student ID Last Name First Name Phone No. Course No. Section Day Time 333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM FIN-3213 3 Th 11:00 AM MGMT-3021 11 12:00 PM 111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM 5 W 8:00 AM ANSI-1422 7 F 123-45-6789 Moore Artie 555-5555 Suppose Alice Simpson changes her phone number. You need to make the change in three places. If you fail to change it in all three places or change it incorrectly in one place, then the records for Alice will be inconsistent. This problem is referred to as an update anomaly.

This problem is referred to as an insert anomaly. Student ID Last Name First Name Phone No. Course No. Section Day Time 333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM FIN-3213 3 Th 11:00 AM MGMT-3021 11 12:00 PM 111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM 5 W 8:00 AM ANSI-1422 7 F 123-45-6789 Moore Artie 555-5555 What happens if you have a new student to add, but he hasn’t signed up for any courses yet? Or what if there is a new class to add, but there are no students enrolled in it yet? In either case, the record will be partially blank. This problem is referred to as an insert anomaly.

This problem is referred to as a delete anomaly. Student ID Last Name First Name Phone No. Course No. Section Day Time 333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM FIN-3213 3 Th 11:00 AM MGMT-3021 11 12:00 PM 111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM 5 W 8:00 AM ANSI-1422 7 F 123-45-6789 Moore Artie 555-5555 If Ned withdraws from all his classes and you eliminate all three of his rows from the table, then you will no longer have a record of Ned. If Ned is planning to take classes next semester, then you probably didn’t really want to delete all records of him. This problem is referred to as a delete anomaly.

This approach is also fraught with problems: Student ID Last Name First Name Phone No. Class 1 Class 2 Class 3 Class 4 333-33-3333 Simpson Alice 333-3333 ACCT-3603 FIN-3213 MGMT-3021   111-11-1111 Sanders Ned 444-4444 ACCT-3433 ANSI-1422 123-45-6789 Moore Artie 555-5555 This approach is also fraught with problems: How many classes should you allow in building the table? The above table is quite simplified. In reality, you might need to allow for 20 or more classes (assuming a student could take many 1-hour classes). Also, more information than just the course number would be stored for each class. There would be a great deal of wasted space for all the students taking fewer than the maximum possible number of classes. Also, if you wanted a list of every student taking MGMT-3021, notice that you would have to search multiple attributes.

The solution to the preceding problems is to use a set of tables in a relational database. Each entity is stored in a separate table, and separate tables or foreign keys can be used to link the entities together.

Note that within each table, there are no duplicate primary keys and no null primary keys. Consistent with the entity integrity rule.

STUDENTS Student ID Last Name First Name Phone No. Advisor No. 333-33-3333 Simpson Alice 333-3333 1418 111-11-1111 Sanders Ned 444-4444 123-45-6789 Moore Artie 555-5555 1503 ADVISORS Advisor No. Last Name First Name Office No. 1418 Howard Glen 420 1419 Melton Amy 316 1503 Zhang Xi 202 1506 Radowski J.D. 203 Advisor No. is a foreign key in the STUDENTS table. Every incident of Advisor No. in the STUDENTS table either matches an instance of the primary key in the ADVISORS table or is null.

Add a student here. Leaves no blank spaces. Add a course here. Leaves no blank spaces. When a particular student enrolls for a particular course, add that info here.

Ned still exists in the student table. Even if Ned was the only student in the class, ACCT-3603 still exists in the course table. If Ned Sanders drops ACCT-3603, remove Ned’s class from this table.

Design Requirements for Relational Database Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Design Requirements for Relational Database Every column must be single valued. Primary keys must contain data (Not Null). Entity Integrity Foreign Keys must contain the same data as the primary key in another table. Referential Integrity All other attributes must identify a characteristic of the table identified by the primary key.

Normalizing Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Normalizing Relational Databases Initially one table is used for all the data in a database Following rules, the table is decomposed into multiple tables related by: Primary Key – Foreign key integration Decomposed set of tables are in third normal form (3NF) First Normal Form: A relation is in first normal form if the domain of each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain. Second Normal Form: No non-prime attribute in the table is functionally dependent on a proper subset of any candidate key Third Normal Form: Every non-prime attribute is non-transitively dependent on every candidate key in the table. The attributes that do not contribute to the description of the primary key are removed from the table. In other words, no transitive dependency is allowed.

Semantic Data Modeling Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Semantic Data Modeling Using Knowledge of Business Processes Diagram is created of the Database System Entity-Relationship Diagram or E-R Diagram In accounting we use a special form: Resource, Event, Agent or REA diagram Diagram becomes Blue-print of Database structure Database designed this way must still follow rules of a Normalized Database to eliminate design errors

Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Creating Queries

Microsoft Access Query#1 Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Microsoft Access Query#1

Microsoft Access Query#2 Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Microsoft Access Query#2

Microsoft Access Query#3 Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Microsoft Access Query#3

Microsoft Access Query#4 Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Microsoft Access Query#4

Microsoft Access Query#5 Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall Microsoft Access Query#5