Download presentation
Presentation is loading. Please wait.
Published byProsper McDaniel Modified over 9 years ago
1
Connecting (relating) Data Tables to get Custom Records (Queries) Database Basics
2
Tables not just Records S13 MIS 2 “Factoring” Data into smallest logical records a.k.a. Normalizing i.e. no record has duplicated data Try sketching Tables and Relations for Name, phone, bought vitamins, during visit the week of 9/20 (there’s another Recall!)
3
Tables for Minimal Records S13 MIS 3 Tables Name, Address, phone, age, gender Purchased item, date Visit date, time How to “connect” the tables? Primary Keys (PK) for each table – unique for every entry Add a PK from another table as a “Foreign Key” (FK) This connecting is called “Relating” tables
4
While You’re at It S13 MIS 4 Metadata – data about data Add metadata to every field in every table
5
Getting to the Data S13 MIS 5 No single record exists in DB, but relations among tables allow ANY record from connected tables to be built “automatically.” Tool to do this is a ‘Query’ e.g. select name, visitdate from clients, visits; Structured Query Language (SQL) not for faint of heart
6
About that Recall! S13 MIS 6 Given Client, Sale, and Visit Tables and Relations connecting them Query: select clients, phone, visitdate (the custom rec) where these are true (query criteria) client=visitclient and visit=salevisit and saleitem = wonderlife vitamins and visitdate between 9/20 and 9/27
7
More Formally Building and Relating Tables S13 MIS 7
8
Metadata for Client Table S13 MIS 8
9
Data for the Client Table S13 MIS 9
10
Metadata for Visit Table S13 MIS 10
11
Data for Visit Table S13 MIS 11
12
Relating the Tables S13 MIS 12
13
Query Design S13 MIS 13
14
Query Executed S13 MIS 14
15
Access Interface S13 MIS 15 See Tables, Queries, etc.
16
Access Ribbon Tools S13 MIS 16
17
Design and Data Views S13 MIS 17 Data Showing Design Showing
18
Multiple Tables Minimize Redundancy S13 MIS 18 Find redundant data fields. (same data in two places) Why AREN’T key fields redundant?
19
Data Validity and Checking S13 MIS 19 Design View of Tables allows specification of detailed data type, default, validation and other field characteristics. How would you set the type of animal to default to DOG?
20
Relating Tables S13 MIS 20 Relationships are under Database Tools What do you think the 1 and ∞ mean? Identify the PK’s and FK’s
21
Query Tool for SQL S13 MIS 21 Specify a query to show clients, visit date, and cost of visit. Fill in the Fields
22
Access Query S13 MIS 22 To Work right: tables and relationships above the Fields and Tables below show field checks any criteria All must be correct
23
SQL for Query S13 MIS 23 Standard Query Language for this query showing the fields to display (line1) the tables to get them from (line2) and the criteria for selecting (line3)
24
Criteria for Query S13 MIS 24 Add criteria to see only visits in 2003 and 2006 N.B. You don’t have a “year” field so you’ll have to use full dates. e.g. #1/1/2003#
25
Grouping and Computation S13 MIS 25 ∑ turns on “Total” row only Group By and Computed columns may “show”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.