IENG2004 Industrial Database and Systems Design Microsoft Access I Defining databases (Chapters 1 and 2) Alison Balter Mastering Microsoft Access 2000 Development SAMS, 1999 What is Microsoft Access? Microsoft Access is a Database Management System. Data definition and storage (relational databases). Data manipulation. User interface (input/output). Architecture of Microsoft Access Table Data storage. Query Data extraction; provide filtered view. Form Data input, display. Report Formatting, calculating, printing, summarizing data. Data Access Page Link with Microsoft Internet Explorer. Macro Actions to be taken in response to events. Module Custom procedures (Visual Basic). 1
Tables Open the database Chap7.mdb Open table tblclients Datasheet view Change records and enter new records Design view Define fields (attributes) Queries Open query qrytimesheet Datasheet view New table as result of query Design view Query definition SQL view Query in SQL format Forms Open form frmclients Brings together data from multiple tables into a display that is easy to use Form view Design view Form Toolbox Field list Property sheet Datasheet view 2
Reports Open report rptclientlisting Print preview Design view Macros Manipulate data within forms and reports by triggering a macro action. MS Access provides many actions that we can include in a macro, e.g. opening tables and forms, running queries, etc. Modules Create a Visual Basic (VBA) procedure that implements a complex macro, or an action that cannot be implemented using a macro. Can be called from any query, form, report, or other procedure in the database. Example: basutils 3
Organizing your objects Organize related tables, forms, etc. in groups. Building a database Create a new, blank database. Create a table by entering data (in datasheet view) Create a table by using wizard Create a table in Design view: In-class assignment #1 Design view Table definition: Field name Data type Field properties Description Define a primary key 4
Field properties - 1 Data format, e.g. Length of text Number data type Date format Input mask Input mask wizard Custom mask; example: L0 for Class Type 0, 9, #, L,?, A, a, &, C, "literal", and some more Field properties - 2 Validation rule Comparison operators IN, BETWEEN, LIKE Wildcards:? * # Examples >= 50 AND <= 100 BETWEEN 50 AND 100 < 1000 IN ("Virginia", "Maryland") or Is Null LIKE "??00####" Validation text Field Properties 3 Required Specifies whether a field is allowed to have the value NULL Allow zero length Specifies whether a zero-length string value is allowed (only for text fields) Note the difference between NULL, "", and " " 5
Indexes An index helps Access search the database more efficiently. An index is a table matching the value in the index field(s) to the location of the corresponding record(s). Single field index: Using field properties. Multiple field indexes: Using the Indexes window (View Indexes) Modifying your database design Open the database Chap7.mdb Tables Backup Delete Rename Fields Rename Insert Copy Change data attributes Using Datasheets Datasheet Moving around Change row height and column width Arrange columns Hiding (and showing) columns Freezing columns Gridlines Data Adding and deleting rows Find/replace 6
Sorting and filtering data Sorting on one field Use toolbar in Datasheet view Sorting on multiple fields Choose Records Filter Advanced Filter/Sort Specify sorting order Use toolbar button or choose Filter Apply Filter/Sort Filtering By selection By form Relationships Choose Tools Relationships Create relationships between corresponding primary and foreign key pairs Enforcing referential integrity Cascading Join type Relationships (contd.) Open your database Lopez.mdb In-class assignment #1 (contd.) 7
Lookup Properties Lookup properties allow you to show the actual values behind (key) ID-numbers 8