Post on 15-Jul-2018
CS 200
CS 200 Fall 2014 Database Introduction1
Lecture 06Database Introduction
CS 200 Fall 2014 Database Introduction
Abbreviations• aka also known as• DBMS DataBase Management System• mutatis mutantis with the necessary changes having been made
2
Miscellaneous Notes
CS 200 Fall 2014 Database Introduction
Please read and highlight BEFORE lab• Assignment 5• This week’s lecture slides
Reading • Database Design (learn.uwaterloo.ca)
Adapted from Access Database Design and Programming by Steven Roman
Today• Database basics and Design• Creation of a database• Reports and Queries• Relationships
Please ask questions!
3
Administrivia
CS 200 Fall 2014 Database Introduction
AssumptionsYou have used a database before
You understand basic data management
4
CS 200 Fall 2014 Database Introduction
Things to think about• What are the data objects in FileMaker?• How does the interface differ from other applications we have seen so far?• What are the efficiencies and deficiencies of the interface?• What are different databases you use?• How are the databases you are part of used?• Is the way data is displayed important?
5
CS 200 Fall 2014 Database Introduction
This is your first pass at FileMaker by the end of this section you will be able to:• design a simple database• create queries and reports• understand database terminology and• create relationships with a database
Our objectives are• to introduce you to database fundamentals• Expose you to an application specific to database – FileMaker
6
Databases–FileMaker
CS 200 Fall 2014 Database Introduction
A collection of related data
Data consists of information on a specific topic•
7
What is a Database?
CS 200 Fall 2014 Database Introduction
Use of DatabasesWhat databases are you a part of?
What are some of the benefits of belonging to a database?
What are some of the drawbacks?
Why/when do I use a database?
How are the databases I am part of used?
8
CS 200 Fall 2014 Database Introduction
Field
Record
Table
File
9
FileMaker Terminology (1)
CS 200 Fall 2014 Database Introduction
FileMaker Terminology (2)Layout
Report
Query
10
CS 200 Fall 2014 Database Introduction
Creation of a TableConsider the following example:
You would like to create a database with all of the Albums you have downloaded onto your iPod.
What info would be relevant to have in a table?
What types of fields will each of these be?
11
CS 200 Fall 2014 Database Introduction
Creating a Database
12
CS 200 Fall 2014 Database Introduction
Creating A DatabaseCreation of a new database is similar to other applications
File: New Database
13
CS 200 Fall 2014 Database Introduction
Creating a Table within our Database
14
CS 200 Fall 2014 Database Introduction
Defining Fields
15
CS 200 Fall 2014 Database Introduction
Data Validation
16
CS 200 Fall 2014 Database Introduction
You can’t mistype something that’s entered for you!
17
Data Validation in FileMaker (1)
CS 200 Fall 2014 Database Introduction
An Important Principle:
18
Data Validation in FileMaker (2)
It’s easier to catch & correct errorswhen data are enteredthan it is to find and correct them later
CS 200 Fall 2014 Database Introduction
Album Table Field Definitions
19
Field Name Field Type OptionsAlbum TitleAlbum Type
MediumRecording Year
LabelPurchase PriceAlbum Artist
Purchase Date
TextTextText
NumberText
NumberTextDate
Value List (TP, CD, LP, MP3)Value List (Jazz, Blues, Rock, )
Range (1921-2010), Number
Number
Date
CS 200 Fall 2014 Database Introduction
Uniquely Identifying RecordsPrimary Key
20
CS 200 Fall 2014 Database Introduction
Browse
Find
Layout
Preview
•
21
Modes in FileMaker
CS 200 Fall 2014 Database Introduction
Browse Mode
22
CS 200 Fall 2014 Database Introduction
Layout Mode
23
CS 200 Fall 2014 Database Introduction
Creating a New Layout
24
CS 200 Fall 2014 Database Introduction
New Layout 2
25
CS 200 Fall 2014 Database Introduction
New Layout 3
26
CS 200 Fall 2014 Database Introduction27
At the top of every page Headerprinted onceon each page
Repeated for Every Record BODYprinted oncefor each group
At the bottom of every page Footerprinted onceon each page
Organization of a Report Layout
CS 200 Fall 2014 Database Introduction
Note especially the difference between• how a data value appears on a form
eg 3.14• and what’s stored in the database
eg 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582
& note the menu items that control the appearance of each data type
28
The Format menu...
Formats in FileMaker
CS 200 Fall 2014 Database Introduction
Find Mode
29
CS 200 Fall 2014 Database Introduction
Preview Mode
30
CS 200 Fall 2014 Database Introduction
More than one Table in a DatabaseSongs Table
31
Song Table Album TableSong ID
Song TitleSideTrackMinsSecs
Song Album ID
Album TitleAlbum Type
MediumRecording Year
LabelPurchase PriceAlbum Artist
Purchase Date
Album IDPrimary Keys
Foreign Key
CS 200 Fall 2014 Database Introduction
Creating a Relationship in FileMaker
32
CS 200 Fall 2014 Database Introduction
Types of Relationships
One to One
One to Many
Many to One
Many to Many
33
CS 200 Fall 2014 SQL
Album ID • is a “primary key” for the Album Table
because it uniquely identifies an album • is a “foreign key” of the Songs Table
because it contains a primary key of the Album Tableand thus links a Song record to a unique Album record
“One-to-many” and “many-to-one” • wrt Album ID
Albums is the “one table” • Songs is the “many table” because for a given Album ID
there is only ONE Album record — but are (usually) MANY Song records
• “many-to-many” can happen, too — though not by matching a primary key in each of two tables! — it is often useful
• we’ll see an example next week
34
Terminology
CS 200 Fall 2014 Database Introduction
Displaying Info from a Many to One Relationship
35
Field Tool in Layout Mode
CS 200 Fall 2014 Database Introduction
Many to One (2)
36
CS 200 Fall 2014 Database Introduction
One to Many
37
Portal Tool
CS 200 Fall 2014 Database Introduction
One to Many (2)
38
CS 200 Fall 2014 Database Introduction
You can define as many layouts as you want• these are also called “views” of the data (SQL-speak)• give them meaningful names!!!
You don’t have to include all fields on all layouts• defining a new field doesn’t cause it to appear on all layouts• by default, a new field is placed on the “current layout,”
although there’s a preference to prevent that
In FileMaker• data entry options are associated with a field’s definition• the appearance of a field is specified on the layout, and can vary• other databases may choose different conventions
39
Things That Might Confuse You in FileMaker