Upload
sikkander-sulaiman
View
216
Download
0
Embed Size (px)
Citation preview
8/6/2019 IT for Mgt Module 2
1/35
Module 2
Database
8/6/2019 IT for Mgt Module 2
2/35
Introductio
n
The term database originated withinthe computing discipline.
Although its meaning has beenbroadened by popular use, even toinclude non-electronic databases, weconcentrate on computer databases.
8/6/2019 IT for Mgt Module 2
3/35
Definitio
n
Acomputer database is a structuredcollection of records or data that isstored in a computer system so that acomputer program or person using aquery language can consult it toanswer queries
The records retrieved in answer toqueries are information that can beused to make decisions.
8/6/2019 IT for Mgt Module 2
4/35
Definitio
n
The term database refers to the collectionof related records, and the software shouldbe referred to as the database
management system or DBMS.
When the context is ambiguous, however,many database administrators andprogrammers use the term database to
cover both meanings.
8/6/2019 IT for Mgt Module 2
5/35
Microsoft Office Access Microsoft Office Access, previously
known as Microsoft Access, is a relationaldatabase management system from
Microsoft which combines the relationalMicrosoft Jet Database Engine with agraphical user interface and softwaredevelopment tools.
It is a member of the 2007 Microsoft Officesystem
8/6/2019 IT for Mgt Module 2
6/35
Use of
Access
Skilled software developers and dataarchitects use it to developapplication software.
Relatively unskilled programmers andnon-programmer "power users" canuse it to build simple applications.
It supports some object-orientedtechniques but falls short of being afully object-oriented development tool
8/6/2019 IT for Mgt Module 2
7/35
Uses
Access is used by small businesses, withindepartments of large corporations, and byhobby programmers to create ad hoc
customized desktop systems for handlingthe creation and manipulation of data.
Access can be used as a database for basicweb based applications hosted on
Microsoft's Internet Information Servicesand utilizing Microsoft Active Server PagesASP
8/6/2019 IT for Mgt Module 2
8/35
Prime benefit
One of the benefits ofAccess from aprogrammer's perspective is its
relative compatibility withSQL(structured query language)
Queries may be viewed and edited asSQL statements
8/6/2019 IT for Mgt Module 2
9/35
File exte
nsio
ns
Microsoft Access saves information under the following fileextensions: .mdb - Access Database (2003 and earlier)
.mde - Protected Access Database, with compiled macros(2003 and earlier)
.accdb - Access Database (2007) .accde - Protected Access Database, with compiled macros
(2007) .mam - Access Macro .maq - Access Query
.mar - Access Report .mat - Access Table .maf- Access Form .adp - Access Project
.adn- Access Blank Project Template
8/6/2019 IT for Mgt Module 2
10/35
Getti
ng started
First of all you need to understandhow Microsoft Access breaks down a
database. Some keywords involved in this
process are: Database File, Table,Record, Field, Data-type
8/6/2019 IT for Mgt Module 2
11/35
Database andTables
Database File: This is your main file thatencompasses the entire database and thatis saved to your hard-drive or floppy disk.
Example) StudentDatabase.mdb
Table: A table is a collection of data abouta specific topic. There can be multipletables in a database.
Example #1) StudentsExample #2) Teachers
8/6/2019 IT for Mgt Module 2
12/35
Field a
nd Datatypes
Field: Fields are the different categorieswithin a Table. Tables usually containmultiple fields.
Example #1) Student LastNameExample #2) Student FirstName
Datatypes: Datatypes are the properties ofeach field. A field only has 1 datatype.
FieldName) Student LastNameDatatype) Text
8/6/2019 IT for Mgt Module 2
13/35
Example of a database structure
STUDENT database structure
Field name Type Length
Code Numeric 4
Name String 20
Date-of-Birth Date
Address line-1 String 20
Address line-2 String 20
Address line-3 String 20
Address line-4 String 20
Marks-English Numeric 3
Marks-Hindi Numeric 3
Marks-Physics Numeric 3
Marks-Chemistry Numeric 3
Marks-Maths Numeric 3
8/6/2019 IT for Mgt Module 2
14/35
Creati
ng a database
8/6/2019 IT for Mgt Module 2
15/35
Creati
ng a database
When Microsoft Access first starts up, a dialog box isautomatically displayed with options to create a newdatabase or open an existing one. If this dialog box isdisplayed, click Blank Access Database, and then
click OK.
If you have already opened a database or closed thedialog box that displays when Microsoft Access startsup, click New Database on the toolbar, and thendouble-click the Blank Database icon on the
General tab. Specify a name and location for the database and
click Create.
8/6/2019 IT for Mgt Module 2
16/35
Create a database without using
the Database
Wizard
8/6/2019 IT for Mgt Module 2
17/35
Example of a table
8/6/2019 IT for Mgt Module 2
18/35
Double-Click on"Create table inDesign view". You get this Design
View
8/6/2019 IT for Mgt Module 2
19/35
Defining fields
Define each of the fields in your table.
Under the Field Name column, enter
the categories of your table. Under Data Type column, enter the
type you want for you categories.
Under t
he Descriptio
ncolum
n, e
nterthe text that describes what your field
is. (This field is optional).
8/6/2019 IT for Mgt Module 2
20/35
Data type It is the attribute of a variable or field that
determines what kind of data it canhold. For example, in a Microsoft Access database, the
Text and Memo field data types allow the field to
store either text or numbers, but the Numberdata type will allow the field to store numbersonly.
Number data type fields store numerical datathat will be used in mathematical calculations.
Use the Currency data type to display or
calculate currency values. Other data types are Date/Time, Yes/No, Auto
Number, and OLE object (Picture).
8/6/2019 IT for Mgt Module 2
21/35
For our tutorial enter the followingitems:
8/6/2019 IT for Mgt Module 2
22/35
Primary key Keys are one or more fields (columns) whose value or
values uniquely identify each record in a table.
A primary key does not allow Null values and mustalways have a unique value.
A primary key is used to relate a table to foreign keysin other tables.
In the above example, make the SocSec # field theprimary key, meaning that everystudent has a socialsecurity number and no 2 are the same.
To do this, simply select the Soc Sec # field andselect the primary key button
After you do this, Save the table
8/6/2019 IT for Mgt Module 2
23/35
Now, enter t
he data
Click on the Datasheet View andsimply start entering the data into
each
field.
8/6/2019 IT for Mgt Module 2
24/35
Manipulati
ng Data
Adding a new row
Simply drop down to a new line and enter theinformation
Updating a record
Simply select the record and field you want toupdate, and change its data with what you want
Deleting a record Simply select the entire row and hit the Delete
Key on the keyboard
8/6/2019 IT for Mgt Module 2
25/35
Form desig
n
AForm is nothing more than a graphicalrepresentation of a table.
You can add, update, delete records in your table byusing a form.
Although a form can be named different from a table,they both still manipulate the same information andthe same exact data. Hence, if you change a record ina form, it will be changed in the table also.
A form is very good to use when you have numerous
fields in
a table.Th
is way you can
see all the fields i
none screen, whereas if you were in the table view
(datasheet) you would have to keep scrolling to getthe field you desire.
8/6/2019 IT for Mgt Module 2
26/35
Form
Wizard
It is a very good idea to create a formusing the wizard, unless you are an
advanced user a
nd k
now w
hat youare doing. Microsoft Access does a
very good job of creating a formusing the wizard.
8/6/2019 IT for Mgt Module 2
27/35
Create a
Form
The following steps are needed to create a basic form:
Switch to the Database Window. You can do this bypressing F11 on the keyboard.
Click on the Forms button under Objects on the leftside of screen
Double click onCreate FormUsing Wizard
On the next screen select the fields you want to viewon your form. Most of the time you would select all ofthem.
Click Next (Contd in the next page)
8/6/2019 IT for Mgt Module 2
28/35
C
reate aF
orm (C
ontd)
Select the layout you wish
Click Next
Select the style you desire...HINT: if you plan onprinting your form, I suggest you use a lightbackground to save on printer toner and ink
Click Next
Give your form a name, and select Open the Formand enterinformation
Select Finish
You should see your form. To adjust the design ofyour form, simply hit the design button (same as withthe tables), and adjust your form accordingly
8/6/2019 IT for Mgt Module 2
29/35
Report A report is an effective way to
present your data in a printed format.
Because you have control over thesize and appearance of everything ona report, you can display theinformation the way you want to see
it.
8/6/2019 IT for Mgt Module 2
30/35
C
reate a Report As with the Form, it is a very good idea to create a
report using the wizard, unless you are an advanceduser. Microsoft Access does a very good job using thewizard to create reports.
Switch to the Database Window. You can do this bypressing F11 on the keyboard.
Click on the Reports button under Objects on theleft side of screen
Double click onCreate Report Using Wizard
On the next screen select the fields you want to viewon your form. Most of the time you would select all ofthem.
Click Next (Contd in the next page)
8/6/2019 IT for Mgt Module 2
31/35
C
reate a Report (C
on
td) Select if you would like to group your files. Keep repeating
this step for as many groupings as you would like. Click Next Select the layout and the paper orientation you desire Click Next Select the style you desire...HINT: if you plan on printing
your report, I suggest you use a light background to saveon printer toner and ink
Click Next Give you report a name, and select Preview the Report Select Finish
You should see your report. To adjust the design of yourreport, simply hit the design button (same as with thetables), and adjust your report accordingly
8/6/2019 IT for Mgt Module 2
32/35
Basic queries usin
g SQL In Microsoft Access you can use
queries to extract information (data)
from one (or more) tables (or fromother queries).
The information you retrieve can belimited by the definition of your
query.
8/6/2019 IT for Mgt Module 2
33/35
A
typical SQL statemen
t A typical SQL statement resembles
the following:
SELE
CTDept
Code,
CrsNum,
Title
FROM
Courses WHERE DeptCode = COMM;
There are four parts to this statement:
1. SELECT
specifies which fields to project 2. FROM specifies the
underlying table (or tables) for the query;
8/6/2019 IT for Mgt Module 2
34/35
A typical SQL statement (Contd)
3. WHERE
specifies one or more conditionsthat each record must satisfy in order tobe included in the results set;
4. ; (semicolon) all SQL statementsmust end with a semicolon (but if youforget it, Access will add it for you).
8/6/2019 IT for Mgt Module 2
35/35