Professional Documents
Culture Documents
Ms Access
Ms Access
BillingDate Date/Time
InvoiceAmt Currency
Adding Records to a Table
Enter data sequentially in Datasheet view
Do not jump from field to field
Use tap key to enter data
Add following data to each filed: 211, 201, paid (mark the
Add a new field between the CoffeeCode and Price fields, using these
properties;
Field Name:WeightCode
Data Type: Text
Description: foreign key
Field Size: 1
Move the Decaf field so that it appears between the WeightCode and
Price fields.
Practice: Updating a Table
Enter these WeightCode values for the three records: A for
ProductCode 2316, A for ProductCode 9309, and E for
ProductCode 9754.
Add a record to the Product datasheet with these field values:
ProductCode: 9729
CoffeeCode: COLS
WeightCode: E
Decaf: D
Price: 39.75
BackOrdered: Yes
Data Integrity (PK Rule)
No “null” value can be allowed.
No two records can have the same primary key.
No two CSUB students can have same ID number.
A PK can be “composite key”
Example on class web page
“Composite PK Example”
More than one field can be used as a PK (composite)
CSUB: student ID + SS#
Referential Integrity (FK Rule)
A field that connects one table logically with another
table.
Exception example on class web page
“PK as FK” there are two tables…
Related table: Shipping Address table
Primary table: customer table
Importing External Access Table and
Excel Worksheet
Barbara also wants you to include the Product and
Order Detail tables from the FineFood database in
the Restaurant database.
Download and Review design view of FineFood
DB first
Importing External Access Table and
Excel Worksheet (con’t)
And she wants you to include the Billing Address
Excel worksheet as a Access table in the Restaurant
database.
Before try to import the excel file, review it first
Use Excel column headings for Access table
PK: CustomerNum
Specify in the description area of Design View that
CutomerNum is not only primary key of
BillingAddress table but also a foreign key of
Customer table.
Access is a relational database
Access allows you to form relationships between the
tables; that’s why it’s called a relational database
The simplest way to create a relationship
Look for identical field names between tables.
Tables can be joined in three ways; one-to-one, one-
to-many, and many-to-many.
An example of a
one-to-many relationship
The Employer table is related to the Position table via the common field EmployerID.
Customer Table
CustomerNum CustomerName Street City State ZipCode OwnerName Phone FirstContact
000 Choi COB 105 CSUB CA 93311 Scott Choi 5348 09/20/2001
Order Table
OrderNum CustomerNum Paid InvoiceAmt BillingDate
201 107 No 854.00 01/15/2001
Product Table
ProductCode CoffeeName Weight/Size Price Decaf
2301 Colombian Aged Crop 1 lb pkg 7.99
More about a Query
When you use the query design window, you use
Query By Example (QBE).
Do not include any unnecessary tables or queries in
Design View of the query.
Otherwise, you have to deal with unexpected problems.
In your midterm, you will be penalized if you include
unnecessary tables or queries.
Always use a primary table.
CustomerNum: Customer vs. BillingAddress
Restrictions can be used as well.
Creating Queries using
Multiple Tables
Since there have been some major changes in the
Restaurant database, Barbara wants to make sure
that the database is reliable. In order to test the
reliability of database query function, She wants
you to generate a query. The query must include
following fields: Order Number, Coffee Name,
Quantity, Price, and Weight/Size.
Save as Test
Should select OrderNum from the Order table
(primary table)
Querying and Sorting of
multiple Tables
Barbara wants to have following information for the
upcoming quarterly report: CustomerName, City,
State, BillingDate, InvoiceAmt, Paid, and First
Contact.
At same time, Barbara wants to sort the records by
the InvoiceAmt field in ascending order.
Barbara also wants to move the Paid field between
the State and BillingDate field.
Save as Customer Orders
Expressions
The And
condition.
The Or
condition.
Creating And and Or conditions
in the design grid
The subform
navigation bar.