Courses/Computer Science/CPSC 203/CPSC 203 Template/Fall 2009 Teaching Assistants/F09 Thomas Burt/Lab 2.1

From wiki.ucalgary.ca
Jump to: navigation, search

Create a new blank database

  • Office Icon (upper left of window) -> New -> Blank Database
  • Change the File Name to "Inventory"
  • Click "Create"

Tables

Create new fields

  • First Name
  • Last Name
  • Email
  • Phone Number
  • Postal Code
  • CityID
  • Save the table
    • CTRL-S
    • Change the name to "Customers"

Create "Products" table

  • Select the "Create" tab from the menu at the top of the screen
  • Click "Table"
  • Add the following fields
    • Name
    • Price
    • Quantity in stock
  • Save the table
    • CTRL-S
    • Change the name to "Products"

Create Cities and Provinces table

  • Select the "Create" tab from the menu at the top of the screen
  • Click "Table"
  • Add the following fields
  • Name
  • Save the table
    • CTRL-S
    • Change the name to "Cities"


Table Relationships

Question: Why did we create a table for Cities? Why didn't we just create a "City Name" column in the Customers table?


Add relationships to the tables

  • Click the "Database Tools" tab -> Click the "Relationships" button
  • Add all the tables
  • Double click the 'City ID' field in the Customers table
  • Click the "Create New..." button on the right side of the dialog
  • Select the following fields:

relationship1.JPG


  • Click "OK" and then click "Create"

Forms

Now lets create a forms so we can enter customer data into the database.


  • Click the "Create" tab -> "Forms" pane -> "More Forms" pull-down menu
  • Click "Form Wizard"
  • Select the "Customers" table
  • Select all the fields except for Customer ID
  • Choose a layout and a style, or just click finish


It should look something like this: customers_form.JPG