access fields and keys participation project
play

ACCESS: FIELDS AND KEYS PARTICIPATION PROJECT WV K-12 Education - PowerPoint PPT Presentation

ACCESS: FIELDS AND KEYS PARTICIPATION PROJECT WV K-12 Education Problem WV Senate Problem TOPICS COVERED Determine appropriate field types Select primary and composite keys Identify appropriate table relationships 2 FIELD DATA


  1. ACCESS: FIELDS AND KEYS PARTICIPATION PROJECT WV K-12 Education Problem WV Senate Problem

  2. TOPICS COVERED • Determine appropriate field types • Select primary and composite keys • Identify appropriate table relationships 2

  3. FIELD DATA TYPES • Each field (column) has an associated field type. • These field types determine what type of data can be stored in the field and how it will be formatted. 3

  4. COMMON FIELD DATA TYPES Type Description Example Short Text Words with at most 255 characters 94 Beechurst Avenue Long Text Words with more than 255 characters Text with multiple sentences, like the response to an analysis question. Number Integers (whole numbers) or double-type 12 (integer) numbers (numbers with decimal parts) 3.14 (double) Date/Time Dates and/or times 12/31/2018 12:00am Currency Amounts of money $6.54 AutoNumber Automatically generated values used for 999 primary keys Yes/No Values that are true (yes) or false (no) No Lookup Wizard Dropdown menu to select values from Names of colleges from a Colleges table another table or query 4

  5. CHOOSING FIELD DATA TYPES • Choose the field type that best matches all of the data you expect that field to contain. – If a field is only going to contain numbers, choosing Number as its type will save space and give more flexibility for queries – But, if the field has any records containing even one letter, you must choose a text-type field • Use special purpose fields like Date/Time and Yes/No to help avoid data errors. – The fields will only allow specific values, reducing the chance of someone entering an invalid value • Try to think about what the field might need to store in the future. – For example, if you have a phone number field, what happens if you need to store an extension in the future? A Number-type field won’t work. Maybe Short Text will be better. 5

  6. SPECIFY DATA TYPES 1. Click in the Data Type column for the field to modify. 2. Select its new data type. 3. Specify any needed field properties like the field size, especially for numbers that have decimal places. • If you edit settings on a table that already contains data, be careful you don’t lose data like by converting a text field to a number 6

  7. PARTICIPATION PROJECT STEP 3 7

  8. PRIMARY KEYS • Keys uniquely identify records in a table. – Used to select individual records – Also relate data across tables • When one field is used to uniquely identify all records, you have a primary key. • Primary keys must: – Not be duplicated – Must always have a value, never empty or null – Rarely (ideally never) change – Be as short as possible • If no existing field meets requirements, you can add an AutoNumber field. 8

  9. COMPOSITE KEYS • Sometimes, there’s not a individual field that uniquely identifies all records but multiple fields taken together do. • When a key involves 2+ fields, it’s called a composite key. • In the table to the right, the County and SchoolYear fields together are a composite key because a student can have multiple majors. 9

  10. SET KEYS 1. Click to select the field(s) that will be part of the key. – To create a composite key, simultaneously select all fields that will be part of the key 2. Go to the Table Tools Design ribbon. 3. Click the Primary Key button. 4. Click the Save button on the Quick Access Toolbar. 10

  11. PARTICIPATION PROJECT STEP 4 11

  12. RELATIONSHIPS • A relationship is how a record in one table is connected to another. • There are three types of table relationships: – 1-to-many (most common) – 1-to-1 – Many-to-many (uncommon) 12

  13. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 1 • In order for your database to work effectively, you must build relationships to tie together the data in different tables. • In 99% of cases: – There will be no tables that are isolated without any relationships – The tables will form a connected graph, where you can follow relationships to get from any table to any other table – AnalysisQuestions is an exception; since it’s not related to the project data, there should be no relationships to this table 13

  14. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 2 1. Start by looking at tables that have a single primary key. – We’ll pick the Counties table and its Counties field. 2. Identify what other tables contain corresponding fields. – There are also Counties fields with the same data in Schools , AnnualStatistics , and Dropouts tables. 14

  15. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 3 3. If another table’s version of the key field appears to be a parent of this field, create a relationship to it. – Here, the Counties table is logically the parent for the County field. We do not want to create any other relationships at this stage. 15

  16. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 4 4. Next, look to see if the current table is the parent of the fields in the other tables. Create relationships to those fields. – Here, we will create relationships between the County fields in Counties with Schools , AnnualStatistics , and Dropouts 16

  17. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 5 5. Next, we will look at the SchoolTypes table and its SchoolTypeAbbrv field. – Also appears in Schools table, where it is not a key 6. Since SchoolTypes is the only place where this field is a key, it has no other parent. 7. Create a relationship to its child in the Schools table. 17

  18. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 6 8. The AnnualStatistics table is the only other table with a primary key. Its key, SchoolStatisticsID, appears nowhere else. 18

  19. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 7 9. Now that we have looked at all primary key tables, look at the composite key tables. – We’ll pick the Schools table, which has a composite key of County and SchoolName. 10. Identify the other places where all composite key fields appear together. – Both composite keys also appear in AnnualStatistics . 19

  20. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 8 11.If another table’s version of the key fields appear to be a parent of this field, create a relationship to them. – Here, the Schools table is logically the parent for the SchoolName and County fields. We do not want to create any other relationships at this stage. 20

  21. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 9 12.Next, look to see if the current table is the parent of the fields in the other tables. Create relationships to those fields. – Here, we will create relationships between the County and SchoolName fields in Schools with AnnualStatistics 21

  22. IDENTIFY FIELDS FOR RELATIONSHIPS: PART 10 5. Next, we will look at the Dropouts table and its County and SchoolYear fields. – Also appear in AnnualStatistics table, where they are not a key 6. Since Dropouts is the only place where these fields are a key, they has no other parent. 7. Create a relationship to the children in the AnnualStatistics table. 22

  23. CREATE RELATIONSHIPS: PART 1 • Be sure to close any open tables or queries before you start. 1. Go to the Database Tools ribbon. 2. In the Relationships section, click the Relationships button. 3. Double-click the names of the tables you wish to create relationships between. 4. Click the Close button when done. 23

  24. CREATE RELATIONSHIPS: PART 2 • You may need multiple relationships, but they must be created one-by-one. • The fields on both sides of a relationship must have identical data (i.e., County and County , not County and SchoolYear ). • In CS101 projects, the fields for each relationship typically have same name. 1. Click on the name of field in the first table. 2. Drag your mouse over to the second table and release the mouse button when you’re on top of the corresponding field. 24

  25. CREATE RELATIONSHIPS: PART 3 • Referential integrity helps ensure your data is valid by preventing orphaned records (records missing a related record). • Cascade updates and cascade deletes propagate changes to avoid orphans when you edit or delete records. • If you enforce referential integrity but don’t use cascade updates or cascade deletes, Access won’t let you make changes that would create an orphaned record. 25

  26. CREATE RELATIONSHIPS: PART 4 To finish creating the relationship: 3. Ensure the correct fields are listed. 4. If the relationship involves multiple fields, as sometimes happens with composite keys, add the additional fields using dropdown menus in each column. 5. Set referential integrity options. 6. Click the Create button. 26

  27. CREATE RELATIONSHIPS: PART 5 • When you finish creating a relationship, it should show up as a line connecting the tables. • If referential integrity was enforced, you may see additional symbols indicating if the relationship is 1-to-1, 1-to- many, or many-to-many. 27

  28. PARTICIPATION PROJECT STEP 5 28

  29. 29

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend