Download presentation
Presentation is loading. Please wait.
Published byJason Morris Modified over 8 years ago
1
Southern Methodist University CSE 2337 1 CSE 2337 Introduction to Data Management Chapter 2
2
Southern Methodist University CSE 2337 2 Overview The Relational Model Relations vs. Tables Queries Query-by-example Relational Algebra
3
Southern Methodist University CSE 2337 3 Relational Database A relational database is a collection of relations –Each entity has is represented by its own relation –Each attribute is a field or column in that relation –Relationships are common attributes in two or more relations
4
Southern Methodist University CSE 2337 4 Relation Two dimensional grid in which: –Entries are single-valued –Each column (field or attribute) has a distinct name –All values in a column represent the same attribute –Order of columns and tuples are immaterial –Each tuple is distinct
5
Southern Methodist University CSE 2337 5 In Access (and other DBMSs) Relation is represented as a table Attributes are represented as columns in the table Order of columns rows in the table is immaterial
6
Southern Methodist University CSE 2337 6 Common Notation for Tables Name of table List attributes of table in parentheses Rep (RepNum, LastName, FirstName, Street, City, State, Zip, Commission, Rate)
7
Southern Methodist University CSE 2337 7 SMU Student (StudentID, FirstName, LastName) Professor (FacultyID, FirstName, LastName) Class (ClassNum, Department, FacultyID) Enroll (StudentID, ClassNum, Semester)
8
Southern Methodist University CSE 2337 8 Primary Key The column or collection of columns that uniquely identifies one row in a table from all other rows in that table. Identify the primary keys in the Premier Products Database.
9
Southern Methodist University CSE 2337 9 Premier Products Sample Data
10
Southern Methodist University CSE 2337 10 Premier Products Sample Data
11
Southern Methodist University CSE 2337 11 Query A question posed to a DBMS in a form or way in which the DBMS can understand and process the question
12
Southern Methodist University CSE 2337 12 Query Example Find all order numbers for Customer 608 SELECT OrderNum FROM Orders WHERE CustomerNum = 608 SQL
13
Southern Methodist University CSE 2337 13 SQL Structured Query Language –Entire computer programming language that allows one to ask simple and sophisticated questions to the DBMS Based on Relational Algebra Operations Focus of Chapter 3……
14
Southern Methodist University CSE 2337 14 Query-By-Example aka QBE Visual/Drag-and-drop approach to writing queries in a RDBMS One of the methods available in MS- Access to write queries
15
Southern Methodist University CSE 2337 15 The Query Window in Access Execute Query Table Fields
16
Southern Methodist University CSE 2337 16 Simple Criteria Criteria - conditions that data must satisfy Criterion - a single condition To display specific query results, enter the condition in the appropriate column in the design grid
17
Southern Methodist University CSE 2337 17 Query with Simple Criteria
18
Southern Methodist University CSE 2337 18 Comparison (Relational) Operators Helps find something other than exact match Relational Operators are: = > < >= <= NOT (not equal to)
19
Southern Methodist University CSE 2337 19 Query With Comparison Op
20
Southern Methodist University CSE 2337 20 Compound Criteria Combines comparison operators AND / OR used between simple criteria AND - both criteria must be true OR - overall criterion is true if either of the individual criteria is true
21
Southern Methodist University CSE 2337 21 Query Using AND
22
Southern Methodist University CSE 2337 22 Query Using OR
23
Southern Methodist University CSE 2337 23 Using Computed Fields Computed field /attribute is one that can be computed on-the-fly rather than stored in the database Can be included in queries when needed Use square brackets if field name contains spaces
24
Southern Methodist University CSE 2337 24 Query with Computed Fields
25
Southern Methodist University CSE 2337 25 Query With Computed Field Right-click the column in the Field row and choose Zoom
26
Southern Methodist University CSE 2337 26 Calculating Statistics Count Sum Avg Max Min StDev Var First Last Built-in statistics (called aggregate functions in Access):
27
Southern Methodist University CSE 2337 27 Example with Statistics
28
Southern Methodist University CSE 2337 28 ?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.