Chapter 15 A Table with a View: Database Queries.

Slides:



Advertisements
Similar presentations
3/25/2017.
Advertisements

1 Senn, Information Technology, 3 rd Edition © 2004 Pearson Prentice Hall James A. Senns Information Technology, 3 rd Edition Chapter 7 Enterprise Databases.
Chapter 16 Unemployment: Search and Efficiency Wages.
Chapter 6 Cost and Choice. Copyright © 2001 Addison Wesley LongmanSlide 6- 2 Figure 6.1 A Simplified Jam-Making Technology.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 14 Money in the Open Economy.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 The Basics of Javascript Programming the World Wide Web Fourth.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Supply of Labor to the Economy: The Decision to Work
Chapter 13 INCOME INEQUALITY.
The Relational Model and Normalization (3) IS 240 – Database Management Lecture # Prof. M. E. Kabay, PhD, CISSP Norwich University
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 5 Author: Julia Richards and R. Scott Hawley.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
1 Chapter 40 - Physiology and Pathophysiology of Diuretic Action Copyright © 2013 Elsevier Inc. All rights reserved.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Relational Database and Data Modeling
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 6: Modular Programming Problem Solving & Program Design in.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.
ZMQS ZMQS
BT Wholesale October Creating your own telephone network WHOLESALE CALLS LINE ASSOCIATED.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Information Systems Today: Managing in the Digital World
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 18 Methodology – Monitoring and Tuning the Operational System Transparencies © Pearson Education Limited 1995, 2005.
ABC Technology Project
CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
Database Design Process
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Microsoft Access.
Chapter Information Systems Database Management.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Squares and Square Root WALK. Solve each problem REVIEW:
the Entity-Relationship (ER) Model
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques
Week 1.
We will resume in: 25 Minutes.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 12 View Design and Integration.
Copyright © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 15 2 k Factorial Experiments and Fractions.
1 Unit 1 Kinematics Chapter 1 Day
TASK: Skill Development A proportional relationship is a set of equivalent ratios. Equivalent ratios have equal values using different numbers. Creating.
Chapter 20 The ISLM Model. Copyright © 2007 Pearson Addison-Wesley. All rights reserved Determination of Aggregate Output.
How Cells Obtain Energy from Food
Copyright © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 14 Factorial Experiments (Two or More Factors)
Management Information Systems, 10/e
Chapter 14 Getting to First Base: Introduction to Database Concepts.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
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.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
A Table with a View: Database Queries
Database Structure Chapter 16.
Getting to First Base: Introduction to Database Concepts
A Table with a View: Database Queries
Getting to First Base: Introduction to Database Concepts
Getting to First Base: Introduction to Database Concepts
A Table with a View: Database Queries
Presentation transcript:

Chapter 15 A Table with a View: Database Queries

Copyright © 2006 Pearson Addison-Wesley. All rights reserved 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. 15-6

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: SELECTList of fields FROMTable(s) WHEREConstraints 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