Database Modeling MS Access
Database Modeling 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 Quality 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, B for ProductCode 9309, and E for
ProductCode 9754.
◼ Add a record to the Product datasheet with these field values:
◼ ProductCode: 9729
◼ OrderCode: EXO
◼ WeightCode: E
◼ Quality: X
◼ Price: 39,750
◼ BackOrdered: Yes
Data Integrity (PK Rule)
◼ No “null” value can be allowed.
◼ No two records can have the same primary key.
◼ No two SLC students can have same ID number.
◼ A PK can be “composite key”
◼ Example
◼ “Composite PK Example”
◼ More than one field can be used as a PK (composite)
Importing External Access Table and
Excel Worksheet
◼ Kyungsoo also wants you to include the Product and
Order Detail tables from the POD database in the
Firm database.
Importing External Access Table and
Excel Worksheet (con’t)
◼ And he 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.
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.
Expressions
The And
condition.
The Or
condition.
Creating And and Or conditions
in the design grid