Вы находитесь на странице: 1из 10

DATABASE SYSTEM - MTA

What Should a Database Provide?


A database is a formally structured set of information that pertains to a particular subject or
purpose, stored by a computer program. The main purpose of a database is to enable you to
store, manipulate and retrieve data. You can store any type of data you want, and the data
should be available whenever you need it. For this reason, the data stored in a database is (or
should be) durable. That is, the data remains intact after any program that accesses the
information has ended.
Because a database can store thousands of records, it would be a chore if you had to open a
table and go through each record one at a time until you found the record you needed. Of
course, the process would be even more difficult if you had to retrieve multiple records.
Thankfully, you dont have to go through database records in this way. Rather, to retrieve data
within a database, you run a database query, which is an inquiry into the database that returns
information back from the database. In other words, a query is used to ask for information from a
database.
If a database contains thousands of records with many fields per record, it may take even a fast
computer a significant amount of time to search through a table and retrieve the requested data.
This is where a database index comes in handy. An index is a data structure that improves the
speed of data retrieval operations on a database table. The disadvantage of indexes is that
they need to be created and updated, which requires processing resources and takes up disk
space.
Many database applications are available on the market. These programs offer various features
and interfaces, but all access the stored data in a standard manner. Database applications are
tools that allow you to create, store, read, update and delete information. Any good database
system should provide the following features: CRUD, ACID, and Security. These features are
explained in the following sections.
NOTE:
A database (db) is an organized collection of data, typically stored in electronic format.
It allows you to input data, organize the data and retrieve the data quickly.
Traditional databases are organized by fields, records, and files.
CRUD
CRUD is an acronym that represents the four database operations that any database should
provide: Create, Read, Update and Delete. If the database is welldesigned, checks are
automatically performed on each of these operations to ensure that data remains consistent and
valid.
A welldesigned database will also employ checks and constraints to prevent the deletion of a
record that has other records linked to it, ensuring that all data remains consistent and valid.

CRISTY NAZARENO

DATABASE SYSTEM - MTA

The ease and speed with which data can be retrieved (read) from a database also depends upon
good database design. Data should be structured to allow specific items to be found and
retrieved quickly and efficiently. Any search performed any number of times should provide
consistent results.

Transactions
Modern databases support the concept of transactions. A transaction is a single operation or a
series of operations that retrieves or alters the data in a database. A successful transaction will
change the database in some way. The goal is always to change the database from one
consistent state to another consistent state. While a transaction is in process, the database may
enter an inconsistent state, but at the end of the transaction, the database is returned to a
consistent state.
A transaction can have either of two results it can be committed, or rolled back. If a transaction
finishes successfully, the results of the transaction are written to the database (committed) and
the end result is that the database attains a new consistent state. This is known as a commit.
Conversely, if there is a problem with the transaction and it does not complete successfully, it
will be aborted and the uncommitted data changes will need to revert back to their original
values. The formal term for reverting the transaction is a rollback, with the database being
placed back into the consistent state it was in before the transaction started.
A classic example of a transaction would be transferring money from one bank account to
another. Suppose Andy writes
Beatrice a check for Php 100 and you need to transfer money from Andy's account to Beatrice's
account. You subtract the Php 100 from Andy's account and add the Php 100 to Beatrice's
account. Both actions (subtracting the money from Andy's account and adding the money to
Beatrice's account) constitute one transaction of transferring the money. However, if a problem
occurs in the middle so that the Php 100 is subtracted from Andys account but Beatrices
account did not receive the Php 100, then there is an imbalance that needs to be corrected.
In a transaction, all the operations happen, or none of them happen. That is, all the operations
within that transaction are committed at the same time, but if the transaction is rolled back then
any of the operations that occurred inside the transaction will be reversed at the same time.
Databases should roll back any transaction that is open if the database encounters an error
situation.
ACID
ACID is an acronym for the four properties that are desirable for any effective transaction
system. These are:
Atomicity The transaction is a complete unit, and is executed in its entirety or not at all.
Consistency The transaction must change the database from one consistent state to
another consistent state. If an operation within the transaction would violate the
database's rules, the transaction is rolled back.
Isolation The transaction is independent from other transactions. That is, while a
transaction is in progress, no one else can see the data being affected, as this data may
CRISTY NAZARENO

DATABASE SYSTEM - MTA

be in an inconsistent state until the transaction is completed (committed). Any other user
reading the data while the AndytoBeatrice transfer transaction was in progress would see
the Php 100 either in Andy's account before the transaction or in Beatrice's account after
the transaction. An incomplete transaction (a state where the Php 100 is neither in Andy's
account nor in Beatrice's account) should not be visible to other users.
Durability Committed transactions are permanent and will not be lost if the power fails or
if the database restarts. Once a transaction has been committed, it cannot be rolled back.
The only way to undo a committed transaction is to execute another transaction that
reverses the changes made by the first transaction.
Security
Database security is accomplished through a combination of physical, network access and design
methods. Database servers, for example, can be made physically secure by setting them up in a
locked room where an access card is required to obtain entrance. You can also disable USB ports
on the server to prevent someone from copying data to removable storage media.
You can use the builtin security tools in your network to prevent unauthorized access to your
data. Additionally, through careful design, you can separate your data into categories that
different types of users need to access. You can then grant different levels of permissions to the
different types of users, thereby controlling access to your data.
Database Files
Microsoft SQL server uses three types of files to store the database:
Primary data files, with an .mdf extension, which contain user-defined objects, such as
tables and views, as well as system tables.
Secondary data files, with an .ndf extension, on separate physical hard disks to give your
database more room.
Transaction log files use an .ldf extension and dont contain any objects such as tables or
views.
Database Management System (DBMS)
Most users do not access the databases directly, Instead, users use a database
management system (DBMS) to access the databases indirectly. DBMS is a collection of
programs that enables you to enter, organize, and select data in a database.
Database Types
A database is a tool that stores data, and lets you create, read, update and delete the data.
Information storage is one of
the primary purposes of computers, and many different types of data storage systems have been
created over the many
years that computers have been in wide use. Filebased data storage systems represent the
earliest attempt at computerizing the traditional manual filing system. In a filebased database,
all the data is contained in one file. File-based
types include flat files and spreadsheets.

CRISTY NAZARENO

DATABASE SYSTEM - MTA

In contrast to filebased storage systems, relational databases store data in multiple tables
that are linked so that all data pertaining to a particular entity may be retrieved, even though
that data may be stored across several separate tables.

Flat type or Flat file (filebased) databases


A flattype database is simply a file that contains data in text and/or binary form. All the
data is contained in one file, and the file consists of one record per line (or row). Each row
in the file is terminated by a new line character (or carriage return and new line character
pair).
Flat-type databases are considered flat because they are two-dimensional tables
consisting of rows and columns. Each column can be referred to as a field (such as a
persons last name or a products ID number), and each row can be referred to as a record
(such as a persons or products information).
The values within each record may be separated by white space or by a delimiter, such as
a comma or a tab. This type of flat file is often referred to as a commaseparated values
(CSV) or fixedformat file. Following is an example of the contents of a flat file.
Robin Stevens,Personnel,402.555.1234,x100
Elaine Richards,Finance,402.555.1234,x200
Henry Woo,Sales,480.555.4321,x300
Emilio Perez,Sales,480.555.4321,x400
Sam Jenkins,Personnel,402.555.1234,x101

Hierarchical databases
A hierarchical database design is similar to a tree structure (such as a family tree). Each
parent can have multiple children, but each child can have only one parent. This type is
the oldest database type and is regarded as the first major influence on database
modelling. Examples are database created using MS Excel, FoxPro, etc. Below is an
example of hierarchical database

Relational databases
A relational database is similar to a hierarchical database in that data is stored in tables
and any new information is automatically added into the table without the need to

CRISTY NAZARENO

DATABASE SYSTEM - MTA

reorganize the table itself. Unlike in hierarchical databases, however, a table in a relational
database can have multiple parents.
Instead of a single table containing all the data, a relational database is a collection of
data organized as a set of formally defined tables. The tables can contain data that relates
to data held in other tables within the database, and this data can be retrieved from the
database in many different ways without the need to reorganize or restructure the
database tables themselves.

CRISTY NAZARENO

DATABASE SYSTEM - MTA

Figure 1: Relational database solution for office supply store


Notice that by using related tables:
Data entry is faster because the operator needs to fill in ID numbers only, not all the
details.
The database itself is smaller because very little data is repeated.
Records are easy to update. In the example above, if the customers address changes,
only one record has to be updated instead of every instance of that address, as a
spreadsheet database would require.
Database Servers
Databases are often found on database servers so that they can be accessed by
multiple users and provide a high level of performance. One popular database server is Microsoft
SQL Server. Database servers like SQL Server do not actually house graphical programs, wordprocessing applications, or any other type of applications. Instead, these servers are entirely
optimized to serve only the purposes of the database itself, usually using advanced hardware
that can handle the high processing needs of the database. It is also important to note that these
servers do not act as workstations; they generally are mounted on racks located in a central data
center and can be accessed only through an administrators desktop system.
CRISTY NAZARENO

DATABASE SYSTEM - MTA

Relational Database Management Systems (RDBMS)


As databases have evolved, so have the applications that store and manage their data. In
general, this software is referred to as a database management system (DBMS). A DBMS
allows users to define, create and maintain databases while providing controlled access to the
data. Early forms of the DBMS, however, did not support related tables.
A relational database management system (RDBMS) provides all the features and
functions of a DBMS and supports the use of related tables. The RDBMS, therefore, is the modern
database application. The terms are at times (inaccurately) used interchangeably. It is safe to
assume, however, that any modern database application is an RDBMS.
Understanding Database Fundamentals
A simple database with one table is similar to a spreadsheet that contains rows and columns.
However, unlike a spreadsheet, a database allows you to store thousands of rows of data and
then access that information more quickly than by reading a spreadsheet.

CRISTY NAZARENO

DATABASE SYSTEM - MTA

Features
An RDBMS is designed to provide general functionality and services for many different database
applications. There are numerous RDBMSs available for use on varying platforms. Most provide a
welldefined set of features which include the following:
The storage of data in a central repository (the database) that can be accessed by multiple
users.
Support for the use of Structured Query Language (SQL) to define and manipulate the
data. SQL is a language used to create professional, highperformance databases. You will
learn more about SQL later in this course.
Support for Data Definition Language (DDL), a subset of SQL used to define the data
contained in the database.
Support for data types (text, numeric, etc.) which must be defined for each column in a
table in advance. The database will not allow values of other types in the column, and will
not allow the data type to change without rebuilding the table.
The ability to enforce constraints, such as requiring that a delivery date be on or after the
current date, or requiring that a specific field contain a value.
Support for Data Manipulation Language (DML), a subset of SQL used to insert, update and
delete data.
The ability to preserve data consistency by preventing the insertion, modification or
deletion of records if such an action would result in inconsistencies.
Support for complex queries and functions.
The ability to restore the data to a previous state in case of a hardware or software failure.
Provision for protecting the data (e.g., a security system).
Support for a data dictionary (or system catalog) for describing the data within the
database.
Advantages and Disadvantages
The advantages to using an RDBMS include:
Management of data redundancy: As has been discussed, filebased systems tend to
store duplicated data. An RDBMS allows for the use of related tables, thereby eliminating
unneeded repetition of data. The RDBMS provides mechanisms for ensuring that updates
to redundant data across multiple tables are properly synchronized.
Consistency of data: Because of the ability to control data redundancy, the risk of
compromising the accuracy and consistency of the data is greatly reduced. If data appears
in more than one location in the database, the RDBMS can ensure that all instances of the
data remain consistent with one another.
Data sharing: In a filebased system, usually only one person has access to the file
containing the database. Because an RDBMS gathers data into a central repository,
several authorized users can have access to the data.
Concurrent data access: In a filebased system, usually only one person can access the
data at any time. Conversely, a database can be accessed by multiple authorized users
simultaneously.
Increased data integrity: The RDBMS provides mechanisms for defining the type of data
that can be held in a table or shared among tables. The RDBMS enforces the constraints
placed on the data in the database, thereby ensuring that the data is valid.

CRISTY NAZARENO

DATABASE SYSTEM - MTA

Increased data security: The RDBMS provides mechanisms to protect data from
unauthorized use. A database administrator (DBA) can define security measures, and the
RDBMS enforces those measures. These measures can include the use of user names and
passwords, restrictions on the type of operations a particular user can perform, and
restricted access to particular areas of the database for certain users.
Adherence to standards: The RDBMS supports the use of standard data access
methods, for example, through SQL. This adherence to standards provides developers and
programmers a standard way to access data from within any custom applications they
create.
Increased data backup and recovery: In a filebased system, the responsibility for
backing up and/or recovering data lies with the person who maintains the file. An RDBMS,
on the other hand, provides mechanisms for both backing up a database and recovering a
database in the event of hardware or software failure.

Disadvantages associated with using an RDBMS may include:


Increased complexity: An RDBMS is a complex piece of software, offering many
services. The database designer and the DBA must have a firm understanding of the
available functionality to fully realize its potential. If the complexities of the software are
not understood, the RDBMS can cause more problems than it solves.
Required resources: Most RDBMSs are extremely large packages requiring hundreds of
megabytes of disk space and significant amounts of memory to run efficiently.
Cost: As with any other software package, there is the cost of ownership. Cost varies from
product to product, but is definitely a factor to be considered. In many cases a light or
free version is available, but some of these are free only for development purposes. When
you are ready to put the database into production, you must pay for licensing. An RDBMS
may also require you to buy additional hardware, perhaps for both additional storage
space and a machine to actually host the RDBMS. In some cases, you may also need to
consider the cost (and time and training) of converting old data to the new RDBMS.
Good Design is Vital
The design of a database determines if it is efficient and easy to use. While database
applications allow you to create, edit and retrieve data, they cannot help you design your
database.
If a database is designed well, you can find the data you want quickly and easily and it will be
consistent. Good design also ensures that the data is valid, that corrections are easy to make,
and that related transactions either all happen or do not happen.
On the other hand, in a poorly designed database, data retrieval may be excruciatingly slow,
data may be inconsistent, or you may not be able to find the data you want. In addition, error
correction may be difficult and time consuming. No one wants to use a database that takes
forever to retrieve records, or that retrieves potentially questionable data. In short, if the
underlying design is flawed, the whole system is at risk for failure.
Planning is paramount
CRISTY NAZARENO

DATABASE SYSTEM - MTA

Entire courses are written on the proper steps for planning the design a database. Here, the
basic steps are described
very briefly.
The first phase in database design involves gathering information and creating a data
model. Before you pick up a pencil to sketch out your first table, be sure you understand the
requirements. Get a clear picture of what the database will be used for, what type of data it
needs to store, and what it needs to accomplish. Will the database track inventory, or customer
orders, or student grades? What types of reports might be expected?
During this phase of the process, you try to determine what type of data should go into
the database. Try to identify the specific entities that are involved. An entity represents a
specific instance of something you want to track, for example, a product or an order. If your
database needs to track information on customers, orders and inventory, it will probably include
entities for customer information, order information and inventory information. A good rule to
keep in mind when
determining an entity is this: One entity should represent one clearly defined thing, and nothing
else.
Each entity in the data model will contain particular attributes that describe characteristics of the
entity. For example, a customer entity would likely contain attributes such as a customer name,
customer identification number, and customer address. An inventory entity would likely contain
attributes such as an item identification number, items description, and price.
The data modeling process also involves determining how the entities relate to one
another. In practice, the task of creating the data model often generates more questions, which
in turn creates the requirement to perform more information gathering.
The second phase of database design involves creating a logical model. In creating a
logical model, entities are generally represented as tables, and attributes as table fields.
You determine how the data should be organized and diagram how the tables are related to one
another. You also identify the constraints that will keep the data valid and consistent.
The third phase of database design involves creating the physical database.

CRISTY NAZARENO

10

Вам также может понравиться