180 likes | 270 Views
Welcome to Access. Welcome to Access Day 1. You have been hired to create a Database for the new library in town. We initially tried to use Excel to keep track of our data, but realized that we just couldn’t keep track of our data in a spreadsheet.
E N D
Welcome to Access Day 1 • You have been hired to create a Database for the new library in town. • We initially tried to use Excel to keep track of our data, but realized that we just couldn’t keep track of our data in a spreadsheet. • Over the course of the next five days you will learn the concepts of creating a database and making it functional for every day use.
Excel vs Access Excel Access Create databases Stores LOTS of data and relates it Retrieves data based on criteria Enables easy data entry Creates customizable reports • Creates spreadsheets • Stores flat data • Analyzes data and performs sophisticated mathematical functions • Presents data in charts and graphs.
When we made it in Excel… In Excel we realized that we would have to duplicate the book record every time a the book was borrowed, or essentially create a new record for the book each time.
If we made it in Access… Access can store one record of a book in a database and tie all the instances of a book borrow to that one book.
When we made it in Excel… We tried to create a record for a patron, but we realized we couldn’t do it unless they checked out a book at the same time.
If we made it in Access… We can have a separate table for Patrons and just connect each patron to a borrow when they check out a book.
When we made it in Excel… We needed to change a patron’s phone number, but we realized we’d have to change all the instances of a patron borrowing a book. Such a headache!
If we made it in Access… We can just go to the patron’s record in the Patron table, change their phone number and every borrow will still be connected to the same record.
When we made it in Excel… We wanted to delete a borrow from the spreadsheet, but we realized that in doing so we’d also delete the customer information. What if that were the only time they checked out a book? We’d loose that information completely.
If we made it in Access… Because the patrons are stored in a separate table from the borrows, we can delete a borrow without deleting the Patron.
Library Database Example • Access can store data in separate tables and relate them • Access can create queries that can pull out very specific pieces of data • Access can create forms that allow for quick and user friendly data entry • Access can create reports to present your data.
Table Design • What fields should we include in the Books and Patrons table? • Data types • Each field should be the smalled data chuncks you can think of. • Example: Separate First_Name and Last Name into two different fields.
What fields would you want? Books • Book ID (PK) • Title • Author First • Author Last • Book Year • Genre • Checked In • Patrons • Patron ID (PK) • Patron First Name • Patron Last Name • Patron Phone • Library Card Number • Address • City, State , ZIP • Country • Patron Info
Define the relationships • Get into pairs and define the relationships between the following entities: • For example how many social security numbers would one citizen have? • One to one • How many passengers can one bus have? • One to many or Many to many
REA Diagrams • Resources—what kind of resources do we need to keep track of for the library? • Events—what kind of events will we need to track in the library? • Agents—Who will be the participants in the library?
Resources Events Agents • Patrons • Patron ID (PK) • Patron First Name • Patron Last Name • Patron Phone • Library Card Number • Address • City • State • ZIP • Country • Patron Info • Books • Book ID (PK) • Title • Author First • Author Last • Book Year • Genre • Checked In • Borrows • Borrow ID (PK) • Book ID (FK) • Patron ID (FK) • Employee ID (FK) • Checked Out Date • Due Date • Checked In Date • Employees • Employee ID (PK) • Employee First Name • Employee Last Name • Address • Hire_Date =one to many
Now it’s your turn! • Let’s start creating the tables in Access and make the relationships between them!