Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 49

Database Management Systems

Introduction
• People need data
• We create different kinds of lists to store and
organize data
• A grocery list, a phone book, a library’s card
catalog, and an instructor’s list of students are all
organized lists of data
• Computers can be used to store and manage lists
of data
• This is the reason for the computerized database
Introduction
• Now-a-days almost all computer applications
use databases
• A database is a collection of related data or
facts
• A database management system (DBMS) is a
software tool that allows people to store,
access, and process data or facts into useful
information
Introduction
• Many small database programs that run on
personal computers are not referred to as
database or database management programs
• Instead, they are called personal information
managers (PIMs), personal organizers, and
other names
• Three of the most important terms to know
about databases are Fields, Records, and Tables
Introduction
• Fields: Each piece of data in the personal address
book is stored in its own location, called a field
• For example, each entry has a field for Name, as
well as fields for Address, City, State, ZIP code, and
Phone
• Each unique type of data is stored in its own field
• The term column is sometimes used instead of
field
Introduction
• Records: One full set of fields – that is, all the
related data about one person or object – is
called a record
• The term row is sometimes used instead of
record
• Tables: A complete collection of records
makes a table
Introduction
• Two of the most common elements of a
database are forms and reports
• Forms are documents that are filled in to
create records
• Reports are documents that display a select
portion of a database’s information in an
easily readable format
• Reports can be printed as hard copies
Flat-File vs. Relational Database
• Many early database applications and some
current low-end applications access and
manipulate only one table at a time
• These applications store each table in its own file
• Very often, the table is simply called a file or just
“the database”
• A database file that consists of a single data table
is called a flat-file database
Flat-File vs. Relational Database
• Flat-file databases are useful for certain single-
user or small-group situations, especially for
maintaining lists, such as address lists or
inventories
• Data that is stored, managed, and manipulated
in a spreadsheet is similar to a flat-file database
• Although they are easy to learn and use, flat-file
database systems can be difficult to maintain
and are limited in their power
Flat-File vs. Relational Database
• When numerous files exist (one for each table
or related document), there is often a lot of
data redundancy
• Data redundancy increases the chance for
errors, wastes time, and uses excess storage
space
• Adding, deleting, or editing any field requires
that you make the same changes in every file
that contains that same field
Flat-File vs. Relational Database
• In a relational database – a database made up
of a set of tables – a common field existing in
any two tables creates a relationship between
the tables
Data Management Tasks
• Data management tasks fall into one of four
general categories:
– Entering data into the database
– Housekeeping tasks, such as updating data,
deleting obsolete records, and backing up the
database
– Sorting the data – that is, arranging or reordering
the database’s records
– Obtaining subsets of the data
Working with a Database
• The DBMS interface presents the user with data
and the tools required to work with the data
• You work with the interface’s tools to perform
the following data management functions:
– Creating tables
– Viewing records
– Sorting records
– Creating queries
– Generating reports
Creating Database Tables
• The first step in building any database is to
create one or more tables
• You must first determine what kind of data will
be stored in each table
• In other words, you must define each field in the
table by following a three-step process:
1. Name the field
2. Specify the field type
3. Specify the field size
Understanding Field Types
• When naming a field, indicate as briefly as
possible what the field contains
• Specifying the field type requires knowledge
of what kind of data the DBMS can understand
• Text fields (also called string fields, character
fields, or alphanumeric fields) accept any
string of letters or numbers that are not used
in calculations
Understanding Field Types
• Such an entry might be a person’s name, a
company’s name, an address, a phone
number, or any other textual data
• Numeric fields store purely numeric data
• The numbers in a numeric field might
represent currency, percentages, statistics,
quantities, or any other value that can be used
in calculations
Understanding Field Types
• The data itself is stored in the table strictly as a
numeric value, even though the DBMS can
display the value with formatting characters,
such as $ or % signs, decimal points, or
commas
• Sometimes a numeric data field is required to
have certain mathematical characteristics,
such as integer (whole numbers), floating point
(fractions), and so on
Understanding Field Types
• A date field or time field stores date or time entries
• Logical fields (also called Boolean fields) store one of only
two possible values
• You can apply almost any description for the data (yes or
no, true or false, on or off, and so forth)
• Binary fields store binary objects, BLOBs
• A BLOB (binary large object) can be a graphic image file
such as clip art, a photograph, a screen image, a graphic or
formatted text
• A BLOB can also be an audio file, video clip, or other object
Understanding Field Types
• In some DBMSs, counter fields (sometimes called
index or autonumber fields) store a unique numeric
value that the DBMS assigns to each record
• Because it is possible for two records to have
identical data in some tables, a counter field
ensures that every record will contain at least one
completely unique piece of data
• Counter fields also may be used for creating records
that number sequentially, such as invoices
Understanding Field Types
• Because most field types have fixed lengths
that restrict the number of characters in an
entry, memo fields (also called description
fields) provide fields for entering notes or
comments of any length
• With a memo field, you do not specify the size
of the data
Entering Data in a Table
• After the table has been set up, data can be
entered
• In most cases, entering data in a table is a
matter of typing characters at the keyboard
• Entering data in a database table is much
more like entering data in a spreadsheet
program (for example, Microsoft Excel)
Entering Data in a Table
• Most DBMSs allow you to create a data entry form to
make data entry easier
• A form is nothing more than a custom view of the
table that typically shows one record at a time and
includes special controls and labels that make data
entry less confusing
• For example, the form’s designer can include controls
that automatically move the insertion point to the
next field when the typist presses the ENTER or TAB
key
Entering Data in a Table
• This makes it easy for a typist to move from
one field to the next without having to take a
hand off the keyboard to reach for the mouse
• A form can even direct input into multiple
tables, which really makes life easier for a
typist who does not know about the
underlying structure of the DBMS and
database tables
Viewing Records
• The way data appears on screen contributes to
how easily users can work with it
• You have already seen examples of data
presented in two-dimensional, worksheet-style
tables
• With many DBMS products, you use the table
view (sometimes called the datasheet view) to
create a database table and to modify field
specifications
Viewing Records
• This view is also suitable for seeing a list of
records that you request to view in some
meaningful way, such as all the customers
who live in the same city
• Sometimes viewing the entire table is
unwieldy because there are too many entries
• Filters are a DBMS feature for displaying a
selected list or sub-sets of records from a table
Viewing Records
• The visible records satisfy a condition that the
user sets
• It is called a filter because it tells the DBMS to
display those records that satisfy the
conditions while hiding – or filtering out –
those that do not
• A DBMS also allows you to create forms for
viewing records
Viewing Records
• These forms are similar in design to those used
in data entry, but they are used to display
existing data instead of receiving new data
• By using forms, you can create simple, easily
understood views of your data that show just
one record at a time
• You also can create complex forms that display
related information from multiple tables
Sorting Records
• One of the most powerful features of a DBMS
is the ability to sort a table of data, either for a
printed report or for displaying on the screen
• Sorting arranges records according to the
contents of one or more fields
• For example, in a table of products, you can
sort records into numerical order by product
ID or into alphabetical order by product name
Sorting Records
• When sorting records, one important
consideration is determining the sort order
• An ascending sort order arranges records in
alphabetical order (from A to Z), numerical
order (from 0 to 9), or chronological order
(from 1/1/1900 to 12/31/1999)
• Conversely, a descending sort order arranges
records in the opposite order – that is, from Z to
A, or from 9 to 0
Querying a Database
• In a manner similar to entering sort conditions,
you can enter expressions or criteria that
– Allow the DBMS to locate records
– Establish relationships or links between tables to
update records
– List a sub-set of records
– Perform calculations
– Delete obsolete records
– Perform other data management tasks
Querying a Database
• Any of these types of requests is called a
query, a user-constructed statement that
describes data and sets criteria so that the
DBMS can gather the desired data and
construct specific information
• In other words, a query is a more powerful
type of filter that can gather information from
multiple tables in a relational database
Querying a Database
• For example, a sales manager might create a
query to list orders by quarter
• The query can include field names such as
Customer and City from a Customers table, and
Order Date from an Orders table
• To obtain the desired information, the query
requires the specific condition or criteria that will
isolate those records (orders received during a
given period) from all the records in both tables
Querying a Database
• In this case, the sales manager includes a range of
dates during which the orders were received
• It should be possible to generate a single language
that can, in theory, query any database
• If such a language were developed, a user knew
the language could query any database, regardless
of who created the database or what software was
used in the creation of the database
Querying a Database
• Mainframe database developers created the
Structured English QUEry Language (SEQUEL) in the
mid-1970s to solve this dilemma
• SEQUEL, and its later variant SQL, are English-like
query languages that allow the user to query a
database without knowing much about the
underlying database structure
• SQL (Structured Query Language, pronounced as
“ess-cue-el” or “sequel”) is a powerful tool and
nearly all PC-based DBMSs include it
Querying a Database
• SQL is useful in querying database and you will see it
available in relational DBMSs such as SQL Server,
Oracle, DB2, Microsoft Access, and many others
• In addition to SQL, PC-based databases sometimes
use a query/programming language called Xbase
• Like SQL, Xbase is somewhat English-like, but it is
more complicated because its commands cover the
full range of database activities, not just queries
Querying a Database
• Some DBMS programs provide an interface, like a form
or grid, that collects the facts about a query from the
user and composes the SQL or query statements
behind the scenes
• This feature allows a user to query by example (QBE)
• With QBE, you specify the search criteria by typing
values or expressions into the fields of a QBE form or
grid
• Whether a DBMS uses SQL, Xbase, or QBE, or offers all
three, the results of a query are always the same
Generating Reports
• Not all DBMS operations have to occur on screen
• Just as forms can be based on queries, so can
reports
• A report is printed information that, like a query
result, is assembled by gathering data based on
user-supplied criteria
• In fact, report generators in most DBMSs create
reports from queries
Generating Reports
• Reports can range from simple lists of records
to customized formats for specific purposes,
such as invoices
• Report generators can use selected data and
criteria to carry out automated mathematical
calculations as the report is printed
• For example, relevant data can be used to
calculate subtotals and totals for invoices or
sales summaries
Relational Database Management System
(RDBMS)
• A program used for creating, updating and
administering a relational database is a Relational
Database Management System (RDBMS)
• A relational database is an organized collection of
data items present as a set of formally described
tables
• The data in these tables can be viewed, modified and
also reassembled in different ways as per the user’s
requirement, without reorganizing the database
tables
Relational Database Management System
(RDBMS)
• E. F. Codd invented the relational database in
1970 at IBM
• A relational database contains a set of tables
comprising data
• Each table contains columns of one or more
categories of data
• The rows have a unique instance of data for
the categories defined in each column
Relational Database Management System
(RDBMS)
• Consider a database having student information as
an example
• It would have a table having columns for a student’s
name, roll number, department, section, address,
phone, etc.
• The same database can have another table with the
details of marks secured by the students having
columns with headings such as roll number, name,
sub1, sub2, sub3, total, pass, fail, rank, etc.
Relational Database Management System
(RDBMS)
• Different users can view this database as per their
requirements
• For example, the principal may like to see only the
students who secured the first 5 ranks, while a
teacher would want to see the list of students who
failed
• For every relational database, a domain is defined
for all possible data values in the column and any
further constraints which might apply to that data
value
Relational Database Management System
(RDBMS)
• Every table in the database is assumed to be a
single entity
• Every entity is used to represent an object or
person or an event for which various data are
stored
• There are a series of attributes for each entry of
the entity
• Different properties of the entities are described
by the attributes
Relational Database Management System
(RDBMS)
• The data are stored in various tables in a
relational database
• These tables are connected to one another
using relationships formed by the keys
• In a RDBMS, there are two types of keys –
primary key and foreign key
• A field used to identify a specific record present
in a table uniquely is called a primary key
Relational Database Management System
(RDBMS)
• As there is a possibility for the text fields like
name which can reoccur, hence, primary keys
should be numeric fields which can include
roll number, membership number, employee
ID, student ID, account number, book ID, etc.
• When there is no logical number present, it is
created automatically by most of the
databases which is called an auto number
Relational Database Management System
(RDBMS)
• A foreign key is present as a field in one table
but it is already the primary key of another
table
• Foreign keys are used for the establishment of
a relationship in between the main table and
the subsidiary/related tables
Relationships
• A relationship is a link between two tables of
a database
• When a relationship is created, a record in one
table is connected to one or many records in
another table
• Using a relationship you can match the
primary key from one table with an entry in
the foreign key of the other related table
Relationships
• There are three types of relationships
1) One-To-One (1:1) Relationships
• In this type of relationship, a row in Table A can have
only one matching row in Table B, and vice versa
• A one-to-one relationship is created if either both the
related columns have unique constraints or both are
primary keys in their tables
2) One-To-Many (1:m) Relationships
• In this type of relationship, a row in Table A has many
matching rows in Table B
Relationships
3) Many-To-Many (m:m) Relationships
• In this type of relationship, rows in Table A can match
with more than one row in Table B, and vice versa

You might also like