DB Tutorial
-
Upload
cathy-ann-lindsay -
Category
Documents
-
view
215 -
download
0
Transcript of DB Tutorial
-
8/13/2019 DB Tutorial
1/9
-
8/13/2019 DB Tutorial
2/9
Database Tutorial
Page 2of 9
C-A Lindsay
Recommended order for design view tasks should be (1) Applicant, (2) Community, and (3) Selection.
Table - Design View
Views Tabs Object panel
Navigation pane Primary Key Field properties
Selectiontable is related to other two tables. It would therefore have a composite keyi.e. a primary key madeup on more than one key (usually primary keys in other tables).
MS Access 2007
To set a primary/composite key
Go to the left of panel next to a (key) field; a bold directed arrow would appear NB.: Do not click to reposition
cursor.
Key press left click Repeat select of (key) field/fields required. Release left click.
Right click highlighted fields Select Primary Key option from pop-up menu. For the respective fields, a
primary key symbol would appear left of the field name.
Save table.
Primary (Composite) key
-
8/13/2019 DB Tutorial
3/9
Database Tutorial
Page 3of 9
C-A Lindsay
Table - Datasheet View
NOTE: A table Datasheet view allows for data entry and may be deferred after the creation of relationships.
Relationships
After completion of the tables (relations) design, a database tool known as relationships is to be used to
establish mappings (links) between the tables. A relationship is provided between similar fields in different tables;
a primary key in one table that is a foreign key in another table. This feature effectively removes redundant data.
MS Access 2007
Go to the Database Toolstab.
Select the Relationshipsicon. A panel title Relationshipswould appear.
Right click in the Relationships panel Select Show All option from pop-up menu. Three objects for the
respective tables would to appear.
In panel place Selectionobject between the other tables; it would serve as link table for the other two tables.
Repeat the following to link (map) the respective related fields.
Click and drag a field in the primary table to the related field in the Selections table. A dialog box title Edit
Relationshipwould appear.Select Referential integritycheck box and click the createbutton. A view of a link would appear.
Edit Relationship Tabs Object panel
Navigation pane RelationshipsCardinality: 1 to M(any)
-
8/13/2019 DB Tutorial
4/9
-
8/13/2019 DB Tutorial
5/9
Database Tutorial
Page 5of 9
C-A Lindsay
Query - Design View
Query Type Tabs Object panel Totals (Group by)
Navigation pane fields (calculated) field
Query - Datasheet View
Expression BuilderA feature (tool) used to facilitate creation expressions and provides access to operators,
functions and arguments (identifiers) for use expressions. It can be accessed by objects such as tables, queries,
forms, reports
For support visitMicrosoft Office Access Support - Expression Builder
http://office.microsoft.com/en-us/access-help/using-the-expression-builder-HP005186638.aspxhttp://office.microsoft.com/en-us/access-help/using-the-expression-builder-HP005186638.aspxhttp://office.microsoft.com/en-us/access-help/using-the-expression-builder-HP005186638.aspxhttp://office.microsoft.com/en-us/access-help/using-the-expression-builder-HP005186638.aspx -
8/13/2019 DB Tutorial
6/9
Database Tutorial
Page 6of 9
C-A Lindsay
Table: Expression Builder
Build button (command)
Query: Expression Builder
End-User Views
Report: A tool with the facility of a template or pre-formatted layout used to present information from a
database.See Specifications.
Design viewShows the template or pre-formatted layout for the report. Layout viewDisplays a softcopy layout of the report; allows for editing. Print PreviewDisplays a preview hardcopy layout of the report; allows no editing.
-
8/13/2019 DB Tutorial
7/9
Database Tutorial
Page 7of 9
C-A Lindsay
MS Access 2007
NOTE: Create a query that returns the results for the report.
Go to the Createtab.
Select the Report Wizardicon from Report group. A dialog box title Report Wizardwould appear.
In dialog box Select fields required for report Click Nextbutton. NB.: Use the query for report.
While NOT finish: Provide report specifications as requested per dialog box Click Next button. Finish
dialog box actions. A panel title with report name would appear.
If further modifications are required: Go to report panel title Right click Select Design View or Layout
Viewoption from pop-up menu.
Review modifications of report layout as necessary.
Save report: Go to report panel title Right click Select Saveoption from pop-up menu.
Close report: Go to report panel title Right click Select Close option from pop-up menu.
Report - Design View
View Tabs Object panel Controls
Navigation Pane Group. Sort, Totals Control properties
Report - Print Preview
-
8/13/2019 DB Tutorial
8/9
Database Tutorial
Page 8of 9
C-A Lindsay
Specifications
Data Dictionary: A repository of information about the description of data in a database.
Structured Query Language (SQL) A programming language designed to retrieve and manage data in a
(relational) database.
Tables
Applicant
Field Data Type Description Validation Checks Control
ID Text [7] Key: Identifier for Applicant Presence, Format, Range Text box
Name Text Name of applicant Presence Text box
DOB Date Date of Birth Presence, Format, Range Text box
Gender Text Gender Presence, Table look-up List box
Married Yes/No Marital status Table look-up Check box
Address Text Residential Address Presence Text box
Profession Text Profession/occupation Table look-up Combo box
Income Number Monthly Income Type: Real; 2 dp Text box
G_Income Number Gross Income Type: Real; 2 dp Text box
N_Income Number Net Income Type: Real; 2 dp Text box
Expenditure Number Monthly Expenditure Type: Real; 2 dp Text box
Approved Text Approved status Table look-up: yes/no List box
Community
Field Data Type Description Validation Checks Control
Name Text Name of community Presence Text box
Acronym Text Key: Community Initials Presence Text box
NH Number Number of houses available Range, Type: Integer Text box
Income Number Qualifying Income Range, Type: Real; 2 dp Text box
Selection
Field Data Type Description Validation Checks Control
Applicant Text Key: Applicant name Presence, Table look-up Text/Combo
Community Text Key: Community acronym Presence, Table look-up Text/Combo
Rank Number Preference rank of selection Table look-up Text/List box
Queries
Structured Query Language
a. SELECT Applicant.ID, Applicant.Name, Applicant.DOB, Round((Date()-[DOB])/365.25) AS AgeFROM Applicant;
For support visitCalculating age from Date of Birth in MS Access
b. SELECT Applicant.ID, Applicant.Name, Applicant.DOB, Applicant.Gender, Applicant.ProfessionFROM Applicant
WHERE (((Applicant.Married)=Yes));
c. SELECT Applicant.ID, Applicant.Name, Applicant.Address, Selection.RankFROM Applicant INNER JOIN Selection ON Applicant.Name = Selection.Applicant
WHERE (((Applicant.ID) Like DatePart("yyyy",Date()) & "***") AND ((Selection.Community)="SGV"));
d. (i.) SELECT Selection.Community, Selection.RankFROM Selection
WHERE (((Selection.Rank)=1));
(ii.) SELECT Community_PR1.Community, Count(Community_PR1.Rank) AS CountOfRank
FROM Community_PR1
GROUP BY Community_PR1.Community;
e. SELECT Applicant.ID, Applicant.Name, Applicant.ProfessionFROM Community INNER JOIN (Applicant INNER JOIN Selection ON Applicant.Name = Selection.Applicant) ON
Community.Acronym = Selection.Community
WHERE (((Community.Name)="Claredon Court") AND ((Applicant.Income)>=[Community]![Income]));
http://office.microsoft.com/en-us/access-help/calculating-age-from-a-birth-date-in-access-HA001055071.aspxhttp://office.microsoft.com/en-us/access-help/calculating-age-from-a-birth-date-in-access-HA001055071.aspxhttp://office.microsoft.com/en-us/access-help/calculating-age-from-a-birth-date-in-access-HA001055071.aspxhttp://office.microsoft.com/en-us/access-help/calculating-age-from-a-birth-date-in-access-HA001055071.aspx -
8/13/2019 DB Tutorial
9/9
Database Tutorial: Applications04
Page 9of 9
C-A Lindsay
Specifications (continued)
Report
Structured Query Language
SELECT Community.Name, Selection.Rank, Applicant.ID, Applicant.Name, Applicant.Gender, Applicant.AddressFROM Community INNER JOIN (Applicant INNER JOIN Selection ON Applicant.Name = Selection.Applicant) ON
Community.Acronym = Selection.Community
WHERE (((Applicant.Income)>=[Community]![Income]) AND ((Applicant.Approved)="Yes"));
Query (Select) - Datasheet View
These results would then serve as the re
sults (record source) for report.
End of Tutorial