SECTION 2 SKILLS Creating Tables and Relationships

46
Skil ls © Paradigm Publishing, Inc. 1 Skil ls © Paradigm Publishing, Inc. 1

description

SECTION 2 SKILLS Creating Tables and Relationships. 2.1 Understand Table Design Principles 2.2 Create a New Database 2.2 Create a Table 2.3 Create a Table in Design View 2.3 Set the Primary Key CHECKPOINT 1 2.4 Modify the Field Size Property 2.4 Modify the Caption Property - PowerPoint PPT Presentation

Transcript of SECTION 2 SKILLS Creating Tables and Relationships

Page 1: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 1 Skills© Paradigm Publishing, Inc. 1

Page 2: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 2 Skills© Paradigm Publishing, Inc. 2

SECTION 2 SKILLSCreating Tables and Relationships

2.1Understand Table Design Principles

2.2 Create a New Database

2.2 Create a Table

2.3 Create a Table in Design View

2.3 Set the Primary Key

CHECKPOINT 1

2.4 Modify the Field Size Property

2.4 Modify the Caption Property

2.4Modify the Default Value Property

2.5 Validate Field Entries

2.6 Create Input Masks

2.6 Format a Field

2.7 Create a Lookup List

2.8 Insert, Move, and Delete Fields

2.8 Insert a Total

CHECKPOINT 2

2.9 Understand Relationships

2.9 Use the Relationships Window

2.10 Create a One-to-Many Relationship

2.11 Create a One-to-One Relationship

2.12 Print a Relationships Report

2.12 Delete a Relationship

2.12Display Records in a Subdatasheet

CHECKPOINT 3

Page 3: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 3

Understand Table Design Principles

To design a new table:1. Analyze the required data

elements.2. Break down the data into

the smallest unit.3. Create a field name.4. Assign each field an

appropriate data type.5. Identify the field suitable

for the primary key.6. Assign a name for the

table.

sample data

Page 4: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 4

Understand Table Design Principles…continuedA field name can be up to 64 characters including a combination of letters and numbers. Some symbols are permitted but others are excluded, so it is best to avoid symbols other than the underscore character which is often used as a word separator.Do not use a space in a field name. Although a space is an accepted character, most database designers avoid using spaces in field names and object names. This practice facilitates easier management of the data with scripting or other database programming tools. Use compound words for field names or the underscore character as a word separator. For example, a field to hold a person’s last name would be named LastName, Last_Name, or LName.Abbreviate field names so that the names are as short as possible while still readily understood. For example, a field such as ContactLastName could be abbreviated to ContactLN or a field such as Telephone to Phone. Shorter names are easier to manage and type into expressions.

Page 5: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 5

Understand Table Design Principles…continuedData Type DescriptionText Alphanumeric data up to 255 characters in length, such as a

name, address, or value such as a telephone number or social security number, that is used as an identifier and not for calculating

Memo Alphanumeric data up to 64,000 characters in lengthNumber Positive or negative values that can be used in calculations;

do not use for values that will calculate monetary amounts (see Currency)

Date/Time Use this type to that ensure dates and times are entered and sorted properly

Currency Values that involve money; Access will not round off during calculations

AutoNumber Access automatically numbers each record sequentially (incrementing by 1) when you begin typing a new record

Page 6: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 6

Understand Table Design Principles…continuedData Type DescriptionYes/No Data in the field will be either Yes or No, True or False, On

or OffOLE Object Used to embed or link objects created in other Office

applicationsHyperlink Field that will store a hyperlink such as a URLAttachment Use this data type to add file attachments to a record such

as a Word document or an Excel workbookCalculated The contents of a calculated field are generated by Access

from an expression you create; for example, a total cost could be calculated by adding a price plus a sales tax column

Lookup Wizard Can be used to enter data in the field from another existing table or display a list of values in a drop-down list for the user to choose from

Page 7: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 7

Create a New Database

To create a new database:1. Start Access.2. Click the Browse button.3. Navigate to the desired

drive and/or folder.4. Type the file name in the

File Name text box.5. Click OK.6. Click the Create button.

Create button

File Name text box

Page 8: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 8

Create a Table

To create a table:1. Click the desired data

type in the Add & Delete group in the Table Tools Fields tab.

2. Type the field name and press Enter.

steps continued on next slide…

Add & Delete group

field name

Page 9: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 9

Create a Table…continued

3. Click the desired field data type in the drop-down list.

4. Type the field name and press Enter.

5. Repeat Steps 3-4 for the remaining columns.

6. Click the Save button on the Quick Access toolbar.

7. Type a table name at the Save As dialog box.

8. Press Enter or click OK.

field data type drop-down list

table name

Page 10: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 10

Create a Table…continued

To type data in the fields:1. Click in any empty cell

below a column heading to close the Click to Add column.

2. Click in the empty cell.3. Type the desired text.4. Press Tab or Enter to

move to the next field.5. Continue typing the data

for the remainder of the fields.

typed data

Page 11: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 11

Create a Table…continued

To switch to Design view:1. Click the View button in

the Views group of the Home tab.

View button

Design view

Page 12: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 12

Create a Table in Design ViewTo create a table in Design view:1. Click the Create tab.2. Click the Table Design button

in the Tables group.3. Type the field names, change

the data types, add descriptions, or modify other field properties as desired.

4. Assign a primary key.5. Click the Save button in the

Quick Access toolbar.6. Type a table name.7. Click OK.

field in Design view

Table Design button

Page 13: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 13

Set the Primary Key

To assign a primary key:1. Open the table in Design

view.2. Make the desired primary

key field active.3. Click the Primary Key

button in the Tools group in the Table Tools Design tab.

4. Click the Save button in the Quick Access toolbar.

Primary Key button

Page 14: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 14

CHECKPOINT 11) A field name can be how many

characters long?a. 24b. 36c. 48d. 64

3) In addition to creating a table in datasheet view, a table can be created in this view.a. Editb. Print Previewc. Designd. Structure

2) This is the name of the field that Access creates automatically in new tables.a. ABb. IDc. IAd. IB

4) The primary field is indicated in Design view by this icon.a. plus signb. minus signc. keyd. circle

Next Question

Next Question

Next Question

Next Slide

Answer

Answer

Answer

Answer

Page 15: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 15

Modify the Field Size Property

To set the field size:1. Open the table in Design

view.2. Click in the desired field

row.3. Select the current value in

the Field Size property box.4. Type a maximum number

of characters for the field.5. Click the Save button in the

Quick Access toolbar.

Field Size property box

Page 16: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 16

Modify the Caption Property

To add a caption:1. Open the table in Design

view.2. Click in the desired field

row.3. Click in the Caption

property box.4. Type the desired field

label.5. Click the Save button in

the Quick Access toolbar.Caption property box

Page 17: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 17

Modify the Default Value Property

To set a default value:1. Open the table in Design

view.2. Click in the desired field

row.3. Click or select the current

entry in the Default Value property box.

4. Type the default value.5. Click the Save button in

the Quick Access toolbar.Default Value property box

Page 18: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 18

Validate Field Entries

To create a validation rule:1. Open the table in Design

view.2. Click in the desired field row.3. Click in the Validation Rule

property box.4. Type the statement.5. Click in the Validation Text

property box.6. Type the error message.7. Click the Save button in the

Quick Access toolbar.

Validation Rule property box

Validation Text property box

Page 19: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 19

Validate Field Entries…continued

Field Name Validation Rule Data CheckCustomer_No >1000 And <1100 Limits customer numbers to 1001

through 1099.Credit_Limit <=5000 Restricts credit limits to values of 5000

or less.State “CA” Only the state of California is accepted.Country “CA” Or “US” Only the United States or Canada is

accepted.Order_Qty >=25 Quantity ordered must be a minimum

of 25.

Page 20: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 20

Create Input Masks

To use the Input Mask Wizard:1. Open the table in Design

view.2. Click in the desired field

row.3. Click in the Input Mask

property box.4. Click the Build button.5. Click the input mask you

want to create.6. Click Next.steps continued on next slide…

Input Mask Wizard

Build button

Page 21: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 21

Create Input Masks…continued

7. Select the placeholder character.

8. Click Next.9. Click Finish at the last

wizard dialog box.10. Click the Save button in

the Quick Access toolbar.

placeholder character

Page 22: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 22

Create Input Masks…continued

Use To restrict data entry to0 digit, zero through nine, entry is required9 digit or space, entry is not requiredL letter, A through Z, entry is required? letter, A through Z, entry is not required> all characters following are converted to uppercase< all characters following are converted to lowercase

Page 23: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 23

Format a Field

To format a field:1. Open the table in Design

view.2. Click in the desired field row.3. Click in the Format property

box.4. Click the down-pointing

arrow at the end of the property box.

5. Click the desired option at the drop-down list.

6. Click the Save button in the Quick Access toolbar.

Format property box

Page 24: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 24

Create a Lookup List

To create a list of values using the Lookup Wizard:1. Open the table in Design

view.2. Type or click the field name.3. Press Enter.4. Change the data type to

Lookup Wizard.5. Click the I will type in the

values that I want option.6. Click Next.steps continued on next slide…

Lookup Wizard dialog box

Page 25: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 25

Create a Lookup List…continued

7. Type the field values in the Col1 column and click Next.

8. Click Finish at the last wizard dialog box.

9. Click the Save button in the Quick Access toolbar.

field values

Page 26: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 26

Create a Lookup List…continued

To change the Limit To List property:1. Click the Lookup tab in the

Field Properties section.2. Click in the Limit To List

property box.3. Click the down-pointing

arrow that appears.4. Click Yes.5. Click the Save button in the

Quick Access toolbar.

Limit To List property box

Page 27: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 27

Create a Lookup List…continued

To select from a list of values in Datasheet view:1. Click the View button to

switch to Datasheet view.

2. Click in the column.3. Click the down-pointing

arrow that appears.4. Click the desired

selection in the drop-down list.

list of values

Page 28: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 28

Insert, Move, and Delete Fields

To insert a field in Design view:1. Open the table in Design view.2. Make the desired field active.3. Click the Insert Rows button in the

Tools group in the Table Tools Design tab.

4. Click in the Field Name area of the new row and type the field name.

5. Change the data type, description, or field properties as desired.

6. Click the Save button in the Quick Access toolbar.

Insert Rows button

Page 29: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 29

Insert, Move, and Delete Fields…continued

To move a field in Design view:1. Open the table in Design view.2. Select the field using the field

selector bar.3. With the pointer in the field

selector bar, drag the field to the desired position.

4. Click the Save button in the Quick Access toolbar.

move pointer

Page 30: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 30

Insert, Move, and Delete Fields…continued

To delete a field in Design view:1. Open the table in Design

view.2. Make the desired field active.3. Click the Delete Rows button

in the Tools group in the Table Tools Design tab.

4. Click Yes at the message box.5. Click the Save button in the

Quick Access toolbar.

Delete Rows button

message box

Page 31: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 31

Insert a TotalTo insert a total:1. Open the table in Datasheet

view.2. Click the Totals button in the

Records group in the Home tab.

3. Click in the Total row in the desired field.

4. Click the down-pointing arrow.

5. Click the desired function.6. Click the Save button in the

Quick Access toolbar.

functions

Page 32: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 32

CHECKPOINT 21) This is the default value for the

field size of a Text field.a. 55b. 155c. 255d. 355

3) This displays a pattern indicating how data is to be entered into the field.a. data maskb. input maskc. enter maskd. text mask

2) This property stores descriptive titles for fields.a. Validation Textb. Default Valuec. Field Sized. Caption

4) When you insert rows using the Insert Rows button, where are new rows inserted in relation to the active field?a. aboveb. belowc. at the beginningd. at the end

Next Question

Next Question

Next Question

Next Slide

Answer

Answer

Answer

Answer

Page 33: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 33

Understand Relationships Access is referred to as a relational database management

system. A relational database is one in which tables have been joined. When two or more tables have been joined to create a

relationship, you can look up or create reports from multiple tables as if they were one table.

In most cases, tables are joined by a common field that exists in both tables.

When designing a new database, consider if two tables need to be joined and make sure to include a common field in each table so that you can create the relationship after the tables have been created.

Page 34: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 34

Use the Relationships Window

To arrange tables in the Relationships Window:1. Click the Database Tools tab.2. Click the Relationships button

in the Relationships group.3. Add the required tables to the

window at the Show Table dialog box.

4. Close the Show Table dialog box.

5. Resize and move the field list boxes as necessary.

6. Save the layout.

Show Table dialog box

Page 35: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 35

Use the Relationships Window…continued

To resize a field list box:1. Position the mouse pointer on

the bottom border of the field list box until the pointer changes to an up- and down-pointing arrow.

2. Drag the bottom border down until the vertical scroll bar disappears.

resize pointer

Page 36: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 36

Create a One-To-Many Relationship When two tables are joined in a relationship, one table is

called the primary table, and the other table is called the related table.

A one-to-many relationship means that one table in the relationship contains one unique record in the field used to join the tables (this table will be the primary table), while the other table can have several records with a matching field value in the joined field (this table will be the related table).

In this type of relationship, the common field in the primary table is also the primary key field.

In the related table the common field is not the primary key and is known as the foreign key field.

Page 37: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 37

Create a One-To-Many Relationship…continued

To create a one-to-many relationship:1. Open the Relationships

window.2. If necessary, add the desired

tables to the window.3. Close the Show Table dialog

box.4. Drag the common field name

from the primary table field list box to the related table field list box.

steps continued on next slide…

Relationships window

Page 38: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 38

Create a One-To-Many Relationship…continued

5. Click Enforce Referential Integrity at the Edit Relationships dialog box.

6. Click Create.7. Click the Save button.

join line

Edit Relationships dialog box

Page 39: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 39

Create a One-To-One Relationship A one-to-one relationship exists when both the primary table

and the related table contain only one record with a matching field value in the common field.

In this relationship the common field used to join the tables is the primary key in each table. For example, the Employees table would contain only one record for

each employee. The Benefits table would also contain only one record for each employee. If these tables are joined on the common EmployeeID field, a one-to-one relationship would be created.

In this type of relationship, consider the primary table to be the table with the fields (such as the employee names) that describe the identity of each ID number (describe for whom the employee number was created).

Page 40: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 40

Create a One-To-One Relationship…continued

To create a one-to-one relationship:1. Open the Relationships

window.2. If necessary, add the desired

tables to the window.3. Close the Show Table dialog

box.4. Drag the common field name

from the primary table field list box to the related table field list box.

steps continued on next slide…

common field

Page 41: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 41

Create a One-To-One Relationship…continued

5. Turn on the desired relationship options.

6. Click Create.7. Click the Save button.

Edit Relationships dialog box

Page 42: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 42

Create a One-To-One Relationship…continued

To edit a relationship:1. Open the Relationships

window.2. Position the mouse

pointer on the black join line between the field list boxes.

3. Right-click.4. Click Edit Relationship

at the shortcut menu.

shortcut menu

join line

Page 43: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 43

Print a Relationships Report

To print a relationships report:1. Open the Relationships

window.2. Click the Relationship

Report button in the Tools group of the Relationship Tools Design tab.

3. Click the Print button.4. Click OK.5. Click the Close Print

Preview button.

Print button

Page 44: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 44

Delete a Relationship

To delete a relationship:1. Open the

Relationships window.2. Right-click the join

line between the tables.

3. Click the Delete option from the shortcut menu.

4. Click Yes at the confirmation message.

confirmation message

shortcut menu

Page 45: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 45

Display Records in a Subdatasheet

To display records in a subdatasheet:1. Open the primary

table in Datasheet view.

2. Click the plus symbol next to the record for which you want to view related records.

subdatasheet

Page 46: SECTION 2 SKILLS Creating Tables and Relationships

Skills© Paradigm Publishing, Inc. 46

CHECKPOINT 31) This is the most common type of

relationship created between Access tables.a. one-to-oneb. one-to-manyc. many-to-oned. many-to-many

3) This symbol appears next to the related table, indicating the many side of a relationship.a. plusb. minusc. asteriskd. infinity

2) Always be careful to drag the common field starting from this table.a. smallestb. largestc. primaryd. secondary

4) In this type of relationship, the common field used to join the tables is the primary key in each table.a. one-to-oneb. one-to-manyc. many-to-oned. many-to-many

Next Question

Next Question

Next Question

Next Slide

Answer

Answer

Answer

Answer