Title: Creating a Database
1Chapter 2
Creating a Database
2Chapter 2 Overview
Chapter 2 gives you an in-depth look at tables
and their structure. Tables contain data and are
the heart of a database. They must be set up
correctly so that the entire database can perform
properly.
3Introducing Database Files
- Access database files are stored with an .mdb
extension. - They should have descriptive names, such as
- Customers (Customers.mdb)
- Music (Music.mdb)
- States (States.mbd)
4Introducing Database Files
Database files contain objects that work together
- Tables
- Reports
- Forms
- Queries
- Data access pages
- Macros
- Modules
5Creating Database Files
There are two ways to create a new database
- Design it yourself
- Creating a database yourself means you have to
make each database object, one at a time. - Use the Database wizard
- The wizard creates all objects from one of the
sample templates you select.
6Creating a New Database
- Click on Create a New File
- Choose Blank Database
7The Database Window
The Database window is the main launching point
for working with database objects.
Each group of objects has its own button.
Object names appear in the viewing area.
8Creating a Table
- Tables contain data and must be created before
other objects in the database.
You can create each table manually, or use the
Table wizard to make new tables.
9Design View Window
For creating or modifying a table.
Company Text Company Name
Tables are built manually by adding new fields,
one per line.
Fields are created by typing a field name, data
type and description for each one.
10Adding Fields
- Field name
- Should be descriptive.
- Can be up to 64 characters in length.
- Data Type
- Most fields are text type, but can be numeric,
date, yes/no, and so forth.
- Description
- Identifies field
- Optional
11Saving the Table Design
- Click on the Save button.
- Type a descriptive table name with the tbl
prefix. For example, tblProducts. - Assign a primary key, if you have determined one.
12Setting Field Properties
Field properties determine the appearance of
data, and the characteristics of the data entered
into the field.
For example A State field can be controlled with
properties
Property Setting Looks/Behaves Like Format All
Caps CO (instead of co) Required Yes Cant be
left blank Field size 2 CO (not COLORADO)
13General Properties
- Field Size
- Default Value
- Decimal Places
- Format
- Caption
- Input Mask
- Validation Rules and Validation Text
- Required, Zero Length, and Indexed
14Lookup Properties
- These properties determine how special fields
look and behave.
- For example, on a form
- Fields can have their contents restricted to a
specific list of values
- Yes/No fields can look like check boxes.
15Establishing a Primary Key
- The primary key uniquely identifies each record.
All tables should have one.
- While in Design view
- Select the primary key field
16Printing the Table Design
- Printing the table design gives you a list of
- Field names
- Data types
- Descriptions
- Properties
You should keep a printed copy for every table in
the database. Its helpful to have printouts when
modifying a database.
17 Modifying Table Design
- You can change fields and properties any time.
- Use the Design view.
- Be cautious when changing primary keys and their
properties. - (It could affect other tables.)
Change field names and properties only when
necessary. Queries, forms, reports, and other
objects that use the table may also need to be
modified.
18The Datasheet View
- This view is for viewing and modifying data.
19Comparing Datasheet and Design View
- Datasheet view is for entering and editing
records (data). - Design view is for entering and modifying field
names, data types, properties (table design ).
20Datasheet and Design View
Click buttons to switch between views
Design view button
Datasheet view button
21Entering Records
- Open the table in Datasheet view
- Click into the first field of the last record
- Use the Enter key, the Tab key or the mouse to
move between fields
22Working with the Datasheet
- You can
- Resize Columns
- Rearrange Columns
- Freeze Columns
- Hide Columns
- Print Records
23Closing and Exiting Access
- Choose the Close command from the File menu
- Or
- Choose the Exit command from the File menu
- Or
- Click the Close button