Sie sind auf Seite 1von 16

ADBMS

DBMS
A database management system (DBMS) refers to the technology for creating and managing
databases. DBMS is a software tool to organize (create, retrieve, update and manage) data in a
database.

ABOUT DBMS
The main aim of a DBMS is to supply a way to store up and retrieve database information that is
both convenient and efficient. By data, we mean known facts that can be recorded and that have
embedded meaning. Normally people use software such as DBASE IV or V, Microsoft ACCESS, or
EXCEL to store data in the form of database. A datum is a unit of data. Meaningful data combined to
form information. Hence, information is interpreted data - data provided with semantics. MS.
ACCESS is one of the most common examples of database management software.

Why Use Dbms?


 To develop software applications In less time.

 Data independence and efficient use of data.

 For uniform data administration.

 For data integrity and security.

 For concurrent access to data, and data recovery from crashes.

 To use user-friendly declarative query language.

Where is a Database Management System (DBMS) being Used?


 Airlines: reservations, schedules, etc

 Telecom: calls made, customer details, network usage, etc

 Universities: registration, results, grades, etc

 Sales: products, purchases, customers, etc

 Banking: all transactions etc

Advantages of DBMS
A DBMS manage data and has many advantages. These are:

 Data independence

 Efficient data

 Data integrity and security

 Data administration
Components of DBMS

 Users: Users may be of any kind such as DB administrator, System developer or database
users.

 Database application: Database application may be Departmental, Personal, organization's


and / or Internal.

 DBMS: Software that allows users to create and manipulate database access,

 Database: Collection of logical data as a single unit

TYPES OF DBMS

Based on the data model


Relational database – This is the most popular data model used in industries. It is
based on the SQL. They are table oriented which means data is stored in different access
control tables, each has the key field whose task is to identify each row. The tables or the
files with the data are called as relations that help in designating the row or record, and
columns are referred to attributes or fields. Few examples are MYSQL(Oracle, open
source), Oracle database (Oracle), Microsoft SQL server(Microsoft) and DB2(IBM).
Object oriented database – The information here is in the form of the object as used
in object oriented programming. It adds the database functionality to object
programming languages. It requires less code, use more natural data and also code
bases are easy to maintain. Examples are ObjectDB (ObjectDB software).
Images Source: Free Coloring Pages

Object relational database – Relational DBMS are evolving continuously and they
have been incorporating many concepts developed in object database leading to a new
class called extended relational database or object relational database.
Hierarchical database – In this, the information about the groups of parent or child
relationships is present in the records which is similar to the structure of a tree. Here the
data follows a series of records, set of values attached to it. They are used in industry on
mainframe platforms. Examples are IMS(IBM), Windows registry(Microsoft).
Network database – Mainly used on a large digital computers. If there are more
connections, then this database is efficient. They are similar to hierarchical database,
they look like a cobweb or interconnected network of records. Examples are CA-
IDMS(COMPUTER associates), IMAGE(HP).

Based on the number of users


Single user – As the name itself indicates it can support only one user at a time. It is
mostly used with the personal computer on which the data resides accessible to a single
person. The user may design, maintain and write the database programs.
Multiple users – It supports multiple users concurrently. Data can be both integrated
and shared,a database should be integrated when the same information is not need be
recorded in two places. For example a student in the college should have the database
containing his information. It must be accessible to all the departments related to him.
For example the library department and the fee section department should have
information about student’s database. So in such case, we can integrate and even though
database resides in only one place both the departments will have the access to it.

Based on the sites over which network is distributed


Centralized database system – The DBMS and database are stored at the single site
that is used by several other systems too. We can simply say that data here is maintained
on the centralized server.
Parallel network database system – This system has the advantage of improving
processing input and output speeds. Majorly used in the applications that have query to
larger database. It holds the multiple central processing units and data storage disks in
parallel.
Distributed database system – In this data and the DBMS software are distributed
over several sites but connected to the single computer.

Further they are classified as


1.Homogeneous DBMS – They use same software but from the multiple sites.
Data exchange between the sites can be handled easily. For example, library information
systems by the same vendor ,such as Geac Computer corporation, use the same DBMS
software that allows the exchanges between various Geac library sites.
2.heterogeneous DBMS – They use different DBMS software for different sites but
there is a additional software that helps the exchange of the data between the sites.
Client-server database system – This system has two logical components namely
client and server. Clients are generally the personal computers or workstations whereas
servers are the large workstations, mini range computers or a main frame computer
system. The applications and tools of the DBMS run on the client platforms and the
DBMS software on the server. Both server and client computers are connected over the
network. We can relate it to client and server in real life to understand in a much better
way. Here the applications and tools act as a client send the requests for its services. The
DBMS processes these requests and returns the result to the client. Server handles jobs
that are common to many clients say database access and updates.
Multi-tier client-server database system – The rise of personal computers in
business has increased the reliability of the network hardware leading to evolution of
two-tier and three-tier systems which use different software for the client and software.

OOPS CONCEPT

Core OOPS concepts are

1) Class
The class is a group of similar entities. It is only an logical component and not the physical entity.
For example, if you had a class called “Expensive Cars” it could have objects like Mercedes, BMW,
Toyota, etc. Its properties(data) can be price or speed of these cars. While the methods may be
performed with these cars are driving, reverse, braking etc.

2) Object

An object can be defined as an instance of a class, and there can be multiple instances of a class in a
program. An Object contains both the data and the function, which operates on the data. For example
- chair, bike, marker, pen, table, car, etc.

3) Inheritance

Inheritance is an OOPS concept in which one object acquires the properties and behaviors of the
parent object. It’s creating a parent-child relationship between two classes. It offers robust and
natural mechanism for organizing and structure of any software.

4) Polymorphism

Polymorphism refers to the ability of a variable, object or function to take on multiple forms. For
example, in English, the verb run has a different meaning if you use it with a laptop, a foot race,
and business. Here, we understand the meaning of run based on the other words used along with
it.The same also applied to Polymorphism.
5) Abstraction

An abstraction is an act of representing essential features without including background details. It is


a technique of creating a new data type that is suited for a specific application. For example, while
driving a car, you do not have to be concerned with its internal working. Here you just need to
concern about parts like steering wheel, Gears, accelerator, etc.

6) Encapsulation

Encapsulation is an OOP technique of wrapping the data and code. In this OOPS concept, the
variables of a class are always hidden from other classes. It can only be accessed using the methods
of their current class. For example - in school, a student cannot exist without a class.

CODDS RULE
Dr. Edgar Frank Codd (August 19, 1923 – April 18, 2003) was a computer scientist
while working for IBM he invented the relational model for database management (
theoretical basis for relational databases). Codd proposed thirteen rules (numbered
zero to twelve) and said that if a Database Management System meets these rules,
it can be called as a Relational Database Management System. These rules are
called as Codd's12 rules.

Rule Zero

 The system must qualify as relational, as a database, and as a management system. For a
system to qualify as a relational database management system (RDBMS), that system must use
its relational facilities (exclusively) to manage the database.
 The other 12 rules derive from this rule. The rules are as follows :

Rule 1: Information Rule


The data stored in a database, may it be user data or metadata, must be a value of some
table cell. Everything in a database must be stored in a table format.

Rule 2: Guaranteed Access Rule


Every single data element (value) is guaranteed to be accessible logically with a
combination of table-name, primary-key (row value), and attribute-name (column value).
No other means, such as pointers, can be used to access data.

Rule 3: Systematic Treatment of NULL Values


The NULL values in a database must be given a systematic and uniform treatment. This is
a very important rule because a NULL can be interpreted as one the following − data is
missing, data is not known, or data is not applicable.

Rule 4: Active Online Catalog


The structure description of the entire database must be stored in an online catalog, known
as data dictionary, which can be accessed by authorized users. Users can use the same
query language to access the catalog which they use to access the database itself.
Rule 5: Comprehensive Data Sub-Language Rule
A database can only be accessed using a language having linear syntax that supports data
definition, data manipulation, and transaction management operations. This language can
be used directly or by means of some application. If the database allows access to data
without any help of this language, then it is considered as a violation.

Rule 6: View Updating Rule


All the views of a database, which can theoretically be updated, must also be updatable by
the system.

Rule 7: High-Level Insert, Update, and Delete Rule


A database must support high-level insertion, updation, and deletion. This must not be
limited to a single row, that is, it must also support union, intersection and minus
operations to yield sets of data records.

Rule 8: Physical Data Independence


The data stored in a database must be independent of the applications that access the
database. Any change in the physical structure of a database must not have any impact on
how the data is being accessed by external applications.

Rule 9: Logical Data Independence


The logical data in a database must be independent of its user’s view (application). Any
change in logical data must not affect the applications using it. For example, if two tables
are merged or one is split into two different tables, there should be no impact or change on
the user application. This is one of the most difficult rule to apply.

Rule 10: Integrity Independence


A database must be independent of the application that uses it. All its integrity constraints
can be independently modified without the need of any change in the application. This rule
makes a database independent of the front-end application and its interface.

Rule 11: Distribution Independence


The end-user must not be able to see that the data is distributed over various locations.
Users should always get the impression that the data is located at one site only. This rule
has been regarded as the foundation of distributed database systems.

Rule 12: Non-Subversion Rule


If a system has an interface that provides access to low-level records, then the interface
must not be able to subvert the system and bypass security and integrity constraints.
NORMALISATION
If a database design is not perfect, it may contain anomalies, which are like a bad dream
for any database administrator. Managing a database with anomalies is next to impossible.
 Update anomalies − If data items are scattered and are not linked to each other properly, then it
could lead to strange situations. For example, when we try to update one data item having its
copies scattered over several places, a few instances get updated properly while a few others
are left with old values. Such instances leave the database in an inconsistent state.
 Deletion anomalies − We tried to delete a record, but parts of it was left undeleted because of
unawareness, the data is also saved somewhere else.
 Insert anomalies − We tried to insert data in a record that does not exist at all.
Normalization is a method to remove all these anomalies and bring the database to a
consistent state.

First Normal Form


First Normal Form is defined in the definition of relations (tables) itself. This rule defines
that all the attributes in a relation must have atomic domains. The values in an atomic
domain are indivisible units.

We re-arrange the relation (table) as below, to convert it to First Normal Form.

Each attribute must contain only a single value from its pre-defined domain.

Second Normal Form


Before we learn about the second normal form, we need to understand the following −
 Prime attribute − An attribute, which is a part of the candidate-key, is known as a prime
attribute.
 Non-prime attribute − An attribute, which is not a part of the prime-key, is said to be a non-
prime attribute.
If we follow second normal form, then every non-prime attribute should be fully functionally
dependent on prime key attribute. That is, if X → A holds, then there should not be any
proper subset Y of X, for which Y → A also holds true.
We see here in Student_Project relation that the prime key attributes are Stu_ID and
Proj_ID. According to the rule, non-key attributes, i.e. Stu_Name and Proj_Name must be
dependent upon both and not on any of the prime key attribute individually. But we find that
Stu_Name can be identified by Stu_ID and Proj_Name can be identified by Proj_ID
independently. This is called partial dependency, which is not allowed in Second Normal
Form.

We broke the relation in two as depicted in the above picture. So there exists no partial
dependency.

Third Normal Form


For a relation to be in Third Normal Form, it must be in Second Normal form and the
following must satisfy −

 No non-prime attribute is transitively dependent on prime key attribute.


 For any non-trivial functional dependency, X → A, then either −
o X is a superkey or,
o A is prime attribute.

We find that in the above Student_detail relation, Stu_ID is the key and only prime key
attribute. We find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is a
superkey nor is City a prime attribute. Additionally, Stu_ID → Zip → City, so there
exists transitive dependency.
To bring this relation into third normal form, we break the relation into two relations as
follows −
Boyce-Codd Normal Form
Boyce-Codd Normal Form (BCNF) is an extension of Third Normal Form on strict terms.
BCNF states that −

 For any non-trivial functional dependency, X → A, X must be a super-key.


In the above image, Stu_ID is the super-key in the relation Student_Detail and Zip is the
super-key in the relation ZipCodes. So,
Stu_ID → Stu_Name, Zip
And
Zip → City
Which confirms that both the relations are in BCNF.

PL/SQL DATA TYPES

Predefined PL/SQL data types are grouped into composite, LOB, reference, and
scalar type categories.

 A composite type has internal components that can be manipulated


individually, such as the elements of an array, record, or table.

 A LOB type holds values, called lob locators, that specify the location of
large objects, such as text blocks or graphic images, that are stored
separately from other database data. LOB types include BFILE, BLOB,
CLOB, and NCLOB.

 A reference type holds values, called pointers, that designate other program
items. These types include REF CURSORS and REFs to object types.

 A scalar type has no internal components. It holds a single value, such as a


number or character string. The scalar types fall into four families, which
store number, character, Boolean, and date/time data. The scalar families
with their datatypes are:
1. PL/SQL Number Types
BINARY_DOUBLE, BINARY_FLOAT, BINARY_INTEGER, DEC, DECIMAL,
DOUBLE PRECISION, FLOAT, INT, INTEGER, NATURAL, NATURALN,
NUMBER, NUMERIC, PLS_INTEGER, POSITIVE, POSITIVEN, REAL,
SIGNTYPE, SMALLINT

2. PL/SQL Character and String Types and PL/SQL National Character Types
CHAR, CHARACTER, LONG, LONG RAW, NCHAR, NVARCHAR2, RAW,
ROWID, STRING, UROWID, VARCHAR, VARCHAR2 Note that the LONG
and LONG RAW data types are supported only for backward
compatibility Information.

3. PL/SQL Boolean Types


BOOLEAN

4. PL/SQL Date, Time, and Interval Types


DATE, TIMESTAMP, TIMESTAMP WITH TIMEZONE, TIMESTAMP WITH
LOCAL TIMEZONE, INTERVAL YEAR TO MONTH, INTERVAL DAY TO
SECOND

DATE COMMAND IN DBMS


In this chapter, we will discuss the Date and Time in PL/SQL. There are two classes of
date and time related data types in PL/SQL −

 Datetime data types


 Interval data types
The Datetime data types are −

 DATE
 TIMESTAMP
 TIMESTAMP WITH TIME ZONE
 TIMESTAMP WITH LOCAL TIME ZONE
The Interval data types are −

 INTERVAL YEAR TO MONTH


 INTERVAL DAY TO SECOND

Field Values for Datetime and Interval Data Types


Both datetime and interval data types consist of fields. The values of these fields
determine the value of the data type. The following table lists the fields and their possible
values for datetimes and intervals.
Field Name Valid Datetime Values Valid Interval Values

YEAR -4712 to 9999 (excluding year 0) Any nonzero integer

MONTH 01 to 12 0 to 11

01 to 31 (limited by the values of MONTH


DAY and YEAR, according to the rules of the Any nonzero integer
calendar for the locale)

HOUR 00 to 23 0 to 23

MINUTE 00 to 59 0 to 59

00 to 59.9(n), where 9(n) is the precision of 0 to 59.9(n), where 9(n) is


SECOND time fractional seconds the precision of interval
fractional seconds
The 9(n) portion is not applicable for DATE.

-12 to 14 (range accommodates daylight


TIMEZONE_HOUR savings time changes) Not applicable
Not applicable for DATE or TIMESTAMP.

TIMEZONE_MINUTE 00 to 59 Not applicable


Not applicable for DATE or TIMESTAMP.

TIMEZONE_REGION Not applicable for DATE or TIMESTAMP. Not applicable

TIMEZONE_ABBR Not applicable for DATE or TIMESTAMP. Not applicable

The Datetime Data Types and Functions


Following are the Datetime data types −

DATE
It stores date and time information in both character and number datatypes. It is made of
information on century, year, month, date, hour, minute, and second. It is specified as −

TIMESTAMP
It is an extension of the DATE data type. It stores the year, month, and day of the DATE
datatype, along with hour, minute, and second values. It is useful for storing precise time
values.
TIMESTAMP WITH TIME ZONE
It is a variant of TIMESTAMP that includes a time zone region name or a time zone offset
in its value. The time zone offset is the difference (in hours and minutes) between local
time and UTC. This data type is useful for collecting and evaluating date information
across geographic regions.

TIMESTAMP WITH LOCAL TIME ZONE


It is another variant of TIMESTAMP that includes a time zone offset in its value.
Following table provides the Datetime functions (where, x has the datetime value) −

S.No Function Name & Description

1 ADD_MONTHS(x, y);
Adds y months to x.

2 LAST_DAY(x);
Returns the last day of the month.

3 MONTHS_BETWEEN(x, y);
Returns the number of months between x and y.

4 NEXT_DAY(x, day);
Returns the datetime of the next day after x.

5 NEW_TIME;
Returns the time/day value from a time zone specified by the user.

6 ROUND(x [, unit]);
Rounds x.

7 SYSDATE();
Returns the current datetime.

8 TRUNC(x [, unit]);
Truncates x.
Timestamp functions (where, x has a timestamp value) −

S.No Function Name & Description

CURRENT_TIMESTAMP();
1
Returns a TIMESTAMP WITH TIME ZONE containing the current session time along with
the session time zone.

EXTRACT({ YEAR | MONTH | DAY | HOUR | MINUTE | SECOND } | { TIMEZONE_HOUR


2 | TIMEZONE_MINUTE } | { TIMEZONE_REGION | } TIMEZONE_ABBR ) FROM x)
Extracts and returns a year, month, day, hour, minute, second, or time zone from x.

FROM_TZ(x, time_zone);
3
Converts the TIMESTAMP x and the time zone specified by time_zone to a TIMESTAMP
WITH TIMEZONE.

4 LOCALTIMESTAMP();
Returns a TIMESTAMP containing the local time in the session time zone.

SYSTIMESTAMP();
5
Returns a TIMESTAMP WITH TIME ZONE containing the current database time along with
the database time zone.

SYS_EXTRACT_UTC(x);
6
Converts the TIMESTAMP WITH TIMEZONE x to a TIMESTAMP containing the date and
time in UTC.

7 TO_TIMESTAMP(x, [format]);
Converts the string x to a TIMESTAMP.

8 TO_TIMESTAMP_TZ(x, [format]);
Converts the string x to a TIMESTAMP WITH TIMEZONE.
The Interval Data Types and Functions
Following are the Interval data types −
 IINTERVAL YEAR TO MONTH − It stores a period of time using the YEAR and MONTH
datetime fields.
 INTERVAL DAY TO SECOND − It stores a period of time in terms of days, hours, minutes, and
seconds.

Interval Functions
S.No Function Name & Description

1 NUMTODSINTERVAL(x, interval_unit);
Converts the number x to an INTERVAL DAY TO SECOND.

2 NUMTOYMINTERVAL(x, interval_unit);
Converts the number x to an INTERVAL YEAR TO MONTH.

3 TO_DSINTERVAL(x);
Converts the string x to an INTERVAL DAY TO SECOND.

4 TO_YMINTERVAL(x);
Converts the string x to an INTERVAL YEAR TO MONTH

Das könnte Ihnen auch gefallen