Course: Introduction to Visual BASIC (CS 143)

Download Report

Transcript Course: Introduction to Visual BASIC (CS 143)

Data & Networks
Problem Solving with Computers
Data & Information
Data is facts and figures
Information is presented data
But, before we extract information
from data …
Data often needs to be organized
Questions & Queries
We often ask questions to obtain
information
The data we receive is organized such
that we can readily see it’s
information content
What about computers?
Questions & Queries
Database
Data organized to facilitate information
retrieval
Query
A question we ask of the database
Questions & Queries
What data would you need to answer
the following questions?
What percentage of students at WCSU
have at least a 3.0 GPA?
How many students graduated for each
of the past five years?
Objects & Attributes
An object is a “thing” we wish to work
with, such as …
Person
Sales receipt
Car
Music CD
Objects & Attributes
Objects in a collection share common
attributes with each other
Example:
Objects: Cars
Attributes: Make, Model, Year, Color, Price,
etc.
Attributes yield a method for describing
an object, but are not the final object
description
Objects & Attributes
Problem
Develop a set of six (6) attributes for
describing college students
Remember, the actual set of values for
these attributes should be unique for
each student
Fields & Records
Each object in a collection is
represented by a record in a
database
Each attribute identified for the
collection is represented by a one or
more fields
Database
A database is a
collection of
records
To be useful,
there should be
a one-to-one
correspondence
between objects
and records
Collection
Object
Record
Database
Models
Therefore …
A record is a model for an object
A database is a model for a collection of
objects
A database can consist of one or
more database files
Tables
Databases are often stored as tables
Each row in a table is a record
Each column in a table is a field
Each field has an associated datatype
and perhaps a length
Hmmm … almost sounds like fields are
variables, eh?
Tables
Used Cars
Field
Make
Model
Year
Color
Price
Subaru
Forrester
1996
Green
10000
Jeep
Cherokee
1995
Blue
5000
Chrysler
Horizon
1985
Tan
1000
Plymouth
Voyager
2002
Red
25000
Record
Try this!
Problem:
Create a simple table design for college
course sections
Select attributes that will yield a unique
record for each course section
Work in pairs
You have 15 minutes to complete this
exercise
Try this!
Primary key
One or fields that represent a unique
set of data for each record
How did you insure that each record
was unique?
Was there any duplicate data?
Database Management Software
Used to create and edit databases
Examples:
Microsoft Access
Filemaker Pro
Facilitates
Creation of tables
Data entry
Data retrieval
Microsoft Access
Demo
Exercise
Use Microsoft Access to implement
your database design for college
course sections
Relationships
Associations between two tables
Based on common field(s)
Often used to reduce errors and/or
duplication of data
Example:
Car Dealership Database
Tables
Models
Car Models
Cars
Cars
Example:
Car Dealership Database
Each car can be
associated with
one model
Each model can
be associated
with many cars
This is a one-tomany relationship
Models
Cars
1
n
Example:
Car Dealership Database
Sometimes, a
record in one
related file
cannot exist
without a record
in another file
Is that the case
here?
Can you imagine a
situation where
this was true?
Models
Cars
1
n
Example:
Car Dealership Database
A common
field(s) is
required to
form the link
between two
related files
Models
Model ID
:
Cars
1
Model ID
n
:
Example:
Car Dealership Database
Models
Cars
Model ID
VIN
Name
Year
Model ID Ext Color
Style
List Price
Int Color List Price
Do this for homework!
Queries
A structured question “asked” of a
database
Examples:
How many cars were sold in January?
What cars were sold in January?
Were any cars sold in March?
What is the data type for each
answer?
Networks