Professional Documents
Culture Documents
Chap 13 (DBMS)
Chap 13 (DBMS)
What is Database?
Database also called electronic database, any collection of data or information, that is specially
organized for rapid search and retrieval by a computer. Databases are structured to facilitate the
storage, retrieval, modification, and deletion of data in conjunction with various data-
processing operations. A database is a collection of related files within an organization. An
organization has more than one database consisting of related files.
Character:
The basic building block of data is a character. A character sometimes called byte consist of letters
(A a, B b, C c..., Z z) numeric digits (0, 1, 2 … 9) or symbols (!, @, #, $, %, &, *).
Entity:
An entity can be a real-world object, either animate or inanimate, that can be easily identifiable.
For example, in a school database, students, teachers, classes, and courses offered can be
considered as entities. All these entities have some attributes or properties that give them their
identity.
An entity set is a collection of similar types of entities. An entity set may contain entities with
attribute sharing similar values. For example, a Students set may contain all the students of a
school; likewise a Teachers set may contain all the teachers of a school from all faculties. Entity
sets need not be disjoint.
Figure : 1 Figure : 2
In Fig 1 Employees, Customers, Orders are Entities.
Fields OR Attributes:
Entities are represented by means of their properties, called attributes. All attributes have values.
For example, a student entity may have name, class, and age as attributes.
There exists a domain or range of values that can be assigned to attributes. For example, a
student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be
negative, etc. Each attribute or field have data type which is represent the type of data item. Most
common data field are text field, numeric field, currency field, logical field, date field and memo
field.
Key Fields:
A key is a data item that allows us to uniquely identify individual occurrences or an entity type.
You can sort and quickly retrieve information from a database by choosing one or more fields (i.e.
attributes) to act as keys. For instance, in a student's table you could use a combination of the last
name and first name fields (or perhaps last name, first name and birth dates to ensure you identify
each student uniquely) as a key field.
Several important keys are given below:
1. Primary Key
2. Secondary Key
3. Foreign Key
4. Simple Key
5. Compound Key
6. Composite Key (Highlighted keys are included in your XII course).
Primary Key:
A primary key consists of one or more attributes that distinguishes a specific record from any other.
For each record in the table the primary key acts like a driver's license number or a national
insurance number, only one number exists for each person.
For example, your student number is a primary key as this uniquely identifies you within the
college student records system. An employee number uniquely identifies a member of staff within
a company. An IP address uniquely addresses a PC on the internet.
A primary key is mandatory. That is, each entity occurrence must have a value for its primary key.
Secondary Key:
An entity may have one or more choices for the primary key. Collectively these are known as
candidate keys. One is selected as the primary key. Those not selected are known as secondary
keys. For example, an employee has an employee number, a National Insurance (NI) number and
an email address. If the employee number is chosen as the primary key then the NI number and
email address are secondary keys. However, it is important to note that if any employee does not
have a NI number or email address (i.e. : the attribute is not mandatory) then it cannot be chosen
as a primary key.
Foreign Key:
A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another
table or the same table. In simpler words, the foreign key is defined in a second table, but it refers
to the primary key or a unique key in the first table. For example, a table called Employee has a
primary key called employee_id. Another table called Employee Details has a foreign key which
references employee_id in order to uniquely identify the relationship between both tables.
Record:
A record is a collection of related fields (Sometimes called a row). Data is stored in records. A
record is composed of fields and contains all the data about one particular person, company, or
item in a database. In this database, a record contains the data for one customer. Records appear
as rows in the database table. A record for Log ID 1201242 is highlighted in Figure.
File:
A file is a collection of related records. The term may refer to a computer file that contains any
type of data, including a word processing document or spreadsheet. It may also refer to a database
file that contains records, such as orders and customers.
6) Program Independence:
With a DBMS, the program and file formats are same, so that one programmer or even several
programmers can spend less time to maintain files.
2) Security Issues:
Database can be structured to restrict access, it’s always possible that unauthorized user will get
past the safeguards. In addition, if a database is destroyed by fire and any natural disaster, theft
and hardware/software problem.
3) Privacy Issues:
Database have all important and most private record of each employee or person, person can’t
share the data with any other like Medical report and other type of personal information which
is used for employee evaluation.
2) Speed:
A DBMS must run fast enough to provide replies to user’s questions within an applicable time
frame. Many systems are now very interactive (like user ask query or question, DBMS response
immediate) so the speed is primary or basic objective.
3) Compatibility:
A DBMS must interface easily with existing hardware, software and data if it is to be installed
successfully. In addition, DBMS should support the hardware and software of the system and
user friendly too.
5) Accessibility:
The purpose of DBMS is that easy to learn query language that allows the user to ask a wide
verity of questions about the data without having to prepare specially designed application
programs. For example (select * from employees) so DBMS show all records of employees
table etc.
6) Data Integrity:
Data integrity means the security, maintenance and consistency of data. The database is a place
where all information is store. Data integrity is one most important objective of DBMS, because
that tells how well it secure data integrity.
1) Query Language:
Structured query languages support database searching and other operations by using
commands such as “find,” “delete,” “print,” “sum,” and so forth. The sentence like structure of
a query resembles natural language except that its syntax is limited and fixed. Almost all DBMS
have same query language. DDL (Data definition language) have facilities for describing the
structure of fields, records, file and program accessing rights. Whereas DML (Data
manipulating language) is used for accessing and update records and files contained within
database, DBMS contain both DDL and DML features.
For Example: select std_ID from Student where Fees < 1000
2) Data Dictionary:
All DBMS include a data dictionary. Which is a software component that store the data
definition of the structure of data used in the database. A data dictionary also maintains data
integrity because as data is entered, the dictionary checks it to make sure that it confirms to the
rules define during data definition such as field name, field size, type of data (text, numeric,
date etc).
3) Utilities:
The DBMS utilities are program that enables users to maintain the database. This includes such
task as:
a) Creating and maintaining the data dictionary.
b) Removing records flagged for deletion. DBMS must have built-in protection to prevent user
from accidently/ by mistake deleting records. To delete unwanted records from the database.
c) Monitoring performance.
d) Preventing data corruption when multiple user attempt to access the dame database
simultaneously.
4) Report Generator:
The report generator aspect of DBMS software simplifies the process of generating an on
screen or print out report. Its only readable report on short notice. In report specify the format
of the report in advance row headings, column heading, page header etc.
5) Access Security:
Access security is a feature of DBMS that allow database administrators (DBA) to specify
different access privilege for different users of DBMS. For instance, some user might be
allowed only to retrieve (view) data, whereas another might have the right to update and
delete records.
6) System Recovery:
Some advance DBMS have a system recovery feature, which enable the DBA (Data base
administrator) to recover content of the database in the event of a hardware or software
failure.
One-to-one relationship:
For each record in one table, there is one and only one matching record in a different table. It is
as if two tables have the exact same primary key. Typically, data from different tables in a one-
to-one relationship will be combined into one table.
One-to-many relationship:
For each record in one table, there may be zero, one or many records matching in a separate
table. For example, you might have an invoice header table related to an invoice detail table. The
invoice header table has a primary key, Invoice Number. The invoice detail table will use the
Invoice Number for every record representing a detail of that particular invoice. This is certainly
the most common type of relationship you will encounter.
Many-to-many relationship:
Used decidedly less often, this relationship cannot be defined in Access without the use of a
mapping table. This relationship states that records in both tables can have any number of
matching records in the other table.
Referential integrity is a relational database concept, which states that table relationships must
always be consistent. In other words, any foreign key field must agree with the primary key that
is referenced by the foreign key.
A feature provided by relational database management systems (RDBMS's) that prevents users
or applications from entering inconsistent data. Most RDBMS's have various referential integrity
rules that you can apply when you create a relationship between two tables.
For example, suppose Table B has a foreign key that points to a field in Table A. Referential
integrity would prevent you from adding a record to Table B that cannot be linked to Table A. In
addition, the referential integrity rules might also specify that whenever you delete a record from
Table A, any records in Table B that are linked to the deleted record will also be deleted. This is
called cascading delete. Finally, the referential integrity rules could specify that whenever you
modify the value of a linked field in Table A, all records in Table B that are linked to it will also
be modified accordingly. This is called cascading update.
Objects of Database:
MS Access uses “objects" to help the user list and organize information, as well as prepare
specially designed reports. When you create a database, Access offers you Tables, Queries, Forms,
Reports, Macros, and Modules. Databases in Access are composed of many objects but the
following are the major objects.
1. Tables
2. Queries
3. Forms
4. Reports
Together, these objects allow you to enter, store, analyze, and compile your data. Here is a
summary of the major objects in an Access database
Table
Table is an object that is used to define and store data. When you create a new table, Access asks
you to define fields which is also known as column headings.
Tables contain fields or columns that store different kinds of data, such as a name or an
address, and records or rows that collect all the information about a particular instance of
the subject, such as all the information about a customer or employee etc.
You can define a primary key, one or more fields that have a unique value for each record,
and one or more indexes on each table to help retrieve your data more quickly.
Query
An object that provides a custom view of data from one or more tables. Queries are a way of
searching for and compiling data from one or more tables.
When you build a query in Access, you are defining specific search conditions to find
exactly the data you want.
In Access, you can use the graphical query by example facility or you can write Structured
Query Language (SQL) statements to create your queries.
You can also define queries that create new tables from data in one or more existing tables.
Form
Form is an object in a desktop database designed primarily for data input or display or for control
of application execution. You use forms to customize the presentation of data that your application
extracts from queries or tables.
The reason forms are used so often is that they are an easy way to guide people toward
entering data correctly.
When you enter information into a form in Access, the data goes exactly where the database
designer wants it to go in one or more related tables.
Report
Report is an object in desktop databases designed for formatting, calculating, printing, and
summarizing selected data.
You can view a report on your screen before you print it.
If forms are for input purposes, then reports are for output.
Anything you plan to print deserves a report, whether it is a list of names and addresses, a
financial summary for a period, or a set of mailing labels.
Reports are useful because they allow you to present components of your database in an
easy-to-read format.
Access offers you the ability to create a report from any table or query.
Macro
This object is a structured definition of one or more actions that you want Access to perform in
response to a defined event. An Access Macro is a script for doing some job. For example, to create
a button which opens a report, you could use a macro which will fire OpenReport action.
You can include simple conditions in macros to specify when one or more actions in the
macro should be performed or skipped.
You can use macros to open and execute queries, to open tables, or to print or view reports.
You can also run other macros or Visual Basic procedures from within a macro.
Data macros can be attached directly to table events such as inserting new records,
editing existing records, or deleting records.
Data macros in web apps can also be stand-alone objects that can be called from
other data macros or macro objects.
odule
Module is an object in desktop databases containing custom procedures that you code
using Visual Basic. Modules provide a more discrete flow of actions and allow you to
trap errors.
Everything that can be done in a macro can also be done in a module, but you don't
get the macro interface that prompts you what is needed for each action.
Modules are far more powerful, and are essential if you plan to write code for a
multi-user environment, because macros cannot include error handling.
Modules can be standalone objects containing functions that can be called from
anywhere in your application, or they can be directly associated with a form or a
report to respond to events on the associated form or report.