A Table with a View: Database Queries

Slides:



Advertisements
Similar presentations
Chapter 15 A Table with a View: Database Queries.
Advertisements

Relational Databases Chapter 4.
ETEC 100 Information Technology
CPSC-608 Database Systems Fall 2009 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #2.
1 The Information School of the University of Washington Nov 27fit databases © 2006 University of Washington Database Intro INFO/CSE 100, Fall 2006.
Chapter 14 Getting to First Base: Introduction to Database Concepts.
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
Recording / Financing Fixed Asset Acquisition Human Resources Purchasing Revenue Traditional files approach: separate systems (Legacy Systems) Expenditure.
Information Technology in Organizations
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes 1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Chapter 15 Introduction to Database Concepts. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Learning Objectives Explain.
Database Technical Session By: Prof. Adarsh Patel.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Information Systems: Databases Define the role of general information systems Describe the elements of a database management system (DBMS) Describe the.
2005 SPRING CSMUIntroduction to Information Management1 Organizing Data John Sum Institute of Technology Management National Chung Hsing University.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
Copyright © 2014 Pearson Canada Inc. 5-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5a Database Design Part 2: Using Information Technology.
Lecture 16 Introduction to Database Concepts. Differences Between Tables and Databases Database: table of info –iTunes –Automobile registrations –Demography.
1 SQL SERVER 2005 Express CE-105 SPRING 2007 Engr. Faisal ur Rehman.
Understanding Data Storage
Entity- Relationship (ER) Model
Physical Changes That Don’t Change the Logical Design
 2012 Pearson Education, Inc. All rights reserved.
DESIGNING DATABASE APPLICATIONS
Fundamentals of Information Systems, Sixth Edition
Chapter 12 Information Systems.
Information Systems Database Management
Databases Intro (from Deitel)
Lecture 2 The Relational Model
CSCI-100 Introduction to Computing
Chapter 4 Relational Databases
Databases A brief introduction….
Database Structure Chapter 16.
Translation of ER-diagram into Relational Schema
Databases and Information Management
Chapter 9 Designing Databases
David M. Kroenke and David J
Chapter 3 The Relational Database Model
Basic Concepts in Data Management
Accounting System Design
Chapter 17 Linked Lists.
Chapter 4 Inheritance.
Chapter 14 Graphs and Paths.
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Teaching slides Chapter 8.
Chapter 10 Datapath Subsystems.
Chapter 20 Hash Tables.
Accounting System Design
Databases and Information Management
Session 2 Welcome: The fifth learning sequence
Getting to First Base: Introduction to Database Concepts
A Table with a View: Database Queries
Getting to First Base: Introduction to Database Concepts
The Facts to Be Explained
Getting to First Base: Introduction to Database Concepts
Databases 1.
A Table with a View: Database Queries
Chapter 2 Reference Types.
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
Presentation transcript:

A Table with a View: Database Queries Chapter 15 A Table with a View: Database Queries

The Physical Database Redundancy is Bad, Very Very Very Bad Never duplicate information in database table To avoid inconsistency among copies We might change the information in one place, and forget to change it in another Inconsistent data is known as garbage Worse than having no data at all Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

The Physical Database (cont'd) Keep Only One Copy of Information Avoiding duplication promotes internal consistency, but does not ensure that the information is correct Database information may be needed in several places Best to keep a master list and allow access Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

The Physical Database (cont'd) Keep a Separate Table and a Key Rather than repeating information, keep a separate table keyed with a unique identifier (foreign key) When information is needed, it can be looked up using the foreign key Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

The Database Schema The metadata of a database's tables is called its schema or scheme Structure and design Imagine a college having two tables defined in its schema, Student and Home_Base: Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Connecting Database Tables by Relationship The two tables are separate, but not independent The common Student_ID field connects them There is a relationship between the two entities Correspondence between rows Relationships are part of the metadata This is a two-way relationship (we can find the address for any student, or the student for any address) Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Reconstruction Using Join The relationship between the two tables allows us to construct a single table (Master_List) containing the combined information from both tables Use the natural join operation from Chapter 14 Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Designing a Database Schema Suppose the Dean's office and the sports center also need address information Define tables without using address, but with Student_ID as primary key Each new table has one-to-one relationship with Home_Base table, and with Student table (so the Dean or sports center could look up the students' names) Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Physical versus Logical Database From our set of four tables, we can create other tables customized to different campus units Logical database — does not physically exist Created fresh every time it is needed, using current values in the physical database Logical databases contain duplicate information, so we don't want to store them and create redundancy Personalized logical databases (database views) allow every user group to see the database in a different way Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Logical Database: Creating Views Views are the logical tables constructed by database operations from the physical table The operations that create views are called database queries Natural join is a query Every named table of a database is either a physical table, stored on the disk, or a logical table created by a query Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Creating a Dean's View Will include selected information from the physical tables Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Join Three Tables into One First step: Note that Dean's View contains information from three tables Join operation associates the information for each student You'd have all the information from all three tables for each student Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Trim the Table Retrieve only the columns the Dean wants to see Join-then-trim strategy is a standard approach A super table is formed by joining several physical tables Then they are trimmed down to keep only the information that is of interest to the user Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Creating a Sport's Center View Join Sports Center's view with its table and the administration table Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

A Query Language: SQL SQL (Structured Query Language): Widely used standard language Provides specific query structure for techniques like join-then-trim SQL varies (dialects) by vendor, but simple queries are roughly the same: SELECT List of fields FROM Table(s) WHERE Constraints on the rows Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

SQL ON Clause Following the SELECT is the list of fields the FROM has to Joins that have been grouped together (which field they are joined ON) Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

SQL WHERE Clause WHERE clause would set a condition (suppose the Dean only wanted to see students whose GPA is greater than 3.75) Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Entity Relationship Diagrams Creating new tables involves relationships The point of identifying relationships in a database schema is to indicate how the information is connected, and joins make these connections If there are relationships, they are likely to be applied when building the logical database Database administrators diagram the relationships to make the structure clear Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Entity Relationship Diagrams (cont'd) Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Entity Relationship Diagrams (cont'd) One-to-One Relationships Any row in the first entity is associated with at most one row in the other entity Many-to-One Relationships Many of the rows of the first entity can be associated with a single row in the second entity These types of relationships can de shown in different ways in ER diagrams Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.