190 likes | 296 Views
Access Tables. William Klingelsmith. 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!. Access Interface. A Basic Table Holding Song Information. A Few Questions.
E N D
Access Tables William Klingelsmith
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!
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?
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)
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.
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
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
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.
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
Same type and content? • Suppose three students were meeting at a café for lunch. • Each student speaks different languages. How will they communicate?
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
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.
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