Tables

advertisement
DAY 22:
MICROSOFT ACCESS – REVIEW
Akhila Kondai
[email protected]
November 04, 2013
ANNOUNCEMENTS
• MyITLab Lesson D is due on 11/04/2013 (Today).
• Homework # 5 would be due for 11/08/2013
• Email me or visit open lab for assistance in home works
or MyITLab.
HOMEWORK 5
• 4 Tables
– Counties ( Import from XML)
– Harvest (Import from XML)
– WMU ( Create a new table and enter data given in the instruction
sheet)
– Analysis Questions ( Create a table and use it store your
answers for the analysis questions in step 7)
• 7 Queries
– Validate if your query is right by checking the number of records
returned by your query with the hint given in the instruction sheet
for each query.
M.S ACCESS OVERVIEW
•
•
•
•
•
•
•
•
Creating tables or importing from XML files
Assigning primary key and formatting the fields accordingly
Entering records
Building relation ships between tables in the database
Creating Queries
Formatting fields used in queries
Creating forms
Creating reports
BASICS
• Database – stores information in various
tables.
• Tables – each table has multiple fields (
name, age, address) where data can be
stored.
• Record – complete set of all the data
(fields) in a table.
– Fields are edited in DESIGN VIEW!!!
– Records are edited in DATASHEET VIEW!!!
STRUCTURE
• All data is organized in tables.
• Tables shouldn’t contain multiple accounts
of similar information.
– If this occurs a new table should be made.
– Ex. Writing the same address for all the
employees of at the same office when you
could have a separate “Locations” table.
TABLES
• Usually created from scratch or imported
from Excel or an .xml file.
• Always has either a single primary key or
two or more fields acting as a composite
key.
• Primary key: The field that separates
every record from every other record.
– Student ID #
– SSN#
TABLES
Design View
• Fields
• Primary Key
– COMPOSITE KEYS
• Data Types
–
–
–
–
AutoNumber, Number, Currency
Text, Memo
Yes/No
Lookup Wizard
Datasheet View
• Add Records
• View Records
• Edit Records
• Delete
Records
TABLES
Always create tables in Design view
Add the Field Names ( Column Labels ) in Design View
Flip from Design View to Datasheet View to enter the
Records
Field Names
Records
9
CREATING TABLES – CONTD.
Select proper field names and data types
Data Types:
• Text – when you are entering text, can be numeric or alphanumeric
• Memo – when you need more than 255 characters
• Number – when you are entering number:
• Single & Double – Use these field sizes to store DECIMAL numbers
• Integer & Long Integer – Use these field sizes to store WHOLE
numbers
• Currency – when storing currencies
• Date/Time – when storing dates and times
• Auto Number – auto incrementing number – note it is sequential so
if you delete a record the associated Auto Number is gone. So don’t
panic if your auto numbers are missing some values
MAKING RELATIONSHIPS
• Make sure neither table is open when you are
creating the relationships. If they are you will get
an error.
• Always relate fields with the same Data Type
and same Content
• In general related fields will have similar names
– Country and Country Abbreviation, etc
• If the relationships aren’t set up properly it is
very likely the queries won’t work
11
QUERIES
• Probably the most important area to focus
your study time on.
• Criteria – AND vs. OR.
• Sorting – Left  Right
• Wildcards – ‘*’
• Aliasing – ‘:’
• Calculated fields – use Expression Builder!!!
• Total/Aggregate Queries
• Show/Hide Fields
QUERIES - TIPS
• In a Total Query, sometimes you want to
use the same field more than once to get
different calculations.
– Think about grades for an exam. We
might want to find the Average and the
Max and the Min. We find these using
the same group of data (the exam
grades).
QUERIES - TIPS
• When choosing which tables to use, use a
few as possible. Even though two tables
might have the same field, if you can
create the query using only one table then
do it.
• If you’re query looks correct but isn’t
returning the correct number of results
check if you’re using too many tables than
needed.
FORMS WITH SUBFORMS
• You can create a form with a subform by including fields from
each of two tables that have an established relationship
formed
• The main form will consist of data from the primary table and
the subform will consist of data from the related table
• Create form by using wizard Create ribbon -> More Forms ->
Form Wizard
– Click the “Tables/Queries” drop down to add all the fields you
need Start with your first table (usually the “One”) and add some
fields from it.
– Then add fields from your second table (usually the “Many)
– Hit Next
– You will see Form with subform at the bottom, if you don’t then
either your relationships aren’t correct or you didn’t add the
entries in properly
REPORTS
Reports
Again, use the Report Wizard
Add in all fields as required
Add in any viewing, grouping or sort levels
Download