WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR...

Preview:

Citation preview

WHAT IS A DATABASE?

• A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSEOR TO PUT IT SIMPLY

• A GENERAL PURPOSE CONTAINER FOR STORING AND MANAGING INFORMATION

DATABASE OBJECTS

OBJECTS IN A DATABASE

• TABLE• QUERY• FORMS• REPORTS

• MACRO• MODULE

Tables

• Fundamental structures in a database

• store data• data is organised in to fields

(columns) and records (rows)

• open to datasheet view

Query

• Tool for asking question about a data

• performing action on your data• can be used to combine or join

data from different related tables• can be used as basis for forms

and reports

Form

• Forms let you display and enter data in a convenient format

• More like fill in the blanks• Forms can include other forms

called subforms that lets you enter data into several tables at once

Report

• Reports let you print or preview data in a useful format

• Reports can print query result in a easy to undestand manner

Macro

• A macro is a set of instruction that automates a task you need to do often

• Access carries out action in the macro in the order in which actions are listed

Module

• Very similar to macros but give precise control over action taken

• requires visual basic programming expertise

OBJECT NAMING RULES

• THE NAMES CANNOT BE THE SAME AS ANY OTHER OBJECT OF THE SAME TYPE WITHIN THE SAME DATABSE

• YOU CANNOT GIVE A TABLE AND QUERY THE SAME NAME

• THE NAME CAN BE UP TO 64 CHARACTERS, INCLUDING SPACES. HOWEVER NAMES CANNOT START WITH A SPACE

OBJECT NAMING CONTD…..• THE NAMES CAN INCLUDE PUNCTUATIONS,

CHARACTERS EXCEPT A PERIOD (. ), AN EXCLAMATION MARK (!), OR BRACKETS{( )}

• AVOID USING SPACES IN OBJECT NAMES, FIELD NAMES FOR EXAMPLE USE EMPLOYEENAME INSTEAD OF EMPLOYEE NAME

• WHEN NAMING A FIELD, AVOID CHOOSING NAMES THAT ARE SAME AS BUILT IN ACCESS FUNCTIONS NAMES OR PROPERTY NAMES.

Creating a Table

• Click the Tables tab on the database window and then click new button --> choose design view

Table creating view in access

Defining a Table’s Fields

• Type a filed name (up to 64 characters)

• Select the data type• Description column type a description

of the field• click general or look up tab in the field

property area and define properties• repeat these steps for every field

Table -- Design View

Data Types

• Auto Numbers A number automaticaaly assigned and never

changes• Currency Rupees Amount• Date/Time Stores Date and Time• Lookup Values that come from

another table/query or list of values one supplies

Data Types ---> contd• Memo large bodies of text up to

640000 character in length• Number True numbers such as

quantities. Choose only for field types that require calculations

• OLE object Any OLE object such as picture , sound or word processing document

Data Types ---> contd

• Text Any written text upto 255 characters in length, numbers that don’t require calculations, and certatin

numbers such as zip code, phone numbers etc.,

• Yes/No A true or False Value only

Important General Field Properties• Allow Zero Length: If Yes, the field will

accept an “empty string” as a valid entry, even if required property is set to YesThe empty string will appear as two quotation mark with nothing in between (“”) when first typed into the field. Those quotes will disappear when the cursor is moved to a different field

Important General Field Properties -- continued• Caption: Lets you define an

alternate name for the field that will be used in datasheet view and labels

• Decimal Places: Lets you specify the number of digits to the right of the decimal separator in a numeric field

Important General Field Properties ---- continued• Default Value: Lets you define a

value that is automatically inserted into the field.You can type a different value during data entry if required The default value for a text field is empty string and for a number or currency field is 0

Important General Field properties ----continued• Field Size: Lets you specify the

maximum length of text allotted in a field or the acceptable range of numbersThough Access does’nt pad text that is shorter than its allotted field length, a smaller maximum field size can conserve memory and speed up processing

Important General Field Properties ---- continued• Format : Lets you define the

appearance of a data in a fieldeg., You can show a date as 14/02/2003 or as February 14, 2003

• Indexed: Lets you choose whether to Index this field and whether to allow duplicates in the index

Important General Field Properties ---- continued• Input Mask: Lets you define a

pattern for entering data into a field• Required: If set to Yes, The field

cannot be left Blank• Validation Rule: Lets you create an

expression that tests data as it comes into the field and rejects faulty entries

EXAMPLES OF VALIDATION RULE EXPRESSION• >0 DISALLOWS 0 OR A

NEGATIVE NUMBER IN A NUMBER OR CURRENCY FIELD

• <>0 ALLOWS ANY NEGATIVE OR POSITIVE NUMBER BUT NOT 0

EXAMPLES OF VALIDATION RULE EXPRESSION --- CONTD• BETWEEN 1 AND 100 ACCEPTS

NUMBERS ONLY IN THE RANGE OF 1

AND 100 (INCLUSIVE)• >=#30/11/2000 PREVENTS

DATES EARLIER THAN

30/11/2000

PRIMARY KEY

• A Primary key is a field (or group of fields) that uniquely identifies each record

• When one defines a primary key you do make sure that no two records in the table have the same value in the field that defines the primary keyKeep records sorted by the entries in the primary keyspeeds up processing

Primary key ---- does what?• Primary key ensures that each

record has a unique identificationand that a field is not left null both unique property and not null property is taken when a field is defined as primary key

Input mask

• When you use input mask, special characters tell access how to limit the data that gets entered in a field

Input mask characters

• 0 required numbers (0-9), no plus or minus sign

• 9 optional number (0-9) or space, no plus or minus sign

• # optional number (0-9) or space, plus or minus sign allowed

Input mask characters continued• L required letter (A_Z)• ? Optional letter (A_Z)• A Required letter or number• a optional letter or number• & required character or space• C optional character or space

Input mask characters continued• < characters that gets converted

to lower case• > characters that get converted

to upper case• ! A mask that displays from right

to left, characters always entered left to right

• \ Next character in mask to display as a constant

Sample Input Mask

• The Mask Allows these field values

• (999)000-0000 (080)228-6923( )228-6923

• >LL0000 as02369• AAa d13

15AN

Sample Input Mask

• 00000-9999 98450-1234598451-

• LL-00-L?-0009 KA-02-P-1152

KA-05-MA-116

Relationship

• For tables to be related they must have fields with common valuesfor eg., in two tables dept and emp there is a common field deptno through which the tables can be related.

Types of relationship

• One- To- One: This type of relationship exists when there is only one record on each table for each linking value

• One- To- Many: When there can be more than one record for a linking value on one side of a relationship

• Many- To- Many: This type describes the situation where linking values can appear in multiple records on both sides of relationship

Recommended