16
Defining Relational Databases What is an Access database? How do you create an Access database? How do you create and modify tables in Access? How do you add data to Access tables? How do users interact with Access databases? How do you create user interfaces? How are relationship types represented in Access?

Copyright © 2003 Addison-Wesley Defining Relational Databases What is an Access database? How do you create an Access database? How do you create and modify

  • View
    217

  • Download
    1

Embed Size (px)

Citation preview

Defining Relational Databases

• What is an Access database?• How do you create an Access database?• How do you create and modify tables in Access?• How do you add data to Access tables?• How do users interact with Access databases?• How do you create user interfaces?• How are relationship types represented in Access?

What is an Access Database?

• An Access database is a relational database– Collection of tables

– Each table is defined by a relation schema

– The whole database is defined by a database schema

– The information content of the database is the rows of the tables

• An Access database is also a collection of user interfaces and tools– Forms for creating and modifying tables and other database objects

– Wizards that help users create objects

– Forms created by users that allow access and modification of the contents of tables

• Chapter 7 will focus on additional topics in manipulating content– Queries that collect and display the contents of one or more tables

– Forms created by users that support complex data operations

Sample Access Database Display

Creating Access Databases

• An Access database is a file– E.g. mydatabase.mdb

– Create a database by telling Access to create a file

• Screen shot is Access with new (empty) database– 3 options for creating tables

Creating Tables

• Create table in design view– New table is ready for adding columns

Customer Table Design View

• Schema: Customer (accountId string, lastName string, firstName string, street string, city string, state string, zipcode string, balance number)

– Many characteristics specified including: name, type, description and key

Defining Multi-attribute Keys

• Select all key attributes and click key symbol

Creating and Modifying Table Contents

• Datasheet view shows contents of table– Simply click and type to enter and modify data– Add new rows by typing in last row

• Updates to database become permanent when cursor moves off row– Move cursor by click or tab– Close window– Change focus to other window

Creating Forms for Tables• Select “Create form by using wizard” from Forms tab• Select source table from drop-down control• Move attributes from left to right panel

Selecting Form Layout and Style

• Types of forms– Datasheet, seen previously

• rows and columns

• 1st row is column names

– Columnar

• label and value for each attribute

• arranged in columns

• One row per page

– Tabular, like datasheet, but with separation of values

– Justified, like columnar, but arranged in rows

Specifying Relationship Types

• Relationship tool is used to specify relationship types– Add tables to display– Drag and drop attribute names to create connections

• Schema: Rental: (videoId references Video, dateDue date, dateRented date, cost currency, accountId number references Customer)

Specifying Relationship Types

• To open properties dialog for relationship type– Right click on connection, select “Properties”

• Set “Enforce Referential Integrity” to specify relationship type– “Cascade” fields refer to what happens when key values are modified or deleted

Viewing Relationship Types

• The Relationship tool shows characteristics of relationship types and roles– To-one relationship role

has a 1

– To-many relationship role has a ∞ (infinity symbol)

– What about many-to-many relationships?

Case in Point

• Creating an Access database for BigHit Online– Review database schema for BigHit Online

• Figure 5.27, repeated as Fig. 6.26– Create Access database– Define tables– Specify relationship types– Create forms to add and modify table data– Add sample data– Evaluate resulting database for clarity, accuracy, and

completeness

Database Schema for BigHit Online

• Customer: (accountId number, lastName string, firstName string)• Sale: (saleId number, dateSold date, totalCost number, creditCardType

string, creditCardExpiration date, creditCardAccountNumber number, accountId number references Customer)

• Movie: (movieId number, title string, genre string)• ShoppingCart: (cartId number, dateCreated date, accountId number

references Customer) • SaleItem: (saleId number references Sale, movieId references Movie,

quantity number)• CartItem: (cartId number references ShoppingCart, movieId references

Movie, quantity number)• CreditCards: (accountId number references Customer, accountNumber

number, type string, expiration date)• ShippingAddresses: (accountId number references Customer, street string,

city string, state string, zipcode string)• DVD: (movieId number references Movie, videoFormat string, languages

string, captioning string)• Videotape: (movieId number references Movie, format string, soundtrack

string)

Tables and Relationship Types for BigHit Online