Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction To ACCESS DataBase

Similar presentations


Presentation on theme: "Introduction To ACCESS DataBase"— Presentation transcript:

1 Introduction To ACCESS DataBase
Navya Thum February 25, 2013

2 Attendance Go to to record attendance. Enter your MyID username and password. 4/3/2019

3 Outline Access 2 Continues
Creating a Three-Table Database Data Types AutoNumber Yes/No Lookup Wizard Much of what we do today will likely be useful for your Homework 4 project 4/3/2019 Access Chapter 2_2

4 The Rock & Roll Hall of Fame Database Example
Premise: We want to create a database to keep track of Bands & Members One Band has Multiple Members For the members, we also want to track their country of origin. There could be one country for many members. 3 Tables, 2 relationships… 4/3/2019 Access Chapter 2_2

5 Table Relational Structure
Members 1 Bands Countries 1 4/3/2019 Access Chapter 2_2

6 AutoNumber Primary Key Example
Create a New Blank Database called LastName_FirstName_Access_Ex4 Switch to Design View and create a Bands table with a field called BandNum of type AutoNumber (Primary Key) Create a field called BandName of type Text Save the table and enter these records in Datasheet view: 1, The Who 2, Van Halen 4/3/2019 Access Chapter 2_2

7 AutoNumber Example Continued
Create another table: Create ribbon > Table Call it Members and enter these fields: Member AutoNumber (Primary Key) BandNum Number (will relate to “Band” Table later) * NOTE: Autonumber from Band Table is compatible with Number type in this table. DO NOT USE AUTONUMBER on both sides of the common field ! FirstName Text LastName Text 4/3/2019 Access Chapter 2_2

8 Second Table from Example
Flip to Datasheet view and Save the table Enter these records: 1, 1, John, Entwhistle 2, 1, Pete, Townsend 3, 1, Roger, Daltry 4, 1, Keith, Moon 4/3/2019 Access Chapter 2_2

9 Second Table Completion
Enter these too… 5, 2, David Lee, Roth 6, 2, Edward, Van Halen 7, 2, Alex, Van Halen 8, 2, Michael, Anthony * Close both open tables and we will come back to this later… 4/3/2019 Access Chapter 2_2

10 Using “Lookup” Type Fields
They allow for clicking a drop down arrow when entering field values while in datasheet view to select predefined items as opposed to having to type them. Two types of lookup fields: Lookup references uses field values in another table Lookup references items you manually enter in advance in the same table We will now do both types… 4/3/2019 Access Chapter 2_2

11 Lookup from Other Table Example
Create the third table for our database called Countries Make these fields: ID AutoNumber (Primary Key) Country Text Flip to Datasheet view and save the table 4/3/2019 Access Chapter 2_2

12 Lookup from Other Table Example
Create the following Records: 1, England 2, America Close the table 4/3/2019 Access Chapter 2_2

13 Lookup from Other Table Example
Return to the “Members” table in Design View Add a 5th field called Origin of type Lookup Wizard Use “I want the lookup column to look up values in a table or query” Select “Table: Countries” 4/3/2019 Access Chapter 2_2

14 Lookup from Other Table Example
Add the Country field to Selected fields Next… Next… Finish Save if prompted Return to Datasheet View in “Members” Click in the Origin file to assign these: Assign “England” to The Who members Assign “America” to Van Halen members. 4/3/2019 Access Chapter 2_2

15 Same Table Lookup Example
In the Members table of our example, return to Design View Create a field called Instrument of type Look-up Wizard… Select I will type the values I want. Enter the following: Vocals, Drums, Guitar, Bass Save, Return to Datasheet view to enter them! 4/3/2019 Access Chapter 2_2

16 “Yes/No” Field Type Example
Add a field called “Living” Make it of Type Yes/No Save the table and mark all records except Keith Moon and John Entwhistle as Living members * We will come back to this 4/3/2019 Access Chapter 2_2

17 Create a Relationship Example
Close the tables Open Relationships Note that lookup wizard created one already! Right click, Show Table, add Bands. Drag [Bands/BandNum] to [Members/BandNum] Enforce referential, Create, and save. 4/3/2019 Access Chapter 2_2

18 Query Example We want to use the relationships we created between the tables to show the names of the artists, their band names, and their countries of origin despite only having a band number in the Member table and a lookup for country. We can use the relationship to seamlessly query between fields in the three tables and give the desired results… 4/3/2019 Access Chapter 2_2

19 Query Example Create query in design view
Create Ribbon > Query Design button Add all tables (note the relationships showing) From Bands table double click to add: BandName From Members table add: FirstName, LastName, Instrument, Living From Countries table add: Country Run the Query ! Close and Save Query as RockTrivia 4/3/2019 Access Chapter 2_2

20 WILD CARDS Special characters that can represent one or more characters in text value. You enter wild card characters in criteria row in query. ? stands foe single character. * stands for any number of characters.

21 Added Date Field for Birthday
Open the Members table from Access_Ex6(DataFile 2)and note a new field of type Date/Time called Born that was added Close Members table 4/3/2019

22 Returning to the Query Create RockTrivia Query
Also Add [Members] Born field in design view Run the query Now let’s look at adding operators for criteria… 4/3/2019

23 Operators 4/3/2019

24 Criteria & Operators Exercise
Remove all the criteria In the criteria row for born, add: >1/1/1960 Note we get 3 records (born after then) Try making it: >=6/5/1950 We get 12 records with VH, Def Lep, and Rush Change it to: <6/5/1950 The Who are our most senior band 4/3/2019

25 Calculations in a Query…
Queries can be built to perform a calculation as part of the query We often do this for things that we do not need to store and take up space with Expressions can be entered into the query design grid as if they were regular fields Done on data type fields treated as numbers 4/3/2019

26 Calculations in a Query…
To perform a calculation in a query, you must add a calculated field to the query design. Make certain that you are following the rules of precedence. Two options for entering expressions: Enter the expression directly into the field text box Enter the expression in the Expression Builder 4/3/2019

27 Creating a Calculated Field
Remove the existing criteria In design view, click in the next available field, where the name would be, and then click the magic wand “Builder” icon above. The expression builder shows up… 4/3/2019

28 The Expression Builder…
4/3/2019

29 Let’s make a Query to try this…
We want to figure out how many years they are/would be alive. It would be inefficient to store this and we would have to update it all the time too Build or type the following: Age: (Date()-[Members]![Born])/365 Note: If you see <<expr>> be sure to remove it ! ! ! Run it ! Expand the width of the column if you see ##### 4/3/2019

30 Changing Decimals Precision
Note: Similar to what is needed for to set decimal places on query results in home works!! In design view, right click Age field Click Properties Select Fixed for Format and 0 for Decimal Places Re-run it to see it without the decimal places 4/3/2019

31 Next Class Try to go over this lecture slides and step by step
Read over Access 2 in text 4/3/2019 Access Chapter 2_2

32 Questions? 4/3/2019


Download ppt "Introduction To ACCESS DataBase"

Similar presentations


Ads by Google