database
database
Access)
Unit of learning code: ICT/CU/IT/CR/4/6
Related Unit of Competency in Occupational Standard: Manage Database Systems (MS Access)
This unit specifies competencies required to manage database system. Which involve identifying
database concepts, designing a basic database, creation and manipulation of database objects,
database testing and printing of database objects. This provides the learner with the competencies
in achieving the above listed items.
377
Database - Shared collection of logically related data (and a description of this data), designed
to meet the information needs of an organization.
Information - Data processed to be useful in decision making
Metadata - Data that describes data
Fields - The place where data is placed within the database is called a field. One field holds one
piece of data. If you are storing student details, possible fields would include Name, Admission
number, Age
Records - All the fields for one student constitute a record, Records ensure which name relates
to which admission number, age
Table - A collection of records that describe similar data is called a table. A database for student
details could have tables for admission information, fees, and exams.
Manual filing Systems - These are filing systems that had the following properties with regards to
records management.
om
File based systems - A file-based system is a collection of application programs that perform
services for the end users. Each program within a file-based system defines and manages its own
data. Because of this, there are limitations as to how that data can be used or transported. There
is data dependency.
If the file structure is changed then the program code will also change.
i. Hardware-These are the tangible components that make up the database such as
physical storage devices.
ii. Software-These are the software programes that manage the database such as the
Database Management System, Antivirus etc.
iii. Data-These are the actual records which are stored inside the database.
iv. Users-These are those people who interact with the database in one way or another
such as data entry clerks, database administrators, programmers etc.
v. Rules and procedures-these are the various guidelines and procedures that define how
data can be accessed.
(a) Advantages of database approach
i. Data independence
om
The data is held in such a way that changes to the structure of the database (schema) does not
.c
t
ve
database is complex where backups are not available. It may require reconstruction of
t.c
ve
disks.
t
sy
ea
Database Models
These are a variety of ways to organize data within a database. A database model specifies the
rules according to which data are structured and the associated operations that are permitted. It
may also be a technique for the formal description of data structure, usage constraints and
operations. The facilities available vary from one database to another. Each DBMS maintains a
particular database model. A Database model is a combination of at least three components:
381
A flat file database model consists of one or more readable files normally stored in a text format.
Information in these files is stored in fields. Every flat-file database is different because
companies store different data and companies have different needs. After a flat- file has been
created and data has been stored in these files, a method must be devised in order to retrieve the
data, create new records, update records or delete records.
Flat-file databases are created and used to migrate data from one database implementation to
another particularly in relational databases.
382
Advantages of flat-file model
i. Easy to come up with
Disadvantages of flat-file model
ii. Do not promote a structure in which data can easily be related.
iii. It is difficult to control data duplication.
iv. The physical location of the data field within the file must be known.
v. A program must be developed to manage the data.
Examples of applications you can use to develop flat-file database word processors,
spreadsheets.
A link is an association between precisely two records. Consider a database that represents a
.c
t
ve
customer-account relationship in a banking system. There are two record types: customer and
t
sy
ea
account. The customer record type can be defined using three fields: customer name, customer-
street, and customer-city. Similarly, the account record consists of two fields: account-number
and balance. Now consider a sample database that shows that customer Hayes has account A-
102, customer Johnson has accounts A-101 and A-201, and customer Turner has account A-305.
Note that the set of all customer and account records is organized in the form of a rooted tree,
where the root of the tree is a dummy node. A hierarchical database is a collection of such rooted
trees, and hence forms a forest. Each such rooted tree shall be referred as a database tree. The
content of a particular record may have to be replicated in several different locations. For
example, in this customer-account banking system, an account may belong to several customers.
The information pertaining to that account, or the information pertaining to the various
customers to which that account may belong, will have to be replicated. This replication may
occur either in the same database tree or in several different trees. Record replication has two
major drawbacks:
Data inconsistency may result when updating takes place.
Waste of space.
383
A tree-structure diagram is the schema for a hierarchical database. Such a diagram consists of
two basic components:
Boxes, which correspond to record types
Lines, which correspond to links
A tree-structure diagram serves the same purpose as an entity–relationship (E-R) diagram;
namely, it specifies the overall logical structure of the database.
om
.c
To access the data, query by path navigation is used. Examples of databases designed based on
sy
ea
384
A network database model is a database model that allows multiple records to be linked to the
same owner record type (parent record). The multiple linkages which this information allows the
network database model to be very flexible. In addition, the relationship that the information has
in the network database model is defined as many-to-many relationship because one owner
record type can be linked to many member records and vice versa. This database model was
created for three main reasons.
1. To represent complex data relationships more effectively.
2. To improve database performance.
3. Imposing a database standard
om
t .c
ve
t
sy
ea
385
Figure 122:Network database model
Customer# CustomerName
Purchases set Payments set
1:M
1:M
386
Advantages of a Network Database Model
Because it has the many-many relationship, network database model can easily be accessed
in any table record in the database.
For more complex data, it is easier to use because of the multiple relationship founded among
its data.
Easier to navigate and search for information because of its flexibility.
Disadvantage of a Network Database Model
It may be Difficult to implement for first time users.
Difficulties with alterations of the database because when information entered can alter the
entire database.
Hardware and software overheads
Applications:
Integrated Database management system (IDMS)
Integrated data store (IDS)
om
t .c
ve
In this model, both data and their relationships are contained in a single structure called object.
An object includes information about relationship between the facts within the object as well as
information about its relationship with other objects. Objects with similar characteristics will
form a class. In this model the database is modelled in form of objects and the relationships.
Class: An entity that has a well-defined role in the application domain, as well as state,
behaviour, and identity
o Tangible: person, place or thing
o Concept or Event: department, performance, marriage, registration
o Artifact of the Design Process: user interface, controller, scheduler
Object: a particular instance of a class
State: attribute types (properties) and values
Behaviour: how an object acts and reacts (methods). Behaviour is expressed through operations
that can be performed on it.
387
Example: Consider a scenario player described by player No, Player Name and Age plays for
one and only one club. A club is described by club No, Club Name. A club plays several fixtures
in a season. A fixture is described by fixture No, Date, venue, and time. Each fixture involves
two clubs only. Draw an object database model for this scenario. Operations to be performed on
this database include add, search, update and delete of records.
Fixture
om
Player Club
.c
FixtureNo
t
1..*
t
sy
Date
ea
PlayerName ClubName
*..1 Add()
2..0 Venue
Add()
Age
Add()
Delete()
Delete()
Delete()
Search()
Search()
Search()
e) Multimedia database
A Multimedia database (MMDB) is a collection of related multimedia data. The multimedia data
om
include one or more primary media data types such as text, images, graphic objects (including
t.c
ve
f) Hypermedia database
Hypermedia, an extension of the term hypertext, is a nonlinear medium of information which
includes graphics, audio, video, plain text and hyperlinks. This contrasts with the broader term
multimedia, which may include non-interactive linear presentations as well as hypermedia. The
World Wide Web is a classic example of hypermedia, whereas a non-interactive cinema
presentation is an example of standard multimedia due to the absence of hyperlinks.
g) Centralized database
A centralized database (sometimes abbreviated CDB) is a database that is located, stored, and
maintained in a single location. This location is most often a central computer or database
system, for example a desktop or server CPU, or a mainframe computer.
h) Distributed database
389
A distributed database is a database in which storage devices are not all attached to a common
processing unit such as the CPU, controlled by a distributed database management system
(together sometimes called a distributed database system). It may be stored in multiple
computers, located in the same physical location; or may be dispersed over a network of
interconnected computers. Unlike parallel systems, in which the processors are tightly coupled
and constitute a single database system, a distributed database system consists of loosely coupled
sites that share no physical components.
many.
t.c
ve
In Relation database models a relation is modelled as a table with rows and columns.
t
sy
ea
390
Figure 124: Relational database model
In the above model there are two relations Employee relation and department relation. The
attribute EmpNo is used to link the two relations.
Advantages of relational database model
Structural independence is promoted by use of independent tables. Any changes in table
structure do not affect data access or application programs.
Tabular view improves conceptual simplicity, thereby promoting easier database design,
implementation, management, and use.
Ad hoc query capability is based on SQL.
Widely accepted in many enterprises.
Disadvantages of relational database model
om
.c
Pick an organization of your choice within the area you reside in. The management of that
organization have asked you to provide advice on which database organization best suits the
organization’s need.
i Advice the organization on the merits of having a database
ii Outline the components that will be required to set up the Database
iii Recommend a database model that fits the organization of choice and give
justifications for the chosen model
5.2.1.5 Self-Assessment
iii. Which are the five components of the DBMS environment and discuss how they relate to
each other.
t
sy
Computer
ea
om
t.c
ve
t
sy
ea
393
5.2.1.8 model answers to self-assessment
i. Discuss the meaning of each of the following terms:
(a) data
For end users, this constitutes all the different values connected with the various
objects/entities that are of concern to them.
(b) database
A shared collection of logically related data (and a description of this data) designed to meet
the information needs of an organization.
(c) database management system
A software system that: enables users to define, create, and maintain the database and
provides controlled access to this database.
(d) application program
A computer program that interacts with the database by issuing an appropriate request
(typically an SQL statement) to the DBMS.
om
This is essentially the separation of underlying file structures from the programs that operate
t
sy
ea
394
(1) Hardware: The computer system(s) that the DBMS and the application programs run on.
This can range from a single PC, to a single mainframe, to a network of computers.
(2) Software: The DBMS software and the application programs, together with the operating
system, including network software if the DBMS is being used over a network.
(3) Data: The data acts as a bridge between the hardware and software components and the
human components. As we’ve already said, the database contains both the operational data
and the meta-data (the ‘data about data’).
(4) Procedures: The instructions and rules that govern the design and use of the database. This
may include instructions on how to log on to the DBMS, make backup copies of the
database, and how to handle hardware or software failures.
(5) People: This includes the database designers, database administrators (DBAs), application
programmers, and the end-users.
iv. Discuss the advantages and disadvantages of DBMSs.
Some advantages of the database approach include control of data redundancy, data
om
consistency, sharing of data, and improved security and integrity. Some disadvantages
t .c
ve
395
5.2.2 Learning Outcome 2: Design basic database
5.2.2.1 Introduction to the learning outcome
This section gives an overview of the various database design concepts focusing on data
relationships and database integrity constraints. By the end of it, the learner should be able to
competently identify and come up with data relationships, the various database integrity
constraints and design a basic Entity-Relationship diagram in database design.
This is the process of creating a design for a database that will support the enterprise’s operations
ea
and objectives. Database design is performed in three phases (stages) namely conceptual design,
logical design and physical design.
Phase 1: Conceptual design
This is the process of constructing an abstract model of data to be included in the database. This
model should be independent of any database management system (DBMS) and other physical
considerations.
Steps followed:
a) Identification of entities
b) Identification of relationships
c) Construction of conceptual data model.
a) Identify entities
It is a thing or object of importance about which data must be captured.
To identify entities in the requirements, map nouns to entities
Database entities appear in a data model as a rectangle with a title.
396
The title (in upper case) is the name of the entity.
Types of entities
i. Weak entity: This is an entity that does not have sufficient attributes to form a primary key
(unique identifier). The existence of a weak entity is indicated by a double rectangle in the
ER diagram.
Weak entity
i. Strong entity: This is an entity that has a primary key (unique identifier). A weak entity is
existence dependent.
Strong entity
ii. Recursive Entity: This is an entity in which a relationship can exist between occurrences of
the same entity. This occurs in a unary relationship. For instance, a doctor can be a patient.
They are represented as follows:
om
t.c
ve
t
sy
ea
DOC
TOR
Generalization: The process of defining a more general entity type from a set of more
specialized entity types. BOTTOM-UP
Specialization: The process of defining one or more subtypes of the supertype and forming
supertype/subtype relationships. TOP-DOWN
b) Identification of relationships
A relationship is a meaningful association between entity types.
397
Classifying relationships:
i. Degree
ii. Cardinality
iii. Optionality
1. Classification according to degree
Degree: The number of entity types participating in a relationship.
i. Unary (recursive) relationship- One entity type participates in a relationship.
DOCTOR DOCTOR
DOCTOR PATIENT
PHARMICST
om
.c
PATIENT
t
tve
sy
ea
a b
1 1
a b
2 2
398
ii). One-to-many relationship(1:m): An entity occurrence in entity type A can have several
matching entity occurrences in entity type B, but each entity occurrence in entity type B can
only have a maximum of one entity occurrences in entity type A.
a b
1 1
b
a
2
2
a b
.c
1 1
t
t ve
a b
sy
ea
2 2
numbers beside the feet are used to show a Cardinality: Cardinality: Not
Not
t
sy
ea
entities using the format many side of a shown except the shown except the
(x,y), which represent the relationship. A single connectivity. connectivity.
Optionality:
minimum and maximum line indicates a one side Optionality:
value, respectively. of the relationship. Optional Optional
Optionality: Optionality: Optional participation
Mandatory is participation is
participation indicated by participation is shown shown with an open shown with an
one/ two line(s) linking with an open circle circle next to open circle next to
the entity to the diamond next to optional end. optional end. optional end.
next to mandatory end. Mandatory Mandatory Mandatory
Optional participation participation is shown participation is participation is
indicated by a circle near with two vertical lines. shown with shown with
optional end. continuous link line continuous link
next to mandatory line next to
end. mandatory end.
400
Comparison of ERD notations.
a) Chen’s notation
Chen model moved conceptual modelling into the practical database design arena by establishing
basic building blocks: entities and relationships. Dominant player in the CASE tool market
om
.c
This model combines connectivity and cardinality information in a single symbol set.
Popularized by the Knowledge ware modeling tool. Cardinality is limited to 0,1 or N.
c) Rein85 notation
This model is based on the same modelling conventions as the Crow’s Foot model, its symbols
are different. It does not recognize cardinalities explicitly, relying on connectivity to lead to
logical cardinality conclusions.
d) IDEF1X notation
This is a derivative of the integrated computer-aided manufacturing (ICAM) studies of the late
1970s. Became the source of graphical methods for defining the functions, data structures and
dynamics of manufacturing businesses. The integration of these methods became known as IDEF
(ICAM Definition). Hughes Aircraft developed the original version named IDEF1. Later, the
extended version was named IDEF1X.
Example 1: Chen’s notation
401
M
1 M PATIENT
tr t MEDICATIO
DOCTOR
(0, (1, (0, (1,
Each DOCTOR must treat one or more PATIENTS. Each patient must be treated by a doctor.
t.c
ve
Each PATIENT may take one or more MEDICATIONS. Each MEDICATION is given to one
t
sy
ea
PATIENT.
Example1: Rein85
Treat
Takes
DOCTOR PATIENT
MEDICATIO
402
Each DOCTOR must treat one or more PATIENTS. Each patient must be treated by a doctor.
Each PATIENT may take one or more MEDICATIONS. Each MEDICATION is given to one
PATIENT.
Treats Takes
DOCTOR PATIENT
MEDICATION
Receives
.c
SUPPLIE
t
ve
has
t
sy
ea
ORDER
From the figure above, the conceptual data model is the entities that describe the data and the
relationships between those entities.
-Identify all the entities and relationships as captured in conceptual data model.
t.c
ve
404
v. Composite attribute: This is an attribute which can be divided into smaller subparts.
These subparts represent basic attributes with independent meanings of their own.
For example, take Name attributes. We can divide it into sub-parts like First name,
Middle name, and Last name.
vi. Simple attribute: This is an attribute that cannot be divided into subparts. It is
therefore said to be simple or atomic attribute. For example, Employee Number is a
simple attribute. Age of a person is a simple attribute.
vii. Single-valued attribute: It is an attribute that can have single value at a particular
instance of time. For instance, a person cannot have more than one age value.
viii. Multi-valued attribute: It is an attribute that can have more than one value at one
time. For instance, a person can have more than one degree at one time, therefore
attribute degree is said to be a multi-valued attribute.
ix. Stored attribute: An attribute that supplies a value to the related attribute.
x. Derived attribute: An attribute whose value is derived from a stored attribute. These
om
xi. Candidate Key: An attribute or set of attributes that uniquely identifies individual
occurrences of an entity type.
xii. Primary Key: A unique attribute that is used to identify an entity type e.g., entity type
student can be identified by student number.
xiii.Composite Key: A candidate key that consists of two or more attributes. e.g.,
VoterID+NationalID+PassportID
405
Normalization the process of removing redundant data from the tables to improve storage
efficiency, data integrity and scalability. Normalization works through series of steps called
normal forms.
Functional dependency
Implies that if A and B are attributes (columns)of a table, B is fully functionally dependent on
An if value of A determines the value of B. For example, voter ID, voter name.
Implies that if A and B are attributes of a table, B is partially dependent on A if there is some
attribute that can be removed from A and yet the dependency still holds. Consider a case of voter
om
ID, voter national ID, voter name, constituency all being attributes in a table. The voter ID value
t .c
ve
406
To reduce the need of restructuring the relations whenever new data types are
introduced(scalability)
To avoid repetitive entries (data redundancy).
Data anomalies
Relations that have redundant data may have problems called anomalies, which are classified as.
i. Insertion anomalies
ii. Deletion anomalies
iii. Update anomalies
a. Update anomaly
The same information appears on multiple rows; therefore, updates to the relation may result in
logical inconsistencies. If the update is not carried through successfully to all the rows, then the
relation is left in an inconsistent state. For example if sender No T3 was actually supposed to be
”Timothy Makua” then the user must update all the records where T3 appears so that the table is
om
consistent.
t.c
ve
Example
t
sy
ea
407
T1 Munyalo Mutua Magazine 11/10/2012 Kasyoka
Munyalo
b. Insertion anomaly
om
This anomaly causes an inability to add information to the database due to a lack of some related
t.c
ve
value. For example, to insert details of a new sender say ”Richard Muriuki” the user must enter
t
sy
ea
sender No value else the system will not allow those details into the system.
c. Delete anomaly.
This may occur when the deletion of data representing certain facts results into deletion of data
representing completely different data. For example if the user deletes third row containing
sender No, then details containing sender, description, date and recipient in that row will be lost
as well.
Normalization steps
Data is organized into database tables by using normal forms rules or conditions. These rules
help to make a good database design. Generally, we organize the data up to third normal form.
We rarely use the fourth and fifth normal forms.
408
Begin with a list of all the fields that must appear in the database. Think of this as one
big table.
Do not include computed fields.
You can get this information from a printed document used by the system e.g., reports.
Additional attributes besides those for the entities described on the document can be
added to the database.
It is a relation that is in first normal form and where every non-primary-key attribute is fully
functionally dependent on the primary key. No partial dependencies.
Steps:
Ensure that the table is in the first normal form.
Remove partial dependencies and put the partially dependent attributes in a separate
table.
409
Example:
Consider the report below about customer rental information. Normalize this report to third
normal form.
Report
A report
Page DreamHome
1 Date: 19-02-2013
Customer Rental Details
Property Property Rent start Rent finish Rent Owner Owner Name
Number Address Number
PG4 Box 123 NRB 1-02-2010 1-02-2012 120000 CO123 Mary mutia
Un-normalized table
om
t .c
ve
t
sy
ea
410
Customer- Customer- Property- Property- Rent- Rent- Rent Owner- Owner-
Customer-No Customer-
No Name No address start Finish No Name
Name
John PG4 BOX 123 1-02- 1-02- 120000 C0123 Mary
Cu034 Mwendwa
John Mwendwa NRB 2010 2012 Mutia
Cu034
Repeating groups are fields that may be repeated several times for one document/entity.
t .c
ve
The primary key of the new table (repeating group) is always a composite key; Usually
document number and a field uniquely describing the repeating line, like an item number.
In this case Customer Name is repeated. But in this case, there is no document number e.g.,
receipt number.
411
Customer- Property- Property- Rent- Rent- Rent Owner- Owner-
No No address start Finish No Name
om
t .c
ve
t
sy
ea
It’s carried out where the table has composite key. All partially dependent attributes are removed
and placed in a new table. A copy of the primary key is used to identify the attributes in this new
table. In this case there are three key attributes in the original table(Property-No,Customer-
No,Owner-No). OwnerName only depends on OwnerNo(Partial dependency). This attribute is
removed together with a copy of the key Owner-No.
412
om
t.c
ve
t
sy
ea
Create a separate table containing the attribute and the fields that are functionally dependent on
it. Keep a copy of the key attribute in the original table.
In this case rent (Amount) is transitively dependent on the rent start and rent finish.
Remove this attribute create a primary to identify its value e.g., payment No. The copy of this
key must remain in the original table.
Database Integrity.
The main types of integrity constraints that exist for a database include the following:
413
i. Domain integrity: This is restricting what users can enter the field. It is the validity of
entries for a given column. It can be enforced by restricting the type (through data types),
check constraints and rules can be used to validate the data that users try to enter against
a list of acceptable data and defaults can be used to enter data for the users if they forget.
ii. Entity integrity: This is the process of making sure that each record in a table is unique
in some way. Primary keys are used to enforce entity integrity (Gunderloy & L.Jorden,
2001).
iii. Referential integrity: This is the process of protecting related data that is stored in some
separate tables.
iv. User defined Integrity: User-defined integrity allows users to define specific business
rules. Example Age>=18.
v). Design the ERD (logical data model) and validate with the users.
In this step we use the normalized forms and standard notations to draw the ERD. Such notations
om
Relationship line
Relationship
Optional symbol
One(1) symbol 1
Many(M) symbol M
Composite entity
414
Weak entity
A logical data model describes the data in as much detail as possible, without regard to how they
will be physically implemented in the database. A logical data model is used to explore the
domain concepts, and their relationships, of the problem. This could be done for the scope of a
single project or for the entire enterprise. The logical data model depicts the logical entity types,
typically referred to simply as entity types, the data attributes describing those entities, and the
relationships between the entities.
415
database is organized as files and what kind of structures to use for efficiency of database
processing.
Steps:
• Select DBMS.
• Select storage devices.
• Determine access methods.
• Design files and indexes
• Determine database distribution.
• Produce the physical model and validate with the users
Underlying model
t .c
ve
Portability
t
sy
ea
Reliability: loss on power failure or system crash and physical failure of the storage device
t
ve
t
sy
ea
Media
Cache: Fastest and most costly form of storage; volatile; managed by the computer system
hardware.
Main memory: Fast access but generally too small (or too expensive) to store the entire
database.
Flash memory: Data survives power failure. Data can be written at a location only once, but
location can be erased and written to again. Reads are roughly as fast as main memory. But
writes are slow (few microseconds), erase is slower.
Magnetic disk: Data is stored on spinning disk and read/written magnetically. It is a primary
medium for the long-term storage of data; typically stores entire database. Data must be moved
from disk to main memory for access and written back for storage. It is possible to read data on
disk in any order, unlike magnetic tape. Survives power failures and system crashes. However,
disk failure can destroy data.
417
Optical storage: This is a non-volatile, data is read optically from a spinning disk using a laser.
Reads and writes are slower than with magnetic disk.
Tape storage: Is a non-volatile storage, used primarily for backup (to recover from disk failure),
and for archival data. Allows sequential-access and thus much slower than disk. Very high
capacity.
om
t.c
ve
t
sy
ea
In this step identify specific structures and access methods for the data to achieve optimum
performance for the database system. The access method depends on storage structure. Some of
the access methods are:
Sequential
Indexed sequential.
Hashing
418
Creating set of tables and constraints on these tables from the information given in logical data
model. The tables are designed, and their field properties specified.
SupplierID Number 8
SupplierName Text 50
Address Text 50
Street Text 50
OrderID Text 50
OrderName Text 50
Dateprepared Date/Time
SupplierID Number 8
ProductID Text 30
ProductName Text 60
419
Quantity Number 8
OrderID Text 50
There is need to consider location and number of users when deciding the database distribution.
For instance, the database may single user database in which case the database can be stored in a
local computer, multiuser database may store in a dedicated server where users can access
simultaneously. If the users are not within the same location and the organization has several
branches in different locations, then a distributed database may be used.
column constraints, primary key, foreign key, and relationships between tables.
t
vet
sy
420
Comparing the logical data model shown above with the logical data model diagram, we see the
main differences between the two:
i. Entity names are now table names.
ii. Attributes are now column names.
iii. Data type for each column is specified. Data types can be different depending on the
actual database being used.
Database Implementation
This is the physical realisation of the database and application designs. The detailed model is
converted to the appropriate implementation model, the data dictionary is built, the database is
populated, application programs are developed, and users are trained.
Database implementation activities
i. Hardware/Software Acquisition if needed.
ii. Coding
om
i. Hardware/Software Acquisition
iii. Testing
t
sy
ea
It is the process of evaluating a system or its component(s) with the intent to find that whether it
satisfies the specified requirements or not. Testing results in the actual expected and difference
between their results. It is used to identify any gaps, errors, or missing requirements in contrary
to the actual desire or requirements.
422
The process of transferring any existing data into new database and converting any existing
applications to run on the new system. This is only required if a new database will be replacing
an existing database. Modern database management systems (DBMS) have utilities for loading
existing files into new database. Such utilities require the specification of the source file and the
target database and then automatically converts the data to the required format of the new
database file
Database Operations
a) SELECT operation
The SELECT statement is probably the most used SQL command. The SELECT statement is
used for retrieving rows from the database and enables the selection of one or many rows or
om
example:
If you only want a few columns, you may specify the names of the columns you want to retrieve,
example:
b) INSERT operation
The INSERT INTO statement is used to insert a new row in a table. It is possible to write the
INSERT INTO statement in two forms.
om
The first form does not specify the column names where the data will be inserted, only their
t .c
ve
values:
t
sy
ea
The second form specifies both the column names and the values to be inserted:
Example:
424
INSERT INTO CUSTOMER (Customer Number, Last Name, FirstName, Area Code,
Address, Phone)
VALUES ('1000', 'Kaparo', 'John', 12, 'Nairobi', '11111111')
Note! You need at least to include all columns that cannot be NULL.
om
c) UPDATE operation
t.c
ve
t
sy
ea
The UPDATE statement is used to update existing records in a table. The syntax is as follows:
Note! Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which
record or records that should be updated. If you omit the WHERE clause, all records will be
updated!
Example:
d) DELETE operation.
425
The DELETE statement is used to delete rows in a table.
The Syntax is shown below:
Note! Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which
record or records that should be deleted. If you omit the WHERE clause, all records will be
deleted!
Example:
It is possible to delete all rows in a table without deleting the table. This means that the table
structure, attributes, and indexes will be intact:
Note! Make sure to do this only when you really mean it! You cannot UNDO this statement!
3.2.4.3 Learning Activities
The report below is how an inexperienced database developer might create a table.
Required: -
i. Normalize it upto 3rd Normal Form.
ii. Prepare an ERD to show the relationships
426
Figure 127: Sample report to be normalized
Email: [email protected]
5.2.3.4 Self-Assessment
i. Define the two principal integrity rules for the relational model. Discuss why it is desirable to
enforce these rules.
ii. Briefly describe the stages of the database system development lifecycle.
427
iii. Describe what relationships represent in an ER model and provide examples of unary, binary,
and ternary relationships.
iv. Describe what attributes represent in an ER model and provide examples of simple,
composite, single-value, multi-value, and derived attributes.
i. Define the two principal integrity rules for the relational model. Discuss why it is
desirable to enforce these rules.
Entity integrity In a base table, no column of a primary key can be null.
428
Referential integrity If a foreign key exists in a table, either the foreign key value must match a
candidate key value of some record in its home table or the foreign key value must be wholly
null.
ii. Briefly describe the stages of the database system development lifecycle.
Stages of the database system development lifecycle.
Database planning is the management activities that allow the stages of the database system
development lifecycle to be realized as efficiently and effectively as possible.
System definition involves identifying the scope and boundaries of the database system
including its major user views. A user view can represent a job role or business application area.
Requirements collection and analysis is the process of collecting and analysing information
about the company that is to be supported by the database system, and using this information to
om
There are three approaches to dealing with multiple user views, namely the centralized approach,
the view integration approach, and a combination of both. The centralized approach involves
collating the users’ requirements for different user views into a single list of requirements. A data
model representing all the user views is created during the database design stage. The view
integration approach involves leaving the users’ requirements for each user view as separate
lists of requirements. Data models representing each user view are created and then merged at a
later stage of database design.
Database design is the process of creating a design that will support the company’s mission
statement and mission objectives for the required database. This stage includes the logical and
physical design of the database.
The aim of DBMS selection is to select a system that meets the current and future requirements
of the company, balanced against costs that include the purchase of the DBMS product and any
additional software/hardware, and the costs associated with changeover and training.
429
Application design involves designing the user interface and the application programs that use
and process the database. This stage involves two main activities: transaction design and user
interface design.
Prototyping involves building a working model of the database system, which allows the
designers or users to visualize and evaluate the system.
Data conversion and loading involves transferring any existing data into the new database and
converting any existing applications to run on the new database.
Testing is the process of running the database system with the intent of finding errors.
om
t .c
ve
Operational maintenance is the process of monitoring and maintaining the system following
t
sy
ea
installation.
The entities involved in a particular relationship are referred to as participants. The number of
participants in a relationship is called the degree and indicates the number of entities involved in
a relationship. A relationship of degree one is called unary, which is commonly referred to as a
recursive relationship. A unary relationship describes a relationship where the same entity
participates more than once in different roles. An example of a unary relationship is Supervises,
430
which represents an association of staff with a supervisor where the supervisor is also a member
of staff. In other words, the Staff entity participates twice in the Supervises relationship; the first
participation as a supervisor, and the second participation as a member of staff who is supervised
(supervisee). See Figure 7.5 for a diagrammatic representation of the Supervises relationship.
om
t.c
ve
t
sy
ea
431
Attributes represent what we want to know about entities. For example, a Video entity may be
described by the catalog no title, category, daily Rental, and price attributes. These attributes
hold values that describe each video occurrence and represent the main source of data stored in
the database.
Simple attribute is an attribute composed of a single component. Simple attributes cannot be
further subdivided. Examples of simple attributes include the category and price attributes for a
video.
Composite attribute is an attribute composed of multiple components. Composite attributes can
be further divided to yield smaller components with an independent existence. For example, the
name attribute of the Member entity with the value ‘Don Nelson’ can be subdivided into Name
(‘Don’) and Name (‘Nelson’).
Single-valued attribute is an attribute that holds a single value for an entity occurrence. Most
attributes are single valued for a particular entity. For example, each occurrence of the Video
entity has a single-value for the catalog no attribute (for example, 207132), and therefore the
om
Multi-valued attribute is an attribute that holds multiple values for an entity occurrence. Some
t
sy
ea
attributes have multiple values for a particular entity. For example, each occurrence of the Video
entity may have multiple values for the category attribute (for example, ‘Children’ and
‘Comedy’), and therefore the category attribute in this case would be multi-valued. A multi-
valued attribute may have a set of values with specified lower and upper limits. For example, the
category attribute may have between one and three values.
5.2.3 Learning Outcome 3: Create and manipulate database objects
5.2.3.1 Introduction to the learning outcome
This section gives an overview of the various database objects including tables, queries, reports,
and forms. It also focuses on creation of tables, linking these tables and extracting data from
these tables using query objects. By the end of it, the learner should be able to competently
identify and come up with the above-mentioned objects.
432
5.2.3.2 Performance Standard
5.2.3.2.1 Database objects are identified.
5.2.3.2.2 Appropriate data Attributes are applied.
5.2.3.2.3 Data relationships are established as per the tables created.
5.2.3.2.4 Data is extracted from database using Access.
t
Reports allow you to print data based on queries/tables that you have created.
ve
t
sy
ea
433
Figure 128: Navigation pane in Ms Access
Sorting the Objects in the Navigation Pane:
om
By default, objects are sorted by type, with the tables in one group, the forms in another, etc.
t.c
ve
Click the drop-down arrow to the right of the All Access Objects and click on a sort option
from the list.
434
Figure 129: Choosing Access options
Creating a Database
1. Start Access
2. Click on Blank desktop database.
3. Under File Name type a name for the database
4. To change the location of where to store the database, click the folder icon and select a
location.
Click Create
om
t .c
ve
t
sy
ea
Understanding Views
There are multiple ways to view a database object. The two views for tables are Design View
and Datasheet View.
Design View is used to set the data types, insert, or delete fields, and set the Primary Key.
435
Datasheet View is used to enter and view the data for the records.
om
Creating a Table
t
sy
A table is a collection of data about a specific topic, such as employee information, products, or
ea
customers. The first step in creating a table is entering the fields and data types. This can be done
in either Datasheet View or Design View, but it is recommended to set up the table in Design
View.
Understanding Fields and Their Data Types
Field - an element of a table that contains a specific item of information, such as a last name.
Field’s Data Type - determines what kind of data the field can store.
Long Text Large amounts of alphanumeric data: sentences and paragraphs – 64,000
characters
436
Number Numeric data
Yes/No Yes and No values and fields that contain only one of two values
OLE Object Pictures, graphs, or other ActiveX objects from another Windows-based
application
Attachment You can attach files such as pictures, documents, spreadsheets, or charts; each
Attachment field can contain an unlimited number of attachments per record, up to
the storage limit of the size of a database file.
om
t.c
ve
Calculated You can create an expression that uses data from one or more fields. You can
t
sy
ea
Lookup Wizard Displays either a list of values that is retrieved from a table or query, or a set of
values that you specified when you created the field. The Lookup Wizard starts
and you can create a Lookup field. The data type of a Lookup field is either text or
number,
depending on the choices that you make in the wizard.
437
5. Type the field names and select the appropriate data type for each field
6. Continue until all fields are added
Note: The order that you enter the field names is the order the fields will appear in the table
Note: To turn off the Primary Key simply click on the Primary Key button again.
t .c
ve
t
sy
ea
Input Masks
An input mask is used to pre-format a field to “look/act” a certain way when a user inputs data.
Examples: Social Security Number input mask automatically inserts the dashes; phone numbers
automatically insert the parentheses and dashes.
The input mask data can either be stored in the table or simply displayed and not stored.
438
om
.c
5. Click Next
6. Click Next for additional screens on which you can set options for the input mask.
7. Click Finish on the last screen of the input mask wizard.
To Save the Table:
1. Click the Save icon on the toolbar
2. Enter a name for the table if you haven’t done so already
3. Click OK
Entering Data in a Table
1. In Datasheet View, start typing the data into the table by pressing the tab key to move to
the next cell
2. When you have completed the record (row), press Enter
3. You can also click on the New record icon on the Home tab in the Records group or at the
bottom of the table
439
Figure 133: entering new data into a table
1. Position your cursor in the field that you wish to sort by clicking on any record in the table
ea
2. Click either the Sort Ascending or Sort Descending icon on the Home tab in the Sort &
Filter group
440
Assume we have three tables. One table will hold customer information, the other will
hold product information, and the last will hold order information.
om
t.c
ve
t
sy
ea
441
Figure 139: field properties settings
Remember that the key icon indicates that the field is a primary key. A primary key ensures that
om
the data in this field is unique - no two values can be the same. A table must have a primary key
t .c
ve
before a relationship can be established with another table. Access automatically sets the ID field
t
sy
ea
as a primary key, so as long as you simply rename ID to ProductId (or OrderId as the case may
be) it will already be a primary key. If for some reason your table doesn't have a primary key set,
or if you want to change the primary key field, you can simply right click on the field header (in
Design view), and select Primary Key from the contextual menu.
Now that you've created two extra tables, our database has three tables. Now it's time to create
the relationship between all three tables.
442
Figure 140: relationships option in Ms Access
2. A Show Table dialog box will pop up, displaying all three tables. Select all of them and
click Add:
om
t.c
ve
443
5. The Edit Relationships dialog will pop up. Click Enforce Referential Integrity so that it is
checked. Check that the values are the same as the following screenshot and click OK:
You will now see a line established between the CustomerId field on the Customers table and
t
sy
6. Now do the same for the Products table. That is, click and drag the ProductId from
the Products table across to the corresponding ProductId field on the Orders table. Your table
relationships should look like the ones in the following screenshot:
444
We just established a many-to-many relationship. There are three types of relationships that you
can establish between tables. These are as follows:
Many-To-Many Relationship
This is what our example above uses. A row in table A can have many matching rows in table B,
and vice versa. In our case, a single customer can order many products, and a single product
could have many customers. You create a many-to-many relationship by using a third table,
called a junction table (more on that below).
One-To-Many Relationship
This is the most common relationship type. You don't need a third (junction) table for this type
of relationship. In this type of relationship, a row in table A can have many matching rows in
table B, but a row in table B can have only one matching row in table A. For example, a row in a
Gender table (which contains the records Male and Female) can have many matching rows in a
om
Customers table, but a row in the Customers table can only have one matching row in the Gender
t .c
ve
table. That is unless there was a business rule that allowed customers to be male and female at
t
sy
ea
the same time. In this case, a many-to-many relationship would need to be established.
One-To-One Relationship
A row in table A can have only one matching row in table B, and vice versa. This is not a
common relationship type, as the data in table B could just have easily been in table A. This
relationship type is generally only used for security purposes, or to divide a large table, and
perhaps a few other reasons.
The type of relationship that you use depends on the table structure and how the fields are
defined.
Junction Table
In the above relationship, the Orders table is known as a junction table. A junction table is one
that contains common fields from two or more other tables within the same database. It is used as
a reference table in a many-to-many relationship (such as we are doing in our example).
445
Junction tables are known under many different names. Here are some: cross-reference
table, bridge table, join table, map table, intersection table, linking table, many-to-many
resolver, link table, pairing table, pivot table, transition table, or association table.
So, if you ever hear someone mention one of those, you should have some idea what they are
referring to.
A foreign key is simply the primary key's corresponding field in the related table. So, in our
t.c
ve
example, the CustomerId field in the Orders table is a foreign key, while the CustomerId field in
t
sy
ea
the Customers table is a primary key. Likewise, the Productid field in the Orders table is a
foreign key, while the ProductId field in the Products table is a primary key. The fields do not
necessarily need to have the same names but it's a good practice to get used to. It will make the
database structure easier to understand - especially when you start adding more tables that also
need to have relationships established.
Queries
A query refers to the action of instructing the database to return some (or all) of the data in your
database. In other words, you are "querying" the database for some data that matches a given
criteria. The queries are run against one or more tables to return only the data that you're
interested in.
For example, you might like to see a list of all individuals whose last name is "Griffin". Or you
might like to see a list of all users who have registered with your database over a given time
period. You might also want to see which customers have ordered a particular product. To do all
this, you need to perform a query.
446
You use queries to view, change, and analyse data in different ways. You can also use them as a
source of records for forms and reports. Types of Query can be SELECT, INSERT, UPDATE,
DELETE.
To Create a Query:
1. Click on the Create tab
2. Click on Query Design in the Queries group
om
3. Select the table that you would like to base your query on
t .c
ve
4. Click Add
t
sy
ea
7. Double-click on the field names in the field list window which you would like to include in
the query
447
Figure 145: Sample relationship window
NOTE: Before we start querying the database, we should probably make sure we've got enough
data in there first. Otherwise, it doesn't matter how good our queries are - they will all return zero
results if there's zero data
Practical example:
om
t .c
ve
t
448
Figure 147: products table
Orders Table
Again, feel free to make up your own but you will need to make sure that the value in
the CustomerId and ProductId fields match an actual ID in the respective tables. For example, if
om
.c
your Orders table contains a CustomerId of 5, you will need to make sure there's an actual
t
ve
t
sy
customer in the Customer table with a CustomerId of 5. Here's some sample data for the Orders
ea
table:
449
Figure 148: Orders table
Create the Query
Now let's create a query that returns the names of all customers who have ordered a product.
1. Ensuring you have the CREATE tab open on the Ribbon, click Query Design
om
t.c
ve
t
sy
ea
450
follows:
om
.c
t
tve
sy
ea
451
5. You should now see the result of the query. Here's mine:
om
6. Save the query by right-clicking on the Query1 tab and giving it a name. Call it Customer
t
sy
ea
Orders:
452
This query will only return those customers who have ordered at least one product. If a customer
is in the Customers table but does not order a product, that customer's record will not be
displayed in the results of this query. If you look back at the Customers table (near the top of this
page), you'll see that Marge Simpson is a customer but she hasn't ordered any products yet (i.e.,
she doesn't have a corresponding record in the Orders table). Well actually, Marge is only
a potential customer. She simply expressed interest in buying a space ship.
453
To Save the Query:
1. Click the Save icon
2. Enter a name for the query
3. Click OK
Product Name
The marketing department wants to see who, if anyone, ordered their most expensive space ship.
om
So, let's return a list of all customers who purchased the most expensive space ship - the "Venus
.c
t
ve
Carrera ET".
t
sy
ea
1. From Design view, in the bottom pane, enter "Venus Carrera ET" (double quotes included)
into the Criteria field of the ProductName field:
454
Figure 157: Sample query output
3. Once you're satisfied with the results, return to Design view and remove your modification
(i.e. remove "Venus Carrera ET" from the Criteria field).
Price
You could also modify your query so that it returns customers who purchased a product worth
over a certain price.
So let's construct a query that returns all customers who purchased any product with a price over
80,000.
1. From Design view, in the bottom pane, add (>80000) into the Criteria field of the Price field:
2. Click the Run button in the Ribbon to view the results of the query. Alternatively, you can
t
ve
t
sy
just click the Datasheet View icon. And here are the results:
ea
455
1. From Design view, click the Totals button in the Ribbon:
456
You could sort by CustomerId instead
You could use >50000 And <80000 (or any other price range)
To switch to SQL view, you simply click the SQL icon at the bottom-right corner of Access:
SQL Statements
Once in SQL view, you will see a SQL statement. This SQL statement represents the query that
you constructed. Here's the SQL view of the last query that we performed:
457
A less complex SQL statement:
SELECT customers name, first name, customers last name
FROM Customers
The above SQL statement returns the FirstName and Last Name fields from the Customers table.
It returns all records because we didn't specify otherwise.
If we wanted to specify only some records, we would need to add some criteria to the statement.
Here's a modified statement:
SELECT Customers.FirstName, Customers.LastName
FROM Customers
WHERE Customers.LastName = 'Griffin'
Like the first example, the above SQL statement returns the FirstName and Last Name fields
from the Customers table. But in this example, we are only returning records where the
om
Creating a Form
A form is a database object that is used to enter or display data in a database.
To Create a Form:
1. Open the table or query on which you are basing the form
2. Click on the Create tab
3. Click on Form in the Forms group
A form is created and opens in Layout View.
458
Figure 164: form in a layout view
Different Views:
Form View – this view allows you to view, create and edit records.
Layout View - this view is like Design View but is more visually oriented in that each control
om
.c
displays real data. As a result, this is a very useful view for setting the size of controls or
t
tve
performing many other tasks that affect the visual appearance and usability of the form.
sy
ea
Design View - this view gives you a more detailed view of the structure of the form. You can see
the header, detail, and footer sections for the form. You cannot see the underlying data while you
are making design changes.
Reports
Reports can be based on tables or queries.
To Create a Report:
1. Open the table or query on which you are basing the report
2. Click on the Create tab
3. Click on Report in the Reports group
A report is created in Layout View.
459
Figure 165: report in Layout view
Different Views:
Print Preview – allows you see what the report would look like on a printed piece of paper.
Report View – allows you to see the data without having to display it in Print Preview.
om
Layout View – allows you make design changes while browsing your data.
t.c
Design View - gives you a more detailed view of the structure of your report
ve
t
sy
ea
Database Integration
The process of combining information from diverse sources, including databases, cloud, data
warehouse, virtual databases, files, and more, to distribute a clean and consolidated version
enterprise-wide is known as database integration. The main benefit of database integration
system is that it makes data accessible to multiple stakeholders and client applications without
the need to duplicate or move data.
One very common data management problem is integrating and synthesizing data from multiple
data sources. How many different sources of data do you have to work with? And how are all
these data sources related?
Most workplaces use multiple software solutions. The different software platforms may share
related data, but it’s almost impossible to pull the various data sets together for analysis. And
then, beyond the software solutions, there are all those spreadsheets with related data.
460
At some point it almost becomes overwhelming. You have all this data, out there but no way to
really bring it all together.
One of the best products, on the market, for data integration is Microsoft Access. Access has a
lot of advantages over other integration software products. Firstly, MS Access is part of the
Microsoft Office suite
Specific to integration, Access can link up to, and share information with:
1. Microsoft Excel
2. Microsoft Outlook
3. Microsoft SQL Server
4. Microsoft SharePoint Lists
In addition, MS Access can also linkup to data from the following data sources:
1. Other ODBC Databases, such as MySQL, etc…
2. Text Files
om
3. XML Files
t.c
ve
4. dBase Files
t
sy
ea
At first the idea of linking data from multiple data sources may be overwhelming. But it really
isn’t all that hard, once you figure out how to do it. Following are some basic guidelines when
using MS Access to integrate various data sources.
Primarily – with MS Access – there are a couple ways to work with external data. The first is
simply importing the external data. For instance, you can open up one of your proprietary
software applications and run an export file. Then you can import that file into MS Access. Since
Access can read and import common text or Excel files, importing data into Access from other
software packages is very doable. But there is another option as well.
With Microsoft Access, instead of importing data that has been exported from another software;
you can link the other data source directly to Access. This allows you to read “live” production
data.
If you open Microsoft Access and click on the External Data ribbon, you will see a group of
ribbon commands labelled, “Import & Link”. These are the commands you want to play with,
461
to fully grasp all the possibilities for integrating your various data sources. Each ribbon
command tool comes with wizards, to walk you through the various steps.
To begin with you may simply want to play with exporting &/or linking data from Excel. Access
and Excel work quite well together, as they are both part of the Microsoft Office Suite. The most
important thing to remember, before you start working to import/link a spreadsheet, is to prep the
spreadsheet. You will want to make sure there are column headings, and that the spreadsheet is
straight data (without sectioned data, etc…)
But, after you have prepped your spreadsheet, simply:
1. Open an Access database.
2. Click on the External Data ribbon
3. Click the Excel command tool on the Import & Link group
4. A wizard will pop up.
You will be able to use a navigator and select the spreadsheet you prepped.
You can choose to import data, append data to an existing table, or link data. --- Stay away
om
from appending data to an existing table, until you’ve played with the other options. Once
t .c
ve
you have played with importing and linking – you’ll feel more comfortable selecting the
t
sy
append option. (Do keep in mind, if you append to an existing table, you’ll want your
ea
spreadsheet data to be formatted so that it is compatible with the table you append to.)
Once you play with the differences between importing and linking data (with Excel) then
you’re in a better position to start working with some of the more sophisticated data sources.
To import/link data from a SQL database, you’ll need to learn how to work with ODBC data
sources. ODBC connectors simply define connection strings to the database you want to
read.
After setting up an ODBC data source for the SQL database you want to connect to, then the
wizards in Access can walk you through the various steps. Just make sure to save your
ODBC data source in a network folder that you can find, when going through the
import/linking process.
462
i. Create four tables namely Students (To capture students bio data), Finance (to
capture students payment details), Books issued (to maintain a record of books
borrowed by the students), Books inventory (to hold details of all the books available
in the library)
ii. Populate these tables with some dummy student data
iii. Create relationships between these tables
iv. Create a query to show student details and the books their individual fee balance
detail
v. Create a form to populate the students Table
vi. Create a report of all the books available in the library.
5.2.3.5 Self-Assessment
i. Differentiate between the functioning of Tables, queries, forms and reports
ii. Describe the following field datatypes
1) Currency
om
2) Autonumber
t.c
ve
3) OLE object
t
sy
ea
4) Attachment
iii. What are the two major components of SQL and what function do they serve?
iv. Explain the function of each of the clauses in the SELECT statement. What restrictions are
imposed on these clauses?
1) FROM
2) WHERE
3) GROUP BY
4) HAVING
5) ORDER BY
v. Describe the various types of relationships that may exist within entities in a database.
5.2.3.6 Tools, Equipment, Supplies and Materials
Computer
Database software (Ms Access)
463
Printer
stationery
5.2.3.7 References
Silberschatz A. and et al (2001), Database System Concepts, McGraw-Hill.
Garcia-Molina H. and et al (2000), Database System: The complete Book, Prentice Hall.
Elmasri R. and Navathe S(2000), Fundamentals of Database System, Addison Wesley.
Conolly& Begg (2010), Database System: a practical approach to design, implementation and
management, Prentice Hall.
Ullman, and Jennifer Widom (2009). Database Systems: The Complete Book (2nd edition) by
SBN 978-0131873254, Pearson Prentice Hall,
Jeffrey A. Hoffer, Mary B. Prescott, and Fred R. McFadden(2007). Modern Database
Management (8th Ed.). Prentice-Hall.
Roger Jennings(2004) Special Edition Using Microsoft Office Access 2003, Que.
Alan Simpson, Margaret Levine Young, and Alison Barrows (2003) Access 2003 for
om
464
Attachment- You can attach files such as pictures, documents, spreadsheets, or charts; each
Attachment field can contain an unlimited number of attachments per record, up to the storage
limit of the size of a database file.
iii. What are the two major components of SQL and what function do they serve?
A data definition language (DDL) for defining the database structure.
A data manipulation language (DML) for retrieving and updating data.
iv. Explain the function of each of the clauses in the SELECT statement. What
restrictions are imposed on these clauses?
FROM specifies the table or tables to be used;
WHERE filters the rows subject to some condition;
GROUP BY forms groups of rows with the same column value;
HAVING filters the groups subject to some condition;
SELECT specifies which columns are to appear in the output;
ORDER BY specifies the order of the output.
om
t .c
ve
v. cribe the various types of relationships that may exist within entities in a database
t
sy
ea
Relationship Types
We just established a many-to-many relationship. There are three types of relationships that you
can establish between tables. These are as follows:
Many-To-Many Relationship
This is what our example above uses. A row in table A can have many matching rows in table B,
and vice versa. In our case, a single customer can order many products, and a single product
could have many customers. You create a many-to-many relationship by using a third table,
called a junction table (more on that below).
One-To-Many Relationship
This is the most common relationship type. You don't need a third (junction) table for this type
of relationship. In this type of relationship, a row in table A can have many matching rows in
table B, but a row in table B can have only one matching row in table A. For example, a row in a
Gender table (which contains the records Male and Female) can have many matching rows in a
465
Customers table, but a row in the Customers table can only have one matching row in the Gender
table. That is unless there was a business rule that allowed customers to be male and female at
the same time. In this case, a many-to-many relationship would need to be established.
One-To-One Relationship
A row in table A can have only one matching row in table B, and vice versa. This is not a
common relationship type, as the data in table B could just have easily been in table A. This
relationship type is generally only used for security purposes, or to divide a large table, and
perhaps a few other reasons.
The type of relationship that you use depends on the table structure and how the fields are
defined.
om
t.c
ve
t
sy
ea
466
5.2.4 Learning Outcome 4: Perform database testing.
But to perform database testing, having sound knowledge of SQL is very important.
467
way of managing, retrieving and storing this data, there are cases where data might get
redundant, duplicated, etc. In such cases database testing comes into the picture which helps
us in validating the data. Below are various aspects based on which a database needs to be
validated:
1. Data Mapping
Data mapping is an integral aspect of database testing which focuses on validating the
data which traverses back and forth between the application and the backend database.
2. ACID Properties Validation
ACID stands for Atomicity, Consistency, Isolation, and Durability. This is another
important aspect that needs to be confirmed against each database transaction.
o Atomicity: This means that all Database Transactions are atomic i.e., the
transactions can result in either, Success or Failure. Also known as All-or-
Nothing.
o Consistency: This means that the database state will stay valid after the
om
.c
transaction is completed.
t
ve
t
o Isolation: This means that multiple transactions can be executed all at once
sy
ea
468
Types of Database Testing
There are 3 types of Database Testing as listed below:
1. Structural Testing
2. Functional Testing
3. Non-functional Testing
1. Structural Testing
The structural database testing is the process of validating all the elements that are present
inside the data repository and are primarily used for data storage. These elements cannot be
manipulated directly by the end-users. Validating database servers is one of the most
important considerations and the testers who manage to complete this phase successfully
acquire mastery in SQL queries.
Various Types of Structural testing are:
1) Schema Testing
om
This type of testing is also known as mapping testing and is performed to ensure that the schema
t.c
ve
mapping of the front end and the back end are in sync. Some of the important checkpoints of this
t
sy
ea
testing are:
o Validates various types of schema formats that are associated with the databases.
o Verification is required for unmapped tables/views/columns.
o Verification is also required to ensure the consistency of the heterogeneous databases
in an environment with the overall application mapping.
o Provides various tools for database schema validation.
469
o Validating the compatibility of the data type and field lengths at the backend database
columns with the front end of the application.
o Validates that the users are able to provide desired inputs using the database fields
which are specified in the business requirement specification documents.
o Ensure the creation of the Clustered indexes and Non-Clustered indexes in the
t .c
ve
470
o Ensure that the required triggers are implicitly invoked by executing the Stored
Procedures.
o Detect and validate any unused stored procedures.
o Validating the Null condition at the database level.
o Ensure that all the Stored Procedures and Functions have been executed and tested on
the blank database that is under test.
o Validate the overall integration of the stored procedure modules as specified in the
requirements of the application under testing.
5) Trigger Testing
Some of the important checkpoints of this testing are:
o Validating that the required coding conventions are followed in the coding phase of
the Triggers.
om
o Ensure that the executed triggers are fulfilling the required conditions for the
.c
t
ve
o Check whether the data is updated correctly once the triggers have been executed.
o Validate the functionalities such as Update, Insert, Delete triggers functionality of the
application under test.
2. Functional Testing
471
Functional database testing is the process that ensures that the transactions and operations
that are performed by the end-users are consistent with the meet the business specifications.
Various Types of Functional Testing are:
Black Box Testing
Black Box Testing refers to the process that checks various functionalities by verifying the
integration of the database. In this, the test cases are usually simple and are used to verify the
incoming and outgoing data from the function. Various techniques like cause-effect graphing
technique, boundary-value analysis, and equivalence partitioning are used to test the database
functionality. It is generally performed at the early development stages and costs less when
compared to other functional testings. But it comes with some drawbacks like some errors
cannot be detected by it and there is no specification on how much of the program should be
tested.
White Box Testing
White Box Testing is concerned with the internal structure of the database and the users are
om
unaware of the specification details. This testing requires database triggers and logical views
.c
t
ve
testing which supports the database refactoring. Moreover, database functions, triggers,
t
sy
ea
views, SQL queries, etc., are also tested in this. White box testing is used to validate the
database tables, data models, database schema, etc. It adheres to the rules of Referential
Integrity and selects the default table values to verify the database consistency. Techniques
like condition coverage, decision coverage, statement coverage, etc. are often used to
perform White Box testing. Unlike Black box testing coding errors can be easily detected to
eliminate the internal bugs present in the database. The only drawback of this type of testing
is it doesn’t cover the SQL statements.
3. Non-Functional Testing
Nonfunctional testing is the process of performing load testing, stress testing, checking
minimum system requirements which are required to meet the business specification along
with detecting risks and optimizing the performance of the database.
Major types of Non-Functional Testing are:
Load Testing
472
The primary function of performing load testing is to validate the performance impact of
most of the running transactions in the database. In this testing, a tester is required to check
the following conditions.
o What is the response time required for executing transactions for multiple users
located remotely?
o What is the time taken by the database for fetching the specific records?
Stress Testing
Stress testing is a testing process that is performed to identify the breakpoint of the system.
Thus, in this testing, an application is loaded until the point the system fails. This point is
known as a breakpoint of the database system. The commonly used Stress Testing Tools
are LoadRunner and WinRunner.
473
Figure 166: summary of database testing tools
om
.c
Database security testing is done to find the loopholes in security mechanisms and also about
sy
ea
DB Query Testing
474
Various SQL frameworks let you define layers of indirection between your SQL and its
input(s); i.e., you declare and label the input datasets upon which a query depends. Unit
testing frameworks can use this indirection to replace real input data with faked versions.
We can then run the code under test, using some faked input, and compare the output result
rows against a set of expected outputs. If the actual output of the code under test matches the
expected output, the test passes; if not, it fails.
This technique is simple and gives you real power to verify that a SQL script does what you
think it does. You can pass faked inputs to your SQL that your real data may not currently
contain, giving you confidence that it can robustly handle a wide range of data.
4. Randomize the data e.g., for a boolean field random insert and true or false.
t
sy
ea
5. Keep a count in the test of the variables (e.g. number of rows, number of trues)
6. For the Asserts execute query and compare against local test variables
7. Use Enterprises Services transactions to rollback database to previous state
There are a few tools out there to help you with this. DbUnit is one of them and I also believe
Microsoft had a tool Visual Studio for Database Professionals that contained some support
for DB testing.
475
Querying the recent data
Select top 1 * from table name order by date/time desc
Ex: Select top 1 * from employee order by joining date desc
Checking for the duplicate records
Select * from table name group by key column having count (*) > 1
Ex: Select * from employee group by empid having count (*) > 1
Find out the existence of objects.
Select * from sysobjects where type = “<type>“ (SQL Server)
where <type> can be
U ------- User table
V ------- View
P ------- Stored procedure
TR ------ Trigger
Select * from User Objects where Object name like ‘xxxxxx’ (Oracle)
om
t.c
ve
1. SQL Injection
This is most common type of attack in a database system where malicious SQL statements
are inserted in the database system and are executed to get critical information from the
database system. This attack takes advantage of loopholes in implementation of user
applications. To prevent this, user inputs fields should be carefully handled.
2. Privilege Elevation in Database
In this attack, a user already has some access in the database system and he/she only tries to
elevate this access higher level so that he/she can perform some unauthorized activities in
database system.
3. Denial of Service
In this type of attack, an attacker makes a database system or application resource
unavailable to its legitimate users. Applications can also be attacked in ways that render the
application, and sometimes the entire machine, unusable.
476
4. Unauthorized Access to data
Another type of attack is gaining unauthorized access to data within an application or
database system. Unauthorized access includes −
Unauthorized access to data via user-based applications
Unauthorized access to by monitoring the access of others.
Unauthorized access to reusable client authentication information
5. Identity Spoofing
In Identity Spoofing, a hacker uses the credentials of a user or device to launch attacks
against network hosts, steal data or bypass access controls to database system. Preventing
this attack requires IT-infrastructure and network-level mitigations.
6. Data Manipulation
In a data manipulation attack, a hacker changes data to gain some advantage or to damage the
image of database owners.
Database Security Testing Techniques
om
7. Penetration Testing
t.c
ve
A penetration test is an attack on a computer system with the intention of finding security
t
sy
ea
Risk Finding
Risk Finding is a process of assessing and deciding on the risk involved with the type of loss
and the possibility of vulnerability occurrence. This is determined within the organization by
various interviews, discussions and analysis.
1. SQL Injection Test
It involves checking the user inputs in application fields. For example, entering a special
character like ‘,’ or ‘;’ in any text box in a user application should not be allowed. When a
database error occurs, it means that the user input is inserted in some query, which is then
executed by the application. In such a case, the application is vulnerable to SQL injection.
These attacks are a big threat to data as the attackers can get access to important information
from the server database. To check SQL injection entry points into your web application, find
477
out code from your code base where direct MySQL queries are executed on the database by
accepting some user inputs.
SQL Injection Testing can be performed for Brackets, Commas, and Quotation marks.
2. Password Cracking
This is the most important check while performing database system testing. To access critical
information, hackers can use a password-cracking tool or can guess a common
username/password. These common passwords are easily available on internet and also
password cracking tools exist freely.
Therefore, it is necessary to check at the time of testing if the password policy is maintained
in the system. In case of any banking and finance applications, there is a need to set a strict
password policy on all the critical information database systems.
interval to determine whether necessary standards are followed or not. Various security
t.c
ve
standards can be followed as per business requirement to define the security policy and then
t
sy
ea
b. Paros
478
All HTTP and HTTPS data between server and client, including cookies and form fields, can
be intercepted and modified using these scanners. It is used for Cross-platform, Java
JRE/JDK 1.4.2 or above.
d. Skip fish
This tool is used to scan their sites for vulnerabilities. Reports generated by the tool are
meant to serve as a foundation for professional web application security assessments. It is
preferred for Linux, FreeBSD, MacOS X, and Windows.om
e. Vega
t.c
ve
It is an open source, multiplatform web security tool that is used to find instances of SQL
t
sy
ea
f. Wapiti
Wapiti is an open source and web-based tool that scans the web pages of the web application
and check for scripts and forms where it can inject data. It is built with Python and can detect
File handling errors, Database, XSS, LDAP and CRLF injections, Command execution
detection.
g. Web Scarab
It is written in Java and is used for analysing the applications that communicate through
HTTP/HTTPS protocols. This tool is primarily designed for developers who can write code
themselves. This tool is not OS dependent.
479
Database recovery testing is used to ensure that the database is recovered. Recovery testing
allows you to find out whether the application is running properly and to check retrieving
invaluable data that would have been lost if your recovery method is not properly setup.
You also check if several critical processes are running smooth to ensure that the data
recovery will pass smoothly through the testing phase.
You can perform the following checks for database recovery −
Any errors or mistakes in the backup software and you need to resolve these issues at an
earlier stage.
You need to conduct the recovery testing so that you will know what to do in case of an
emergency.
You need to check recovery testing needs so that you can plan for an effective recovery
strategy.
You should also know how you can recover the documents.
You need to run the recovery tests in early phase of the project. This allows you to remove
om
and throw away every type of errors from the system. Here is a list of some of important
.c
t
ve
ea
480
5.2.4.4 Learning Activities
a) Database testing involves among other items, checking on the security of a database.
Describe any four internal features provided by a database for ensuring security.
b) Given the primary objectives of performing database security testing below, describe how
measures can be used to enforce each of them.
i. Authentication
ii. Authorization
iii. Confidentiality
iv. Availability
v. Integrity
5.2.4.5 Self-Assessment om
481
5.2.4.6 Tools, Equipment, Supplies and Materials
Computer
Database software (Ms Access)
Printer
stationery
internet connectivity (to access open-source testing tools)
5.2.4.7 References
Ullman, and Jennifer Widom (2009). Database Systems: The Complete Book (2nd edition) by
t.c
ve
Jeffrey A. Hoffer, Mary B. Prescott, and Fred R. McFadden (2007). Modern Database
Management (8th Ed.). Prentice-Hall.
Roger Jennings (2004) Special Edition Using Microsoft Office Access 2003, Que.
Alan Simpson, Margaret Levine Young, and Alison Barrows (2003) Access 2003 for
DUMMIES, Wiley Publishing.
482
5.2.4.8 Model answers to self-assessment
The ideal situation for system testing is to have a test database on a separate hardware system,
t .c
ve
but often this is not available. If real data is to be used, it is essential to have backups taken in
t
sy
ea
case of error.
Testing should also cover usability of the database system. Ideally, an evaluation should be
conducted against a usability specification. Examples of criteria that can be used to conduct the
evaluation include (Sommerville, 2000):
Learnability - How long does it take a new user to become productive with the system?
Performance - How well does the system response match the user’s work practice?
Robustness - How tolerant is the system of user error?
Recoverability - How good is the system at recovering from user errors?
Adaptability - How closely is the system tied to a single model of work?
Some of these criteria may be evaluated in other stages of the lifecycle. After testing is complete,
the database system is ready to be ‘signed off’ and handed over to the users.
483
3. Backup and Recovery.
4. Integrity.
5. Encryption.
6. Raid.
Authorization
Authorization is the granting of a right or privilege that enables a subject to have legitimate
access to a system or a system’s object. Authorization controls can be built into the software and
govern not only what database system or object a specified user can access, but also what the
user may do with it. The process of authorization involves authentication of a subject requesting
access to an object, where ‘subject’ represents a user or program and ‘object’ represents a
database table, view, procedure, trigger, or any other object that can be created within the
database system. om
Views
.c
t
ve
A view is a virtual table that does not necessarily exist in the database but can be produced upon
t
sy
ea
request by a particular user, at the time of request. The view mechanism provides a powerful and
flexible security mechanism by hiding parts of the database from certain users. The user is not
aware of the existence of any columns or rows that are missing from the view. A view can be
defined over several tables with a user being granted the appropriate privilege to use it, but not to
use the base tables. In this way, using a view is more restrictive than simply having certain
privileges granted to a user on the base table(s).
484
restore the database to the latest possible consistent state. Journaling is the process of keeping
and maintaining a log file (or journal) of all changes made to the database to enable recovery to
be undertaken effectively in the event of a failure.
Integrity constraints
Contribute to maintaining a secure database system by preventing data from becoming invalid,
and hence giving misleading or incorrect results.
Encryption
Is the encoding of the data by a special algorithm that renders the data unreadable by any
program without the decryption key. If a database system holds particularly sensitive data, it may
be deemed necessary to encode it as a precaution against possible external threats or attempts to
access it. Some DBMSs provide an encryption facility for this purpose. The DBMS can access
the data (after decoding it), although there is degradation in performance because of the time
om
taken to decode it. Encryption also protects data transmitted over communication lines. There are
t .c
ve
a number of techniques for encoding data to conceal the information; some are termed
t
sy
ea
irreversible and others reversible. Irreversible techniques, as the name implies, do not permit the
original data to be known. However, the data can be used to obtain valid statistical information.
Reversible techniques are more commonly used. To transmit data securely over insecure
networks requires the use of a cryptosystem, which includes:
• an encryption key to encrypt the data (plaintext);
• an encryption algorithm that, with the encryption key, transforms the plain text into
ciphertext;
• a decryption key to decrypt the ciphertext;
• a decryption algorithm that, with the decryption key, transforms the ciphertext back into
plain text.
Redundant Array of Independent Disks (RAID)
RAID works by having a large disk array comprising an arrangement of several independent
disks that are organized to improve reliability and at the same time increase performance. The
hardware that the DBMS is running on must be fault-tolerant, meaning that the DBMS should
continue to operate even if one of the hardware components fails. This suggests having
485
redundant components that can be seamlessly integrated into the working system whenever there
is one or more component failures. The main hardware components that should be fault-tolerant
include disk drives, disk controllers, CPU, power supplies, and cooling fans. Disk drives are the
most vulnerable components with the shortest times between failures of any of the hardware
components.
One solution is the use of Redundant Array of Independent Disks (RAID) technology. RAID
works by having a large disk array comprising an arrangement of several independent disks that
are organized to improve reliability and at the same time increase performance.
In addition to the above two methods of securing a Microsoft Access database, other security
t.c
ve
features include:
t
sy
ea
486
5.2.5. Learning Outcome 5: Print Database objects
5.2.5.1 Introduction to the learning outcome
This section gives an overview of the procedure of printing the various database objects
including tables, queries, reports, and forms. By the end of it, the learner should be able to
competently print database objects.
5.2.5.2 Performance Standard
5.2.5.2.1 Database tables are printed.
5.2.5.2.2 Database queries are printed.
5.2.5.2.3 Database forms and reports are printed.
While you can print data from a table, query, form or report in your Microsoft Access
database, you can set print options for reports that will produce an eye-catching and more
readable printed copy of your data.
Printing data directly from tables or queries works when you want to print just a simple list.
Forms are better suited for viewing or printing data for a single record or a related set of
records, and not for printing larger sets of data or data summaries. By printing data from a
report, you can compare, summarize, and total large sets of data, and then present that
information in an attractive layout.
487
2. On the Print Preview tab, in the Page Layout group, click Page Setup and set the
margins, orientation and column settings that you want.
om
t .c
ve
t
sy
488
Figure 168:Print data settings option
To customize the margins on your report, on the Print Preview tab, in the Page Size group,
click Margins and select a suitable option and a preview of the report with the changed
om
489
om
.c
t
tve
sy
ea
490
These options are also available on the Print Preview tab, in the Page Layout group, under
Columns.
om
t.c
ve
t
sy
ea
491
Figure 170: column data settings options
Select printer settings
After you complete the page setup settings for your report, you can select specific printer
options to control the print layout or the pages you want printed and the number of copies.
1. In the Navigation Pane, right-click the report that you want to print, and click Print
Preview.
2. On the Print Preview tab, in the Print group, click Print.
(Keyboard shortcut, Press Ctrl+P).
3. Select your print options, and then click OK to print your report.
om
t .c
ve
t
sy
ea
The following table describes the results you can expect from specific printer settings:
492
Figure 171 : print data settings options
om
.c
To save paper, or to send a print job to a commercial printer, or send the report via e-mail,
t
tve
sy
you can create a .pdf or xps format of your report: On the Print Preview tab, in
ea
Exporting to PDF is like printing your document, except that instead of a paper copy, you're
getting a digital copy. XPS is a format similar to PDF, but created by Microsoft.
Select a report, then click the PDF or XPS button to get started. You will be asked to select a
file location for the PDF.
493
om
t .c
ve
t
sy
ea
When you click OK, Access asks you if you'd like to save the export to the Saved Export
Manager.
More Options
By clicking the More button in the Export group on the ribbon, you access options to save the
report as a Microsoft Word file, an HTML file, and others. Since the process to export to
each of these files is nearly identical, we won't repeat it here.
494
om
.c
t
tve
sy
ea
Saved Exports
If you use the same export settings frequently, you may want to save those settings. The
Saved Exports button is basically the saved export manager. As we discussed the export
options, we saved some of the export settings. Right now, we're going to examine the Saved
Export window.
495
om
t.c
ve
t
sy
ea
Here we have the saved settings. One export is called "Export-Books". It has a short
description--"Export data to Excel file" - and a location. We can edit any of this information
by clicking on it and typing in something new.
To run a saved report, select it from the list and click Run.
To delete a report, select it and click Delete.
496
To preview a report that is not already open, in the Navigation Pane, right-click the report
that you want to preview, and then click Print Preview.
or
Click File > Print, and then click Print Preview.
or
If the report is open, right-click the document tab for the report, and then click Print
Preview.
You can make further formatting changes from Print Preview by using the options in
the Preview Print tab.
om
t.c
ve
If you want to see several pages of the report, move to other pages, or view multiple pages at
the same time when previewing you report, try any the following options:
Click the Shutter Bar Open/Close button (<<) in the upper-right corner of the
Navigation Pane, and then expand the report view area.
Position the report by using the horizontal or vertical scroll bars.
To magnify an area on the report, on the Print Preview tab, in the Zoom group, click the
arrow below Zoom and select a magnification percentage. You can also use the Zoom
control in the lower right-hand corner of your window.
To preview multiple pages at a time, in the Zoom group, click Two Pages or click More
Pages and then select an option.
Select your print options: In the Print group, click Print and then select your print
options.
Close Print Preview: In the Close Preview group, click Close Print Preview.
497
Microsoft Access can also help you prepare printed documentation of your database's design,
which you can use for offline reference and planning. Specifically, Access can help you print
table relationships as depicted in the Relationship window, and can help you print the design
characteristics of database objects, such as object properties.
Prepare the Relationships window for printing
The Relationship window is a window in which you view, create, and edit relationships
between tables and queries. Depending on how you configure it, the Relationships window
does not always show all the relationships in your database. You should decide which
relationships you want to document — and prepare the Relationships window accordingly —
before you print table relationships. You can show or hide tables in the Relationships
window, and you can rearrange their layout.
Show or hide a table in the Relationships window
1. On the Database Tools tab click Relationships.
om
To show a table, on the Design tab, in the Relationships group, click Show
t
sy
ea
Table, and then in the Show Table dialog box, add the table that you want.
To hide a table, in the Relationship window, click the table that you want to hide,
and then press DELETE.
3. Press CTRL+S to save your changes.
498
5. On the Print Preview tab, in the Print group, click Print.
Print the design characteristics of database objects
You can use the Database Documenter to print the design characteristics of database objects.
1. Open the database that you want to document.
2. On the Database Tools tab, in the Analyze group, click Database Documenter.
3. In the Documenter dialog box, click the tab that represents the type of database object
that you want to document. To create a report on all of the objects in a database, click
the All Object Types tab.
4. Select one or more of the objects listed on the tab. To select all of the objects on a tab,
click Select All.
5. Click OK.
(The Database Documenter creates a report that contains detailed data for each selected
om
object, and then opens the report in Print Preview. For example, if you run the Database
t.c
ve
Documenter against a data entry form, the report created by the Documenter lists the
t
sy
ea
properties for the form as a whole, the properties for each of the sections in the form, and the
properties for any buttons, labels, text boxes, and other controls on the form, plus any code
modules and user permissions that are associated with the form.)
6. To print the report, on the Print Preview tab, in the Print group, click Print.
Preview a report.
When you want to see how your report will appear when printed, use Print Preview. If you
preview a report that was created in Access, the record navigation buttons appear in the
default location, at the bottom of the Access window.
Start Print Preview
1. If the report is not open, in the Navigation Pane, right-click the report that you want to
preview, and then click Print Preview on the shortcut menu.
-or-
If the report is open, right-click the document tab for the report and click Print Preview.
499
2. Click the record navigation buttons to move among the pages in the report.
If the report is open, right-click the document tab for the report and click Print Preview.
1. On the Print Preview tab, in the Zoom group, click Two Pages to preview your report
two pages at a time.
-or-
In the Zoom group, click More Pages, and then select an option.
2. Click the record navigation buttons to move among the pages in the report.
3. To revert to previewing a single page, in the Zoom group, click One Page.
You can either print the report after previewing it or close the preview if you want to make
t .c
ve
ea
On the Print Preview tab, in the Close Preview group, click Close Preview.
If you want to print all the pages in the report without making any changes to the format of
the report such as margins, headers, footers, and orientation (portrait or landscape) you can
use the Quick Print option.
1. If the report is not open, in the Navigation Pane, right-click the report and click Print.
-or-
Make sure that the Quick Print button is available in the Quick Access Toolbar. To add the
button to the toolbar, click the down-arrow at the end of the toolbar and click Quick Print.
On the Quick Access Toolbar, click Quick Print.
500
In a report, you can limit what you print only by selecting a range of pages.
1. Click File and then click Print.
2. On the Print area of the File options, click the Print option to open the Print dialog box.
3. To print only some of the data in the report, under Print Range, click Pages, and then
enter a value in the From and the To boxes.
For example, to print just page 5 of a report, type 5 in both the From and the To boxes.
If you own the necessary permissions to change the design of a report, you can make
additional changes to the way that your report prints by changing the print layout in the Page
Setup dialog box (click Setup to display the Page Setup dialog box).
two ways to display the Page Setup dialog box. You can start it from within the Print dialog
t .c
ve
box, or you can start it from the Print Preview tab, which appears when you start Print
t
sy
ea
Preview.
The steps in this section explain how to display the Page Setup dialog box.
Start the Page Setup dialog box from the Print dialog box
1. In the Navigation Pane, select the report that you want to change. You do not need to
open the report, although you can if you need to ensure that the data you are about to
print is current.
2. Click File and then click Print.
3. On the Print area of the File options, click the Print option to open the Print dialog box.
4. Click Setup to display the Page Setup dialog box.
5. Set or change the options in the dialog box, as needed.
Start the Page Setup dialog box from the Print Preview tab
2. In the Navigation Pane, right-click the report that you want to change and click Print
Preview.
501
Access opens the report in Print Preview.
3. On the Print Preview tab, in the Page Layout group, click the Page Setup button.
4. Set or change the options in the dialog box, as needed.
5. Select print options
Follow the steps in this section when you need to print some of the pages in a report or when
you need to select a printer or change print settings, such as margins or columns.
4. In the Navigation Pane, select the report that you want to print.
5. Click File and then click Print.
6. On the Print area of the File options, click the Print option to open the Print dialog box.
7. Change the page format setup or other print options or printer selection as needed, and
then click OK to print your report.
them as PDF.
t
tve
a. Table relationship
sy
ea
b. Form
c. Reports
d. Queries
5.2.5.5 Self-Assessment
ii. Describe the procedure of printing a report in Ms Access.
iii. Describe the procedure of Printing Table Relationships window
502
5.2.5.7 References
Silberschatz A. and et al (2001), Database System Concepts, McGraw-Hill.
Garcia-Molina H. and et al (2000), Database System: The complete Book, Prentice Hall.
Elmasri R. and Navathe S(2000), Fundamentals of Database System, Addison Wesley.
Conolly& Begg (2010), Database System: a practical approach to design, implementation
and management, Prentice Hall.
Ullman, and Jennifer Widom (2009). Database Systems: The Complete Book (2nd edition) by
SBN 978-0131873254, Pearson Prentice Hall,
Jeffrey A. Hoffer, Mary B. Prescott, and Fred R. McFadden(2007). Modern Database
Management (8th Ed.). Prentice-Hall.
Roger Jennings (2004) Special Edition Using Microsoft Office Access 2003, Que.
Alan Simpson, Margaret Levine Young, and Alison Barrows (2003) Access 2003 for
DUMMIES, Wiley Publishing. om
In a report, you can limit what you print only by selecting a range of pages.
1. Click File and then click Print.
2. On the Print area of the File options, click the Print option to open the Print dialog box.
3. To print only some of the data in the report, under Print Range, click Pages, and then
enter a value in the From and the To boxes.
For example, to print just page 5 of a report, type 5 in both the From and the To boxes.
If you own the necessary permissions to change the design of a report, you can make additional
changes to the way that your report prints by changing the print layout in the Page Setup dialog
box (click Setup to display the Page Setup dialog box).
503
2. On the Database Tools tab click Relationships.
3. On the Design tab, in the Tools group, click Relationship Report.
(A report that depicts the Relationships window opens in Print Preview mode.)
4. To make any adjustments to the way your report will print, use commands on the Print
Preview tab.
5. On the Print Preview tab, in the Print group, click Print.
Print the design characteristics of database objects
om
t .c
ve
t
sy
ea
504