Database Basics Create a new database Create tables Create records Create forms Create queries Create reports Hands On Practice Create a new database Open Microsoft Access. It should look like this: In the Getting Started pane, click Create a new file. When the New File pane appears, click Blank Database. South San Antonio ISD Technology Department 1
When the File New Database window appears, create a new folder in the My Documents folder called Practice Access Files. TIP: To create a new folder, double click the My Documents folder so it appears in the Save in drop down list. Then click the icon. Double click the Practice Access Files folder. It should appear in the Save in box. In the File name box, type: Friends.mdb TIP: The file extension for Access databases is.mdb. Just like Word files are something.doc, and Web pages are somethingelse.html, Access databases are database.mdb. MDB stands for Microsoft DataBase. Click the The window for the Friends database should open: South San Antonio ISD Technology Department 2
Identify database elements Elements of databases A database stores information in an organized way, and makes it easy to get information in and out. Tables store data within the database. Forms make it easy to put data into tables. Queries pull out specific data. Reports put data in an easily read format. South San Antonio ISD Technology Department 3
In the Objects list, click Tables. Access Database 2003 Basics Click Queries. Click Forms. Click Reports. South San Antonio ISD Technology Department 4
Click Tables. Click the The Friends database window should expand to fill the screen. Create tables Double click Create table by entering data. A blank table should open: South San Antonio ISD Technology Department 5
Name fields Double click the Field 1 column header. Type: First Name Press the ENTER key on your keyboard. The column header should look like this: Double click the Field2 column header. Type: Last Name It should look like this: Press the ENTER key on your keyboard. Double click the Field3 column header, type: City then press ENTER. South San Antonio ISD Technology Department 6
Double click the Field4 column header, type: Zip then press ENTER. Double click the Field5 column header, type: Phone Number then press ENTER. The table should now look like this: Delete unused fields Right click the Field6 column header. When the menu appears, click Delete Column. South San Antonio ISD Technology Department 7
When the alert window appears, click the Right click the Field7 column header. When the menu appears, click Delete Column. When the alert window appears, click the Delete the Field8, Field9, and Field10 columns the same way. The table should now look like this: On the Menu Bar, click File, then Save. South San Antonio ISD Technology Department 8
When the Save As window appears, type: Friends of Mine in the Table Name box. Click the When the alert window that reads There is no primary key defined appears, click the Access will insert an ID field the Key field in the table: What is the key field? When the alert window popped up, and you clicked the the table. button, Access added the ID field to The ID field is now the table's primary key, or key field. That means it can't contain any duplicates. Every table should have a key field. For example, if a hospital keeps a database, each patient can have a unique ID number in the key field. That way, if it has more than one patient named John Baker, it can easily distinguish John Baker, ID #326 in for a checkup, from John Baker, ID #298 who needs his gall bladder removed. South San Antonio ISD Technology Department 9
Create records Click in the box under the First Name column header. Type: Elvis Press the TAB key on your keyboard. The table should now look like this: Type: Presley then press the TAB key. Type: Baltimore then press TAB. Type: 21212 then press TAB. Type: 4105551212 then press TAB. The table should now look like this: TIP: Notice how the cursor in the row selector has moved down to the second (new) record. When you move on to a new record, Access automatically saves the previous record. Add new fields Right click the Zip column heading. South San Antonio ISD Technology Department 10
When the menu appears, click Insert Column. Access Database 2003 Basics The table should now look like this, with a new blank field: Double click the column heading and type: State Press the ENTER key. Click inside the new State field for the first record. Type: MD Press TAB until the cursor moves down to a new record. Record number 1 is saved and complete. South San Antonio ISD Technology Department 11
Move fields Click the Phone Number column heading. The entire column should be selected. Place the cursor on the Phone Number column heading. Then drag the column so the cursor rests between the Last Name and City columns. When you see a thick black line between the two columns, release the mouse The Phone Number column should now rest between the Last Name and City columns: On the Menu Bar, click File, then Close. When prompted to save the changes to the table layout, click the South San Antonio ISD Technology Department 12
The Friends database window should now look like this: Create forms In the Objects list, click Forms. Double click Create form by using wizard. South San Antonio ISD Technology Department 13
When the Form Wizard window appears, click the All the table fields should be added to the form: Click the South San Antonio ISD Technology Department 14
When the next screen appears, leave Columnar selected, then click the When the next screen appears, make sure Standard is selected, then click the South San Antonio ISD Technology Department 15
When the last screen appears, type: Friends of Mine Data Input Form in the box. Click the The form should open and look like this: South San Antonio ISD Technology Department 16
Add a new record In the form window, click the button located at the bottom of the form. A blank record should appear. Press TAB to advance to the First Name box. Type: Bo then press the TAB key. Type: Diddley then press the TAB key. Type: Richmond then press the TAB key. Type: VA then press the TAB key. Type: 23220 then press the TAB key. Type: 8005557890 The form should now look like this: Press the TAB key again. South San Antonio ISD Technology Department 17
The form should progress to a new, blank record: Access Database 2003 Basics The old record has been saved. On the Menu Bar, click File, then Close to return to the database window. Create queries What's a query? A query is a way to get specific information from the database. Essentially, it's a question. You use queries to ask the database things like, "Who are my customers in Montana?", or "How many pipe fittings have I sold this month?" South San Antonio ISD Technology Department 18
In the Objects list, click Queries. Access Database 2003 Basics Double click Create query by using wizard. When the Simple Query Wizard opens, double click First Name in the Available Fields list. First Name should appear in the Selected Fields column: South San Antonio ISD Technology Department 19
Click the This should add the Last Name field to the Selected Fields list: Double click Phone Number. This should add the Phone Number field to the Selected Fields list: South San Antonio ISD Technology Department 20
Click the When the final screen appears, type: Names and Numbers Click the The query is automatically saved and executed. It should look like this: On the Menu Bar, click File, then Close to return to the database window. South San Antonio ISD Technology Department 21
Create reports In the Objects list, click Reports. Double click Create report by using wizard. When the Report Wizard window appears, click the Tables/Queries drop down arrow. When the list appears, click Table: Friends of Mine. Click the button to move all the fields into the Selected Fields list. South San Antonio ISD Technology Department 22
In the Selected Fields list box, click ID, then click the The ID field should be removed. The report wizard should now look like this: Click the When the next screen appears, click the South San Antonio ISD Technology Department 23
When the next screen appears, click the first drop down arrow, then click State in the list. Click the Choose layout and style When the next screen appears, make sure Tabular is checked in the Layout section. Then click the South San Antonio ISD Technology Department 24
When the next screen appears, click Soft Gray in the list of available styles. Then click the View the report When the final screen appears, type: My Friends in the box. Then click the Preview the report radio South San Antonio ISD Technology Department 25
Click the The report is automatically created, saved and opened. It should look like this: On the Menu Bar, click File, and then Close to return to the Friends database window. On the Menu Bar, click File, then Exit to close Access. Practice: Database Basics 1. Open Microsoft Access. 2. Create a blank Access database in the Practice Access Files folder called Music Library.mdb. 3. Create a new table with these fields: CD Title Artist Genre Date Purchased Number of Songs 4. Delete unused fields from the table. South San Antonio ISD Technology Department 26
5. Save the table as CDs. Allow Access to create a Primary Key. Access Database 2003 Basics 6. Rename the ID field (the Primary Key) Album ID. 7. Enter these data into the table to create the first record: CD Title: Pearls on a String Artist: Dusty Trails Genre: Folk Date purchased: 05/10/2001 Number of Songs: 14 It should look like this: 8. Close the CDs table. 9. Create a form for inputting data into the CDs table. 10. Save it as CDs Table Data Input. It should look like this: 11. Use the form to enter information for four more CDs. TIP: Feel free to make things up. 12. Create a query that pulls out this information: CD Title Genre Number of Songs South San Antonio ISD Technology Department 27
13. Save the query as Quick CD Notes. Run the query. It should look like this: Create a report based on the CDs table. 14. Include all the fields of the CDs table in the report, and sort the records based on Genre. TIP: Format the report using the Soft Gray style. 15. Name the report CD Inventory. It should look like this: 16. Close the report. 17. Exit Microsoft Access. South San Antonio ISD Technology Department 28