access tables william klingelsmith. exam review/reminders grades were okay for the most part common...

19
Access Tables William Klingelsmith

Upload: hilda-walsh

Post on 17-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Access TablesWilliam Klingelsmith

Page 2: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Exam Review/Reminders• Grades were okay for the most part• Common errors• Incorrect references in formula• Incorrect difference formula• Chart errors

• Homework 3 due tonight!

Page 3: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Access Interface

Page 4: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

A Basic Table Holding Song Information

Artist Title Album_ID

Black Moth Super Rainbow

Hairspray Heart 1

White Lung Thick lip 4

Mind.in.a.box Lament for Lost Dreams 2

The Shins The Rifle’s Spiral 3

Page 5: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

A Few Questions• How many fields does

this table contain?• Which data types should

we use for the fields in this table?• Text, Number, Memo,

Currency, etc.

• Can we specify a primary key (uniquely identifying field) on field in this table?• Why or why not?

Artist Title Album_ID

Black Moth Super Rainbow

Hairspray Heart

1

White Lung Two of You 4

Mind.in.a.box

Lament for Lost Dreams

2

The Shins The Rifle’s Spiral

3

Page 6: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

An Updated Basic TableSong_ID Artist Title Album_ID

1 Black Moth Super Rainbow

Hairspray Heart

1

2 White Lung Thick lip 4

3 Mind.in.a.box Lament for Lost Dreams

2

4 The Shins The Rifle’s Spiral

3

Page 7: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Let’s Create this Table in Access• Move to the Create Tab• Click Table• Switch to the Design View of the table and name it “Songs”• Keep the Auto numbered ID field and call it Song_ID• Specify it as the primary key using the large key button in the top

left• Add the remaining fields for the table (name and data type)

Page 8: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Views in Access• Each object in Access, be it a query, table, form, etc, has

multiple views associated with it• Each of these views allows the design or data of the object to be

changed• For tables, the design view is where you will construct the

table fields and data types and the datasheet view is where data will actually be inputted.

Page 9: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Placing Data in the Table• The design view you are currently in is for constructing the

table ONLY. Data is entered in a different view• Switch to Datasheet View and enter the values into the table• You will notice the Autonumbering ID field auto increments

and you don’t have to type anything in for it.• Add one new song of your choosing as a record in the table• For the album_ID, use the number four

Page 10: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

A Note About Saving in Access• Once you have finished entering data into your table, close

your database • Reopen your database• You will notice all data you entered is still there even though

you didn’t save• All changes made to data in Access tables is saved automatically• Only changes to the structure of objects in your database will

prompt a save dialog• Access can’t undo everything

Page 11: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Album TableAlbum_ID Album_Na

meGenre Price Number_S

oldRelease Date

1 Cobra Juicy 1 $9.99 234,014 7/5/2012

2 Dreamweb 1 $10.50 65,565 1/1/2005

3 Port of Morrow

1 $15 768,000 3/20/2012

4 sorry 1 $5.99 125,387 1/1/2012

Page 12: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Relationships• As introduced Tuesday, the proper way to construct tables in

databases involves segmenting related data into distinct tables.

• At this point, we have a table which holds information about songs and another that has album information.

• We will now link these using a relationship.

Page 13: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Creating Relationships• Move to the Database Tools tab• Click Relationships• You will be presented with a Show Table dialog in which you

can choose the tables on which the relationship will be made• Add Songs and Albums

• To create a relationship, you simply drag one field from one table to another• The fields must be of the same data type• The contents of the fields must be the same in each table

Page 14: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Same type and content?• Suppose three students were meeting at a café for lunch.• Each student speaks different languages. How will they

communicate?

Page 15: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Same type and content?

John

• French• English• Dutch

Sara

• French• German

Tim

• German• Russian• Icelandic

Page 16: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Same type and content?

John

• French• English• Dutch

Sara

• French• German

Tim

• German• Russian• Icelandic

Page 17: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Creating Relationships• Once you begin the relationship, you will see different options

available to you• Referential Integrity: All entries from one table must be present in

the other• Cascading Updates: Any changes made in one table will be

propagated to the others linked to it• Cascading Deletes: Any deletions made in one table will delete

corresponding entries in the other tables• Enable all three

Page 18: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Creating Relationships• Also, at the bottom of the relationship will be a small phrase

detailing the type of relationship that is going to be created.• One-to-One: every entry in one table has exactly one entry in the

other table• One-to-Many: one entry in a table may have relationships with

multiple entries in another table• Many-to-many: multiple entries from one table can be associated

with multiple entries from another table

• If you ever see “Indeterminate”, it’s usually an indicator that your relationship is incorrect.

Page 19: Access Tables William Klingelsmith. Exam Review/Reminders Grades were okay for the most part Common errors Incorrect references in formula Incorrect difference

Importing Data from External Resources

• Similar to Excel, Access has the capability to import data from other sources which include:• XML Files• CSV Files• Excel Spreadsheets• Etc.

• All of these import options are located on the External Data tab.• XML files allow you to import just the structure of a table, both

the data and structure, or append data to an existing table