IE 423 – Design of Decision Support Systems Database development – Relationships and Queries.

Slides:



Advertisements
Similar presentations
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Advertisements

With Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
Tutorial 3 Queries and Table Relationships
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
SUNY Morrisville-Norwich Campus-Week 10 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Querying a Database Microsoft Office Access 2003.
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.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Computer Science & Engineering 2111 Introduction to Database Management Systems Relationships and Database Creation 1 CSE 2111 Introduction to Database.
Define Table Relationships—1 of 3 One of the most powerful features of a relational database management system, such as Access, is its ability to define.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
IE 423 – Design of Decision Support Systems Database development – Relationships and Queries.
Microsoft Access Lesson 3
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
Primary & Foreign Keys. PK & FK 1.Primary key is required 2.The PK must be unique 3.If the primary key from one table is related to a field in another.
Microsoft Access – Tutorial 3
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
CS&E 1111 AcInnerJoins Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Analyzing Data For Effective Decision Making Chapter 3.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 9 – Building Links,
Office Management Tools II Ms Saima Gul.  When you create your tables, you should assign each table a primary key—one or more fields whose contents are.
WEEK 11 Database Design. TABLE INSTANCE CHARTS Create Tables.
Access Chapter 2: Relational Database Objectives Design data Create tables Understand table relationships Understand data types, key, & field properties.
Database Design. Referential Integrity : data in a table that links to data in another table must always work in such a way that following the link will.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
Microsoft Access Intro Class 6 Relationships.
Using Microsoft Access 56:150 Information System Design.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
M1G Introduction to Database Development 5. Doing more with queries.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making Chapter.
Tutorial 9 Using Action Queries and Advanced Table Relationships.
Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
Maintaining a Database Access Project 3. 2 What is Database Maintenance ?  Maintaining a database means modifying the data to keep it up-to-date. This.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Relational Database Techniques
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
© 2001 ComputerPREP, Inc. All rights reserved. Access 2000: Module II.
D1 FMA Review. Many-to-Many Relationships - Examples Car Hire –A customer may hire one or more cars –A car may be hired by one or more customers Gym Club.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Exploring Microsoft Access Chapter 5 One-to-Many Relationships: Subforms and Multiple Table Queries.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
Chapter 6 Many-to Many Relationship. Agenda AutoNumber Many-to-many relationship Cascaded updating and deleting Auto Lookup Parameter query Total query.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Microsoft ® Office 2007 PowerPoint Lecture to Accompany.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Tables & Relationships
Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data Integrity Cascade Update.
Objectives Query for top values Create a parameter query
Objectives Create an action query to create a table
Microsoft Office Access 2003
Insert, Update, Delete Manipulating Data.
Microsoft Office Access 2003
Relational Queries (query 12) Display vendor contact info (contact person and phone number) for inventory products (relationship query) Query: Inventory.
Tutorial 9 Using Action Queries and Advanced Table Relationships
Presentation transcript:

IE 423 – Design of Decision Support Systems Database development – Relationships and Queries

Important Events 0 days to St. Patrick’s Day Happy St. Patrick’s Day 2 days to deadline for DSS Analysis Report 4 days to Spring Break

Neighbor08a.mdb

Remember that we split our House Survey data into two relations (tables) …so now we need to create a table for the rest of the data Don’t forget that each record must have a unique house identifier …and what we will use this for?

New tables for Neighbor08 database

Neighbor08a.mdb Make a relationship between these two tables How do you do this? What kind of relationship is this?

Neighbor08a.mdb Then, we are also interested in who lives in these houses… …so create another table for people You will need – PersonID HouseID –to tell which house they live in FirstName LastName DOB (what data type?) CellPhone (use an input mask)

Neighbor08a.mdb

Make a relationship between what two tables? How do you do this? What kind of relationship is this?

Referential Integrity – what does it really mean? When we have a one-to-many relationship, we might call the table on the one side the parent table,… And the table on the many side the child table And for any given relationship, we can call the primary/foreign key pair in the related tables linking fields Referential Integrity – all foreign key values in a child table must come from (match) primary key values in the parent table

Referential Integrity – what does it really mean? Referential Integrity – Five Rules The Linking field in the parent table must be a primary key or must be indexed with unique value entries Linking fields must be of the same data type, exception autonumber and number (with length=ReplicationID) When you enforces Referential Integrity no existing records in the tables can violate referential integrity With Referential Integrity enforced, no record can be deleted where its key value matches a value use in foreign key in the child table With Referential Integrity enforced, we cannot change values of the linking field in the parent table there is a corresponding value in the linking field of the child table

College.mdb

Referential Integrity – what does it really mean?

Cascading So, how do we do these things? Access helps Cascading Deletes  If you delete the record in the parent table that contains the Primary key value, access will automatically delete matching records in the child table  Think about this Cascading Deletes  If you change a primary key value in the parent table, Access will automatically change the corresponding foreign key values in all records in child table

College.mdb Suppose you need to create a course registration system for college courses (or workshops, etc.) What are the objects that you need to work with? Students, Courses, ??? So, you have a table of students You have table of courses How do you relate these two tables? Does this present any problems?

College.mdb Solution – create two one-to-many relationships,… …but to do this you are missing something – What?

College.mdb ***Open College.mdb Build a registration system Enroll students in courses Any student can be in one or more courses Any course can have one or more (or zero) students

College.mdb Build a Registrations table In general terms this is sometimes called a linking table

College.mdb Define the relationships between Students & Registrations Courses & Registrations Register students for courses

Queries You’ve built tables,… You’ve added data… So, how do you use this data Queries (at least that’s one answer)

Queries Queries retrieve and, maybe, manipulate data in your database Several kinds of queries Select Query – retrieves data from tables  Simple Query – from a single table  Complex Query – from multiple tables Parameter Query – dynamic input of criteria Crosstab Queries – statistical aggregation of data …

Queries Several kinds of queries (…continued) Action Queries – operate on data in a table or multiple tables  Delete Queries – delete records based on selection criteria  Update Queries – modify field values based on selection criteria  Append Query – appends records from other tables to existing table

Queries Select Queries Single table query

Queries Select Queries Single table query Similar to defining a table, … …except query field come from other table fields (or other queries) To build a query you need  To create column (fields)  Pick the table from which to pull the field (no really an issue in a simple query  Sort or not  Show field or not  Define Select criteria

Queries Select Queries Fields and tables drag and drop Sort – left to right order – if checked Show – do you want to see it? Criteria  Logical test for record selection Criteria in multiple columns – “AND”ed Logical OR – add criteria to more rows

Queries Select Queries Build a simple query to Select all Senior Industrial Engineering students Select all Seniors and Juniors Select all Senior I.E. student and all Juniors

Queries Select Queries Build a simple query to Select all Senior Industrial Engineering students Select all Seniors and Juniors Select all Senior I.E. student and all Juniors

Queries Select Queries Complex Queries  Similar to simple queries, except…  Add more tables to the design grid  Tables need relationships  …may be already defined,…  …or you can design them in the query design grid

Queries Select Queries Complex Queries  Connecting multiple tables in a query is called a join operation  Two major kinds of joins Results include records from both source tables only if records match, otherwise not included Inner Join Include a selected record from one table (regardless of whether it has a match in the other table) and records from the other table that match records in the first table Outer Join

Queries Select Queries Complex Queries  OK, so what is a left outer join vs. a right outer join?