Professional Documents
Culture Documents
A. R. Dani
Basics
DBMS : Data Base Management Systems. DBMS: An abstraction of an enterprise related to an enterprise It is used to store data of the enterprise Data: Transactional Data and other type of data DBMS: Allows enterprise to store, retrieve, update, delete and backup the data. Life Cycle of Data: C Store, Retrieve, Update, Backup and Delete The alternative to DBMS was File System In File System, data are stored in one or more data files. Data Files can be of different types.
Basics
Problem with File System Redundancy of Data Same data in different files Access through Programmers (no SQL like access) Sharing data among different users is difficult Explicit locking by programmers Difficult to answer adhoc queries Many data files are created. Explosion of files Update problems No centralized control Access controls has to be implemented by programmers Files are created for specific purposes in most cases as such are specific for the purpose for they are created Time to develop applications
Basics
DBMS Designed taking into account enterprise view Centralized Control Access Controls enforced by DBMS Reduce Data Redundancy Developed for Data Sharing SQL can be used to store data, retrieve data and update data Automatic backup and recovery features Programming Languages access through standardized DBMS interface Easy to applications. Many tools are available Manage large volume of data
RDBMS
Relational Data Base Management System (RDBMS) RDBMS: It views data as collection of tables. A Table has row and columns (two dimensional structure) Entity Relationship Diagrams are used to model tables A row represents record A column represent an attribute Primary Key Different tables can be related by table values Primary Keys, Foreign Keys RDMS Design: Reduce data redundancy and update anomalies Data Normalization Referential Integrity
MS Access is part of MS Office It can be used to store data As such there is overlap with some other products available in MS Office and from other vendors Although there is always overlap, the following rules might help when deciding when / when not to use MS Access: MS Access is best used for long-term data storage and/or data sharing. MS Excel is best used for minor data collection, manipulation, and especially visualization. SPSS is best used for minor data collection and especially data analysis. It is easy to export data from MS Access to Excel SPSS
MS Access
Cheap, readily available (packaged with MS-Office Premium). Easy to use (relative to other systems ) Easy to use Interface Wizards Oracle may require one Engineer to maintain the server as a database administrator It also requires another engineer to serve as an application developer MS Access Includes front-end tools for rapid application development (RAD). This also makes MS-Access a good prototype environment. All programming languages can use it.
MS Access
MS Access
MS-Access can handle a large number of records, but is somewhat slow compared to some of the high-end platforms. Multiple users may use the database simultaneously, but MSAccess is known to become unstable with greater than 3-5 users. MS Access is used by smaller companies It is also used as Database for small applications In case of complex multi users applications, which have to handle large number of record , the other RDBMS will be preferred. ORACLE/DB2 are preferred choices for complex enterprise applications MS Access Learning
MS Access
Although the term database typically refers to a collection of related data tables, an Access database includes more than just data. In addition to tables, you can add: Saved queries (stored procedures) - organizing and/or manipulating data Forms gui interaction with data, event programming Reports customized results for printing (~ static forms) Macros and VB programs for extending functionality Microsoft provides some logical integration of these tools through wizards. However, these are pretty basic - most developers must pick and choose the best approach when implementing applications.
MS Access File
VB + Macros Event Driven Automation, etc.
Forms (Active)
Reports (Static)
Queries
Applications
Front-End File - Contains all Application Entities (Forms, Queries, etc.) and links to data tables in back-end file. Note you may have more than one FE to accommodate different user types.
Forms (Active)
Reports (Static)
Labs
H&P
Forms are parts of user interface. Forms are used to enter, edit or browse data from a database Reports present requested information and allow to create hard copies. Microsoft Access is a relational database management system (DBMS or RDBMS). At the very core, it is a software engine that provides an interface between physical data and user application queries. Other examples of DBMS applications include: Oracle mySQL SQL Server (Microsoft) DB2 (IBM) Informix
Tables Overview
Think of Access as a collection of
Data Types
Text Memo Numbers
Byte Integer Long integer Single Double
Date/time
Create Table
Click on the round Office button Choose New from the drop-down menu In Create Blank Database window specify the database name Click Create Using Wizard Design View Specify field names Data types Properties Determine a primary key Save the table
Tables
General Setup for Tables Describe General Options Show Validation Rule Relationships Lookup Option
Tables
Table Relationships
Table Import
Importing a Table makes a copy of existing data
Linking a Table lets you control existing data through Access (Exercise Caution !)
Tables
Data storage principles Attempt to store data 1 time / 1 place; Do not store data that may be calculated from other fields (utilize queries); and Strive for very discrete data storage (no ambiguity garbage in / garbage out). Choose real or arbitrary (autonumber) unique identifier for each record. Relationships Use table relationships to automatically cascade delete and update records. Other Data Sources Import = Copy; Link
Query
Specify the source of data If multiple tables are used, specify relationships between tables Select desirable fields from the table(s) and options related to the fields Specify a criterion
To be selected a record must satisfy a criterion Expressions may contain the following operators:
Math Operators Relational operators Boolean Operators String Operators Miscellaneous Operators
Math Operators
+
*
Addition
Subtraction Multiplication
/
\ ^ Mod
Division
Integer Division Exponentiation Modulo (remainder) division
Relational Operators
= <> < > <= >= Equal Not equal Less than Greater than Less than or equal to Greater than or equal to
Boolean Operator
And
Or
Logical And
Logical Or
Xor
Excusive Or
Not
Negation
Concatenation
Similar to
Between Between 2 values inclusive and In (list) One from the list
Is Null True if the field is empty
Queries Retrieve Data SQL (Structured Query Language) is a very widely used
Query
database language designed specifically for communicating with databases SQL is not proprietary almost every DBMS supports SQL (including MS-Access). An MS-Access query is a set of stored SQL instructions that manipulate and/or select data from one or more tables. Select Query Data grouping and/or filtering Make-Table Query Select + creates/populates new table. Update Query Updates fields from specified table data Append Query Runs query on one table, appends results to a table Delete Query Delete selected records from table
Query
SQL is relatively easy to learn, but extremely powerful One of the easiest ways to learn is to use MS-Access Query by Example methods (QBE), It also generates corresponding SQL Statement . After QBE one can look at the generated SQL command Remember that a query is nothing more than the database engine running the stored SQL command It looks and sometimes acts like a table, but really adds little mass to the database file. In Query, Name the calculated field, then type a colon, then type the equation using brackets ( [ ] ) around table fields. If there is ambiguity in the field names between tables, you may need to type table.[field] format. Ex: BMI: [Weight]/([Height]/100)^2 Select , Insert , Delete, Update with where
Choose Ascending or Descending in the Sort Row This query would sort by Gender THEN by Race.
This query will return all records in the database for: Females who are not white whose height are greater than 150 cm and who weigh between 60 and 70 kg
Running this Query indicates there are 203 Females and 261 Males in the database.
Avg
Min Max Count StDev Var
2)
3)
Query
Queries are extremely easy to set up/use They provide an up-to-date snapshot of your data at any time. Queries may be used to calculate values based upon existing fields, join fields from separate tables, globally update or delete data, and export linked/calculated data to external programs. Different types of joints The queries are really nothing more than stored SQL statements that are run upon command. They add little mass to the file application. If you use MS-Access its important should feature is to import data and export it.
GUI Forms
Out of Program
Create using Form Wizard Create using Form Design view Specify source of data will be presented by the form Table Query Specify fields related to the form Add labels, titles, graphics and so on Form Design View : Form Header a place for titles, graphics, additional information Form Details section the fields used to create a form and control elements related to the fields Form footer a place for any items which will appear at the bottom of the form
MS Access Forms
MS Access Forms
A Form can be associated with a Table Must be bound with fields from the source table or query Contain data from correspondent fields, labels or other controls (like command button) or another form called subform Viewing Forms: Open database Click Forms tab to display all available forms in the database Select the form Select Open To view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes Forms can be used for editing data The results of query can also be displayed in form
Sub Forms A Form can have many sub forms Represent 1:N relationships To add a subform to a form Create a form that will be a subform Click on Subform/Subreport button and then click on a form where the subform should appear Specify the source for the subform Specify the fields to link the form and subform Reports present table contents or query results in an easily assimilated format Reports have Design view and Print Preview Report Design View is similar to the Form Design view
Reports Page Header contains data and graphics appearing at the top
of each page Report Header contains the data and graphics appearing at the top of the first report page Detailed section contains data from tables or queries Page Footer contains the data and graphics appearing at the bottom of every page Report Footer contains the data and graphics appearing at the bottom of the last report page Reports can be of following types Columnar reports a single record on a page Tabular reports datasheets: fields from the tables are presented as columns Justified reports combine two previous types of the reports
Creating Reports
With a Wizard Design view: Specify source for the report . The source is one or more tables. A Query can also be specified Select Fields from the Fields List Add labels Used for titles and captions The headers can also be described here The data formatting can also be done Switch the view to see the result.