Professional Documents
Culture Documents
by kailash dhirwani (
WHAT IS DBMS ?
- To be able to carry out operations like insertion, deletion and retrieval, the database
needs to be managed by a substantial piece of software; this software is usually called a
Database Management System(DBMS).
- A DBMS is usually a very large software package that enables many different tasks
including the provision of facilities to enable the user to access and modify information in
the database.
- Data Description Languages (DDL) and Data Manipulation Languages (DML) are
needed for manipulating and retrieving data stored in the DBMS. These languages are
called respectively.
An architecture for database systems, called the three-schema architecture was proposed
to help achieve and visualize the important characteristics of the database approach.
What is a Database?
A collection of related pieces of data:
▪ Representing/capturing the information about a real-world
enterprise or part of an enterprise.
▪ Collected and maintained to serve specific data management
needs of the enterprise.
▪ Activities of the enterprise are supported by the database and
continually update the database.
University Database:
Data about students, faculty, courses, research-
laboratories, course registration/enrollment etc.
Reflects the state of affairs of the academic aspects of the
university.
Purpose: To keep an accurate track of the academic
activities of the university.
RDBMS
1
A Relational Database Management System is a program that lets you create,
update and administrator a relational database. The primary rule for RDBMS is
that the Data should be stored in the form of tables.
Most of the RDBMS’s use the Structures Query Language to access the database.
When a database undergoes NORMALISATION it is called as a RDBMS.
2
What is the purpose of the mappings in the Three Schema Architecture? Is the user
or the DBMS responsible for using the mappings?
Ans: The purpose of the mappings in the Three Schema Architecture is to describe how
a
schema at a higher level is derived from a schema at a lower level. The DBMS, not the
user, is responsible for using the mappings
IMPORTANT TO REMEMBER :
Data and meta-data
– three schemas are only meta-data(descriptions of data).
– data actually exists only at the physical level.
Mapping
– DBMS must transform a request specified on an external schema into a request against
the conceptual schema, and then into the internal schema.
– requires information in meta-data on how to accomplish the mapping among various
levels.
– overhead(time-consuming) leading to inefficiencies.
– few DBMSs have implemented the full three-schema architecture.
3
DATA INDEPENDENCE
The disjointing of data descriptions from the application programs (or user-interfaces)
that uses the data is called data independence. Data independence is one of the main
advantages of DBMS. The three-schema architecture provides the concept of data
independence, which means that upper-levels are unaffected by changes to lower-levels.
The three schemas architecture makes it easier to achieve true data independence. There
are two kinds of data independence.
rewritten.
* Modifications at this level are usually to improve performance.
Logical data independence is harder to achieve as the application programs are usually
heavily dependent on the logical structure of the data. An analogy is made to abstract data
types in programming languages.
. What is a DBMS?
Ans: A database management system (DBMS) is a collection of software that supports
the creation, use, and maintenance of databases. Initially, DBMSs provided efficient
storage and retrieval of data. Due to marketplace demands and product innovation,
DBMSs have evolved to provide a broad range of features for data acquisition, storage,
dissemination, maintenance, retrieval, and formatting. The evolution of these features
has made DBMSs rather complex
What is SQL?
Ans: The Structured Query Language (SQL) is an industry standard language supported
by most DBMSs. SQL contains statements for data definition, data manipulation, and
data control. A DBMS has to be persistent, that is it should be accessible when the
program created the data ceases to exist or even the application that created the data
restarted. A DBMS also has to provide some uniform methods independent of a specific
application for accessing the information that is stored.
RDBMS is a Relational Data Base Management System Relational DBMS. This adds the
additional condition that the system supports a tabular structure for the data, with
enforced relationships between the tables. This excludes the databases that don't support a
tabular structure or don't enforce relationships between tables.
4
Many DBA's think that RDBMS is a Client Server Database system but thats not the case
with RDBMS.
Yes you can say DBMS does not impose any constraints or security with regard to data
manipulation it is user or the programmer responsibility to ensure the ACID PROPERTY
of the database whereas the rdbms is more with this regard bcz rdbms define the integrity
constraint for the purpose of holding ACID PROPERTY.
5
the complete details of data storage and access paths
Three Schema Architecture
Data and meta-data
- three schemas are only meta-data (descriptions of data)
- data actually exists only at the physical level
Mapping
- DBMS must transform a request specified on an external
schema into a request against the conceptual schema,
and then into the internal schema
- requires information in meta-data on how to accomplish
the mapping among various levels
- overhead (time-consuming) leading to inefficiencies
- few DBMSs have implemented the full three-schema
architecture
Benefits of Three Schema Architecture
Logical data independence
- the capacity to change the conceptual schema without
having to change external schema or application prgms
ex: Employee (E#, Name, Address, Salary)
A view including only E# and Name is not affected by
changes in any other attributes.
Physical data independence
- the capacity to change the internal schema without
having to change the conceptual (or external) schema
- internal schema may change to improve the performance
(e.g., creating additional access structure)
- easier to achieve logical data independence, because
application programs are dependent on logical structures
Data Models
Data abstraction
- one fundamental characteristic of the database approach
- hides details of data storage that are not needed by most
database users and applications
Data model
- a set of data structures and conceptual tools
used to describe the structure of a database
(data types, relationships, and constraints)
- used in the definition of the conceptual,
external, and internal schema
- must provide means for DB designers to represent
the real-world information completely and naturally
Data Models
High-level (conceptual) data models
- use concepts such as entities, attributes, relationships
6
- object-based models: ER model, OO model
Representational (implementation) data models
- most frequently used in commercial DBMSs
- record-based models: relational, hierarchical, network
Low-level (physical) data models
- to describe the details of how data is stored
- captures aspects of database system implementation:
record structures (fixed/variable length) and ordering,
access paths (key indexing), etc.
Schemas and Instances
In any data model, it is important to distinguish between
the description of the database and the database itself.
Data Models
ER model
- popular high-level conceptual model used in DB design
oo..
7
(e.g., employee: E# 32 bits
Name 30 bytes
Address 50 bytes)
Benefit
- application programs must know the logical organization
but the physical organization is an implementation detail
they need not know
8
• We then run the script using the START keyword…
9
2000 01-MAY-81
7782 CLARK
2000 09-JUN-81
• For changing date in a table, we make use of the UPDATE statement…
SQL> update managers
Table of Contents
Basics of the SELECT Statement
Conditional Selection
Relational Operators
Compound Conditions
IN & BETWEEN
Using LIKE
Joins
Keys
Performing a Join
Eliminating Duplicates
Aliases & In/Subqueries
Aggregate Functions
Views
Creating New Tables
Altering Tables
Adding Data
Deleting Data
Updating Data
Indexes
GROUP BY & HAVING
More Subqueries
EXISTS & ALL
UNION & Outer Joins
Embedded SQL
Common SQL Questions
10
Nonstandard SQL
Syntax Summary
Exercises
Important Links
Basics of the SELECT Statement
In a relational database, data is stored in tables. An example table would relate Social
Security Number, Name,
and Address:
EmployeeAddressTable
SSN
FirstName LastName Address
City
State
512687458 Joe
Smith
83 First Street Howard Ohio
758420012 Mary
Scott
842 Vine Ave. Losantiville Ohio
102254896 Sam
Jones
33 Elm St.
Paris
New York
876512563 Sarah
Ackerman 440 U.S. 110 Upton
Michigan
Now, let's say you want to see the address of each employee. Use the SELECT statement,
like so:
SELECT FirstName, LastName, Address, City, State
FROM EmployeeAddressTable;
The following is the results of your query of the database:
First Name Last Name Address
City
State
Joe
Smith
83 First Street Howard Ohio
Mary
Scott
842 Vine Ave. Losantiville Ohio
11
Sam
Jones
33 Elm St.
Paris
New York
Sarah
Ackerman 440 U.S. 110 Upton
Michigan
To explain what you just did, you asked for the all of data in the EmployeeAddressTable,
and specifically, you
asked for the columns called FirstName, LastName, Address, City, and State. Note that
column names and
table names do not have spaces...they must be typed as one word; and that the statement
ends with a semicolon
(;). The general form for a SELECT statement, retrieving all of the rows in the table is:
SELECT ColumnName, ColumnName, ...
FROM TableName;
To get all columns of a table without typing all column names, use:
SELECT * FROM TableName;
Each database management system (DBMS) and database software has different methods
for logging in to the
database and entering SQL commands; see the local computer "guru" to help you get
onto the system, so that
you can use SQL
Data model
A data model provides the details of information to be stored, and is of primary use when
the final product is the generation of computer software code for an application or the
12
preparation of a functional specification to aid a computer software make-or-buy
decision. The figure is an example of the interaction between process and data models.
According to Hoberman (2009), "A data model is a wayfinding tool for both business
and IT professionals, which uses a set of symbols and text to precisely explain a subset of
real information to improve communication within the organization and thereby lead to a
more flexible and stable application environment
Database model
13
Hirchiel model network model relational model
Data structure
A data structure is a way of storing data in a computer so that it can be used efficiently. It
is an organization of mathematical and logical concepts of data. Often a carefully chosen
data structure will allow the most efficient algorithm to be used. The choice of the data
structure often begins from the choice of an abstract data type.
A data model describes the structure of the data within a given domain and, by
implication, the underlying structure of that domain itself. This means that a data model
in fact specifies a dedicated grammar for a dedicated artificial language for that domain.
A data model represents classes of entities (kinds of things) about which a company
wishes to hold information, the attributes of that information, and relationships among
those entities and (often implicit) relationships among those attributes. The model
describes the organization of the data to some extent irrespective of how data might be
represented in a computer system.
The entities represented by a data model can be the tangible entities, but models that
include such concrete entity classes tend to change over time. Robust data models often
identify abstractions of such entities. For example, a data model might include an entity
class called "Person", representing all the people who interact with an organization. Such
an abstract entity class is typically more appropriate than ones called "Vendor" or
"Employee", which identify specific roles played by those people
14
It is common practice to draw a context-level Data flow diagram first which shows the
interaction between the system and outside entities. The DFD is designed to show how a
system is divided into smaller portions and to highlight the flow of data between those
parts. This context-level Data flow diagram is then "exploded" to show more detail of the
system being modeled
Object model
In computing the term object model has a distinct second meaning of the general
properties of objects in a specific computer programming language, technology, notation
or methodology that uses them. For example, the Java object model, the COM object
model, or the object model of OMT. Such object models are usually defined using
concepts such as class, message, inheritance, polymorphism, and encapsulation. There is
an extensive literature on formalized object models as a subset of the formal semantics of
programming languages
Data properties
Some important properties of data for which requirements need to be met are:
• definition-related properties
o relevance: the usefulness of the data in the context of your business.
o clarity: the availability of a clear and shared definition for the data.
15
o consistency: the compatibility of the same type of data from different
sources.
Another kind of data model describes how to organize data using a database management
system or other data management technology. It describes, for example, relational tables
and columns or object-oriented classes and attributes. Such a data model is sometimes
referred to as the physical data model, but in the original ANSI three schema architecture,
it is called "logical". In that architecture, the physical model describes the storage media
(cylinders, tracks, and tablespaces). Ideally, this model is derived from the more
conceptual data model described above. It may differ, however, to account for constraints
like processing capacity and usage patterns.
While data analysis is a common term for data modeling, the activity actually has more
in common with the ideas and methods of synthesis (inferring general concepts from
particular instances) than it does with analysis (identifying component concepts from
more general ones). {Presumably we call ourselves systems analysts because no one can
say systems synthesists.} Data modeling strives to bring the data structures of interest
together into a cohesive, inseparable, whole by eliminating unnecessary data
redundancies and by relating data structures with relationships./
• Concurrency Control
– Provide correct and highly available access to data
in the presence of concurrent access by large and
diverse user populations
• Recovery
– Ensures database is fault tolerant, and not
corrupted by software, system or media failure
– 7x24 access to mission critical data
• Existence of Concrncy&Recovry
allows applications to be
written without explicit concern for
concurrency and fault tolerance
16
Database transaction and the ACID rules
the concept of a database transaction (or atomic transaction) has evolved in order to
enable both a well understood database system behavior in a faulty environment where
crashes can happen any time, and recovery from a crash to a well understood database
state. A database transaction is a unit of work, typically encapsulating a number of
operations over a database (e.g., reading a database object, writing, acquiring lock, etc.),
an abstraction supported in database and also other systems. Each transaction has well
defined boundaries in terms of which program/code executions are included in that
transaction (determined by the transaction's programmer via special transaction
commands). Every database transaction obeys the following rules (by support in the
database system; i.e., a database system is designed to guarantee them for the transactions
it runs):
• Atomicity - Either the effects of all or none of its operations remain ("all or
nothing" semantics) when a transaction is completed (committed or aborted
respectively). In other words, to the outside world a committed transaction appears
(by its
effects) to be indivisible, atomic, and an aborted transaction does not leave effects
at all, as if never existed.
• Consistency - Every transaction must leave the database in a consistent (correct)
state, i.e., maintain the predetermined integrity rules of the database (constraints
upon and among the database's objects). A transaction must transform a database
from one consistent state to another consistent state (it is the responsibility of the
transaction's programmer to make sure that the transaction itself is correct, i.e.,
performs correctly what it intends to perform while maintaining the integrity rules).
Thus since a database can be normally changed only by transactions, all the
database's states are consistent. An aborted transaction does not change the state.
• Isolation - Transactions cannot interfere with each other. Moreover, usually the
effects of an incomplete transaction are not visible to another transaction. Providing
isolation is the main goal of concurrency control.
• Durability - Effects of successful (committed) transactions must persist through
crashes (typically by recording the transaction's effects and its commit event in a
non-volatile memory).
• Thus concurrency control is an essential element for correctness in any system
where two database transactions or more, executed with time overlap, can access
the same data, e.g., virtually in any general-purpose database system. Consequently
a vast body of related research has been accumulated since database systems have
emerged in the early 1970s. A well established concurrency control theory exists for
database systems: serializability theory, which allows to effectively design and
analyze concurrency control methods and mechanisms.
17
transactions are executed serially, i.e., sequentially with no overlap in time, no transaction concurrency
exists. However, if concurrent transactions with interleaving operations are allowed in an uncontrolled
manner, some unexpected, undesirable result may occur. Here are some typical examples:
• The lost update problem: A second transaction writes a second value of a data-item (datum) on top
of a first value written by a first concurrent transaction, and the first value is lost to other
transactions running concurrently which need, by their precedence, to read the first value. The
transactions that have read the wrong value end with incorrect results.
• The dirty read problem: Transactions read a value written by a transaction that has been later
aborted. This value disappears from the database upon abort, and should not have been read by any
transaction ("dirty read"). The reading transactions end with incorrect results.
• The incorrect summary problem: While one transaction takes a summary over the values of all the
instances of a repeated data-item, a second transaction updates some instances of that data-item. The
resulting summary does not reflect a correct result for any (usually needed for correctness)
precedence order between the two transactions (if one is executed before the other), but rather some
random result, depending on the timing of the updates, and whether certain update results have been
included in the summary or not.
18
Lock Management
19
Periodically check for cycles in the waits-for
graph
Database Systems
Introduction
Dr P Sreenivasa Kumar
Professor
CS&E Department
I I T Madras
Introduction
What is a Database?
A collection of related pieces of data:
▪ Representing/capturing the information about a real-world
enterprise or part of an enterprise.
▪ Collected and maintained to serve specific data management
needs of the enterprise.
▪ Activities of the enterprise are supported by the database and
continually update the database.
University Database:
Data about students, faculty, courses, research-
laboratories, course registration/enrollment etc.
Reflects the state of affairs of the academic aspects of the
university.
Purpose: To keep an accurate track of the academic
activities of the university.
An Example
Database Management System (DBMS)
A general purpose software system enabling:
▪ Creation of large disk-resident databases.
▪ Posing of data retrieval queries in a standard manner.
▪ Retrieval of query results efficiently.
▪ Concurrent use of the system by a large number of users
in a consistent manner.
▪ Guaranteed availability of data irrespective of system failures.
OS File System Storage Based Approach
• Files of records – used for data storage
• data redundancy – wastage of space
• maintaining consistency becomes difficult
• Record structures – hard coded into the programs
• structure modifications – hard to perform
• Each different data access request (a query)
20
• performed by a separate program
• difficult to anticipate all such requests
• Creating the system
• requires a lot of effort
• Managing concurrent access and failure recovery are difficult
DBMS Approach
DBMS
• separation of data and metadata
• flexibility of changing metadata
• program-data independence
Data access language
• standardized – SQL
• ad-hoc query formulation – easy
System development
• less effort required
• concentration on logical level design is enough
• components to organize data storage
process queries, manage concurrent access,
recovery from failures, manage access control
are all available
Data Model
Collection of conceptual tools to describe the database at a
certain level of abstraction.
▪ Conceptual Data Model
▪ a high level description
▪ useful for requirements understanding.
▪ Representational Data Model
▪ describing the logical representation of data
without giving details of physical representation.
▪ Physical Data Model
▪ description giving details about record formats,
file structures etc.
E/R (Entity/Relationship) Model
▪ A conceptual level data model.
▪ Provides the concepts of entities, relationships and attributes.
The University Database Context
Entities: student, faculty member, course, departments etc.
Relationships: enrollment relationship between student & course,
employment relationship between faculty
member, department etc.
Attributes: name, rollNumber, address etc., of student entity,
name, empNumber, phoneNumber etc., of faculty
thee-schema Architecture(1/2)
Logical Level Schema
21
▪ Describes the logical structure of the entire database.
▪ No physical level details are given.
Physical Level Schema
▪ Describes the physical structure of data in terms of
record formats, file structures, indexes etc.
Remarks
• Views are optional
- Can be set up if the DB system is very large and if
easily identifiable user-groups exist
• The logical scheme is essential
• Modern RDBMS’s hide details of the physical layer
Three-schema Architecture(2/2)
The ability to modify physical level schema without
affecting the logical or view level schema.
Performance tuning – modification at physical level
creating a new index etc.
Physical Data Independence – modification is localized
▪ achieved by suitably modifying PL-LL mapping.
▪ a very important feature of modern DBMS.
Physical Data Independence
Three Schema Arch
Logical Data Independence
The ability to change the logical level scheme without affecting the
view level schemes or application programs
Adding a new attribute to some relation
• no need to change the programs or views that don’t
require to use the new attribute
Deleting an attribute
• no need to change the programs or views that use
the remaining data
• view definitions in VL-LL mapping only need to be
changed for views that use the deleted attribute
.
Functional dependency
Functional dependencies are represented, associated with a particular schema,
by a set of elements found in the antecedent, and set of elements in the con-
sequent. These functional dependencies can be manipulated by application of
Armstrong’s axioms. This manipulation, as well as automatic generation of can-
didate keys, is handled by a Solver. The Solver is invoked when a user selects an
axiom to apply.
22
A functional dependency (FD) is a constraint between two sets of attributes in a relation
from a database.
A functional depending set S is irreducible if the set has following three properties:
Sets of Functional Dependencies(FD) with these properties are also called canonical or
minimal.
23
Properties of functional dependencies
Given that X, Y, and Z are sets of attributes in a relation R, one can derive several
properties of functional dependencies. Among the most important are Armstrong's
axioms, which are used in database normalization:
Equivalent sets of functional dependencies are called covers of each other. Every set of
functional dependencies has a canonical cover.
Inclusion dependencies
INDs (which can say, for example, that every manager is an
employee) are studied, including their interaction with functional dependencies, or FDs. A
simple complete axiomatization for INDs is presented, and the decision problem for INDs is
shown to be PSPACE-complete. (The decision problem for INDs is the problem of deter-
mining whether or not C logically implies u, given a set Z of INDs and a single IND u).
As an example, an inclusion
dependency can say that every MANAGER entry of the R relation appears as an
EMPLOYEE entry of the S relation. In general, an inclusion dependency is of the
form
We note that INDs differ from other commonly studied database dependencies in
two important respects. First, INDs may be interrelational, whereas the others deal
with a single relation at a time. Second, INDs are not typed [Fa4]; they are special
cases of extended embedded implicational dependencies [Fa4], for which the
existence of “Armstrong-like databases” have been proven. We show that INDs have a
simple complete axiomatization. However, we also
show the rather surprising fact that the decision problem for INDs
24
These commands are used to append, change or remove the data in a Table.
COMMIT/ROLLBACK statement should be given to make the changes permanent or to
revert back.
2.2.1 INSERT
Using this command we can append data into tables.
Syntax
INSERT INTO <table name>(<column_name1>, <column_name2>, ...)
VALUES (column1_value, column2_value, ...);
INSERT INTO <table-name>(<column_name2>, <column_name1>, ...)
VALUES (column2-value, column1-value, ...);
INSERT INTO <table-name> VALUES (value1, value2, ...);
Example
INSERT INTO Employee(empno, ename, salary, hire_date, gender, email)
VALUES(1234, ‘JOHN’, 8000, ’18-AUG-80, ‘M’, ‘john@miraclesoft.com’);
INSERT INTO Employee(email , ename, empno, hire_date, gender, salary)
VALUES(‘rhonda@miraclesoft.com’, ‘RHONDA’, 1235, ’24-JUL-81’, ‘F’, 7500);
INSERT INTO Employee
VALUES(1236, ‘JACK’, 15000, ’23-SEP-79’, ‘m’, ‘jack@miraclesoft.com’);
4
2.2.2 UPDATE
This command is used to modify the data existing in the tables.
Syntax
UPDATE <table-name> SET <column-name> = <value>;
UPDATE <table-name> SET <column-name> = <value> WHERE <condition>;
Example
UPDATE Employee SET salary = 15000;
UPDATE employee SET salary = 15000 WHERE empno = 1235;
2.2.3 DELETE
This command is used to remove the data from the tables.
Syntax
DELETE FROM <table-name>;
DELETE FROM <table-name>WHERE <condition>;
Example
DELETE FROM Employee;
DELETE FROM Employee WHERE empno = 1236
Oracle Forms
Oracle Forms is a software product for creating screens that interact with an Oracle
database. It has an IDE including an object navigator, property sheet and code editor that
uses PL/SQL. It was originally developed to run server-side in character mode terminal
sessions. It was ported to other platforms, including Windows, to function in a client–
server environment. Later versions were ported to Java where it runs in a Java EE
container and can integrate with Java and web services.
The primary focus of Forms is to create data entry systems that access an Oracle database
Oracle Forms accesses the Oracle database and generates a screen that presents the data.
The source form (*.fmb) is compiled into an "executable" (*.fmx), that is run
(interpreted) by the forms runtime module. The form is used to view and edit data in
25
database-driven applications. Various GUI elements, such as buttons, menus, scrollbars,
and graphics can be placed on the form.
The environment supplies built-in record creation, query, and update modes, each with its
own default data manipulations. This minimizes the need to program common and
tedious operations, such as creating dynamic SQL, sensing changed fields, and locking
rows.
As a result of this strategy, it is possible to create a number of default form layouts which
possess complete database functionality yet contain no programmer-written code at all.
History
Oracle Forms is sold and released separately from the Oracle database. However, major
releases of an Oracle database usually result in a new major version of Oracle Forms to
support new features in the database.
HOW IT WOKS
Oracle Forms accesses the Oracle database and generates a screen that presents the data.
The source form (*.fmb) is compiled into an "executable" (*.fmx), that is run
(interpreted) by the forms runtime module. The form is used to view and edit data in
database-driven applications. Various GUI elements, such as buttons, menus, scrollbars,
and graphics can be placed on the form.
The environment supplies built-in record creation, query, and update modes, each with its
own default data manipulations. This minimizes the need to program common and
tedious operations, such as creating dynamic SQL, sensing changed fields, and locking
rows.
26
Each trigger function is initially a stub, containing a default action or nothing.
Programming Oracle Forms therefore generally consists of modifying the contents of
these triggers in order to alter the default behavior. Some triggers, if provided by the
programmer, replace the default action while others augment it.
As a result of this strategy, it is possible to create a number of default form layouts which
possess complete database functionality yet contain no programmer-written code at all.
The first version of Oracle Forms was named Interactive Application Facility (IAF). This
had two main components, the compiler (Interactive Application Generator - IAG) and
the runtime interpreter (Interactive Application Processor - IAP). This provided a
character mode interface to allow users to enter and query data from an Oracle database.
IAF was released with Oracle Database Version 2, the first commercial version of Oracle.
It was renamed to FastForms with Oracle Database version 4 and added an additional
tool to help generate a default form to edit with standard tool (IAG).
Oracle Forms 2.3 was character based, and did not use PL/SQL. The source file was an
*.INP ASCII file. It was common for developers to edit the INP file directly although that
was not supported by Oracle. This version used its own primitive and unfriendly built-in
language, augmented by user exits—compiled language code linked to the binary of the
Oracle-provided run-time
Oracle Forms 3 was character based, and was the first real version of Forms, using
PL/SQL. All subsequent versions are a development of this version. It could run under X
but did not support any X interface specific features such as checkboxes. The source file
was an *.INP ASCII file. The IDE was vastly improved from 2.3 which dramatically
decreased the need to edit the INP file directly, although this was still a common practice.
Forms 3 automatically generated triggers and code to support some database constraints.
Constraints could be defined, but not enforced in the Oracle 6 database at this time, so
Oracle used Forms 3 to claim support for enforcing constraints.
There was a "GUI" version of Forms 3 which could be run in environments such as X
Window, but not Microsoft Windows. This had no new trigger types, which made it
difficult to attach PL/SQL to GUI events such as mouse movements.
Oracle Forms version 4.0 was the first "true" GUI based version. A character based
runtime was still available for certain customers on request. The arrival of Microsoft
Windows 3 forced Oracle to release this GUI version of Forms for commercial reasons.
Forms 4.0 accompanied Oracle version 6 with support for Microsoft Windows and X
27
Window. This version was notoriously buggy and introduced an IDE that was unpopular
with developers. This version was not used by the Oracle Financials software suite. The
4.0 source files were named *.FMB and were binary.
Oracle Forms version 4.5 was really a major release rather than a "point release" of 4.0
despite its ".5" version number. It contained significant functional changes and a brand
new IDE, replacing the unpopular IDE introduced in 4.0. It is believed to be named 4.5 in
order to meet contractual obligations to support Forms 4 for a period of time for certain
clients. It added GUI-based triggers, and provided a modern IDE with an object
navigator, property sheets and code editor.
Forms 6 was released with Oracle 8.0 database; it was rereleased as Forms 6i with Oracle
8i. This was basically Forms 4.5 with some extra wizards and bug-fixes. But it also
included the facility to run inside a web server. A Forms Server was supplied which
solved the problem of adapting Oracle Forms to a three-tier, browser-based delivery,
without incurring major changes in its programmatic interface. The complex, highly
interactive form interface was provided by a Java applet which communicated directly
with the Forms server. However the web version did not work very well over HTTP. A
fix from Forms 9i was retrofitted to later versions of 6i to address this.
The naming and numbering system applied to Oracle Forms underwent several changes
due to marketing factors, without altering the essential nature of the product. The ability
to code in Java, as well as PL/SQL, was added in this period.
Forms 9i included many bug fixes to 6i and was a stable version. But it did not include
either client–server or character-based interfaces, and three-tier, browser-based delivery
is the only deployment choice from here on. The ability to import java classes means that
it can act as a web service client.
Forms 10g is actually Forms version 9.0.4, so is merely a rebadged forms 9i.
Forms 11 will include some new features, relying on Oracle AQ to allow it to interact
with JM
28
Oracle Forms for Oracle Applications
DBMS Function
1. Data Dictionary Management
2. Data Storage Management
3. Data Transformation and Presentation
4. Security Management
5. Multi-User Access Control
6. Backup and Recovery Management
7. Data Integrity Management
8. Database Access Languages and
Application Programming Interfaces
9. Database Communication Interfaces
Database Model
16
Copyright © 2004 R.M. Laurie
17
29
EMPLOYEE (1) manages STORE (1)
Copyright © 2004 R.M. Laurie
18
Hierarchical Database❖Advantages
◆ Conceptual simplicity – Relationships defined
◆ Database security – Uniform throughout system
◆ Data independence – Data type cascaded
◆ Database integrity – Child referenced to parent
◆ Efficiency – Parent to Child (One to Many)
❖Disadvantages
◆ Complex implementation
◆ Difficultto manage
◆ Lacks structural independence
◆ Applications programming and use is complex
◆ Implementation limitations (Many to Many)
◆ Lack of standards
21
30
overhead
◆ Possibility of poor design and implementation
◆ Potential “islands of information” = local DB
Copyright © 2004 R.M. Laurie
Figure 1.11
Copyright © 2004 R.M. Laurie
22
31
Figure 1.15: A Comparison: The OO Data Model and the ER Model
Copyright © 2004 R.M. Laurie
28
Normal forms
The normal forms (abbrev. NF) of relational database theory provide criteria for
determining a table's degree of vulnerability to logical inconsistencies and anomalies. The
higher the normal form applicable to a table, the less vulnerable it is to inconsistencies
and anomalies. Each table has a "highest normal form" (HNF): by definition, a table
always meets the requirements of its HNF and of all normal forms lower than its HNF;
also by definition, a table fails to meet the requirements of any normal form higher than
its HNF.
The normal forms are applicable to individual tables; to say that an entire database is in
normal form n is to say that all of its tables are in normal form n.
32
Second normal E.F. Codd (1971)[12] No non-prime attribute in the table
form (2NF) is functionally dependent on a
proper subset of a candidate key
Third normal E.F. Codd (1971)[13]; see +also Every non-prime attribute is non-
form (3NF) Carlo Zaniolo's equivalent but transitively dependent on every
differently-expressed definition candidate key in the table
(1982)[14]
Boyce–Codd Raymond F. Boyce and E.F. Every non-trivial functional
normal form Codd (1974)[15] dependency in the table is a
(BCNF) dependency on a superkey
Fourth normal Ronald Fagin (1977)[16] Every non-trivial multivalued
form (4NF) dependency in the table is a
dependency on a superkey
Fifth normal Ronald Fagin (1979)[17] Every non-trivial join dependency
form (5NF) in the table is implied by the
superkeys of the table
Domain/key Ronald Fagin (1981)[18] Every constraint on the table is a
normal form logical consequence of the table's
(DKNF) domain constraints and key
constraints
Sixth normal C.J. Date, Hugh Darwen, and Table features no non-trivial join
form (6NF) Nikos Lorentzos (2002)[4] dependencies at all (with reference
to generalized join operator)
Anomaly
When an attempt is made to modify (update, insert into, or delete from) a table, undesired
side-effects may follow. Not all tables can suffer from these side-effects; rather, the side-
effects can only arise in tables that have not been sufficiently normalized. An
insufficiently normalized table might have one or more of the following characteristics:
• The same information can be expressed on multiple rows; therefore updates to the
table may result in logical inconsistencies. For example, each record in an
"Employees' Skills" table might contain an Employee ID, Employee Address, and
Skill; thus a change of address for a particular employee will potentially need to
be applied to multiple records (one for each of his skills). If the update is not
carried through successfully—if, that is, the employee's address is updated on
some records but not others—then the table is left in an inconsistent state.
Specifically, the table provides conflicting answers to the question of what this
particular employee's address is. This phenomenon is known as an update
anomaly.
• There are circumstances in which certain facts cannot be recorded at all. For
example, each record in a "Faculty and Their Courses" table might contain a
33
Faculty ID, Faculty Name, Faculty Hire Date, and Course Code—thus we can
record the details of any faculty member who teaches at least one course, but we
cannot record the details of a newly-hired faculty member who has not yet been
assigned to teach any courses except by setting the Course Code to null. This
phenomenon is known as an insertion anomaly.
• There are circumstances in which the deletion of data representing certain facts
necessitates the deletion of data representing completely different facts. The
"Faculty and Their Courses" table described in the previous example suffers from
this type of anomaly, for if a faculty member temporarily ceases to be assigned to
any courses, we must delete the last of the records on which that faculty member
appears, effectively also deleting the faculty member. This phenomenon is known
as a deletion anomaly
34
35
Mapping Constraints
An E-R scheme may define certain constraints to which the contents of a database must
conform.
For example,
ER diagram
36
(ER diagram)
37
The Entity-Relationship (ER) Diagram. One of the key techniques in ER modeling is to document the
entity and relationship types in a graphical form called, Entity-Relationship (ER) diagram. Figure 2 is a
typical ER diagram. The entity types such as EMP and PROJ are depicted as rectangular boxes, and the
relationship types such as WORK-FOR are depicted as a diamond-shaped box. The value sets (domains)
such as EMP#, NAME, and PHONE are depicted as circles, while attributes are the “mappings” from entity
and relationships types to the value sets. The cardinality information of relationship is also expressed. For
example, the “1” or “N” on the lines between the entity types and relationship types indicated the upper
limit of the entities of that entity type participating in that relationships.
Fig. 2. An Entity-Relationship (ER) Diagram
ER Model is based on Strong Mathematical Foundations. The ER model is based on (1) Set Theory,
(2) Mathematical Relations, (3) Modern Algebra, (4) Logic, and (5) Lattice Theory. A formal definition of
the entity and relationship concepts can be found in Fig. 3.
Fig. 3. Formal Definitions of Entity and Relationship Concepts
38
“entities.” In the relational model, a Cartesian product of data “domains” is a “relation,” while in the ER
model a Cartesian product of “entities” is a “relationships.” In other words, in the relational model the
mathematical relation construct is used to express the “structure of data values,” while in the ER model the
same construct is used to express the “structure of entities.”
ER Model Contains More Semantic Information than the Relational Model. By the original definition of
relation by Codd, any table is a relation. There is very little in the semantics of what a relation is or should
be. The ER model adds the semantics of data to a data structure. Several years later, Codd developed a
data model called RM/T, which incorporated some of the concepts of the ER model.
ER Model has Explicit Linkage between Entities. As can be seen in Figures 2 and 4, the linkage between
entities is explicit in the ER model while in the relational model is implicit. In addition, the cardinality
information is explicit in the ER model, and some of the cardinality information is not captured in the
relational model
39
data element with the entities and relationships defined in the ERD. Together, these three
documents form a complete conceptual data model for e-resource management.
Understanding the Model
There are several different modeling systems for entity relationship diagramming. This
ERD is presented in the “Information Engineering” style. Those unfamiliar with entity
relationship diagramming or unfamiliar with this style of notation may wish to consult
the following section to clarify the diagramming symbology
Relational Algebra
Steps in Building and Using a Database
1. Design schema
2. Create schema in DBMS
3. Load initial data
4. Repeat: execute queries and updates on the database
Database Query Languages
What is a query?
Given a database, ask questions, get answers
Example: get all students who are now taking CS145
Example (from the TPC-D benchmark):
“The Volume Shipping Query finds, for two given nations, the gross discounted revenues derived from lineitems in which parts were
shipped from a supplier in either nation to a customer in the other nation during 1995 and 1996. The query lists the supplier nation, the
customer nation, the year, and the revenue from shipments that took place in that year. The query orders the answer by supplier nation,
customer nation, and year (all ascending).”
40
What is a relational query?
Input: a number of relations in your database
Output: one relation as the answer
Relational Algebra
Basic operators: selection, projection, cross product, union, difference,
and renaming
Additional operators (can be defined using basic ones): theta-join,
natural join, intersection, etc.
Operands: relations
Input relation(s) operator output relation
Jun Yang 1 CS145 Spring 1999
Example:
Student(SID, name, age, GPA)
Take(SID, CID)
Course(CID, title)
Selection
Notation:
Purpose: pick rows according to some criteria
Input: a table
Output: has the same columns as , but only the rows of that satisfy
Example: the student with SID 123
Example: students with GPA higher than 3.0
Example: straight-A students under 18 or over 21
The selection predicate in general can include any columns of , constants,
comparisons such as , , etc., and Boolean connectives (and),
(or), (not)
Projection
Notation:
Purpose: pick columns to output
Input: a table
Output: has only the columns of listed in
Example: SID’s and names of all students
Example: SID’s of students taking classes
Notice the elimination of duplicate rows
Example of composing and : names of students under 18
Jun Yang 2 CS145 Spring 1999
Product and Joins
Cross Product
Notation:
Purpose: pair rows from two tables
Input: two tables and
Output: for each row in and each row in , output a row ; the output
table has the columns of and the columns of
41
Example: Student Take
If column names conflict, prefix the names with the table name and a dot
Looks odd to glue unrelated tuples together; why use then?
Example: names of students and CID’s of the courses they are taking
Theta-Join
Notation:
Purpose: relate rows from two tables according to some criteria
Shorthand for:
Example: names of students and CID’s of the courses they are taking
Natural Join
Notation:
Atomicity
42
In database systems, atomicity (or atomicness) is one of the ACID transaction properties.
In an atomic transaction, a series of database operations either all occur, or nothing
occurs. ... Atomicity – All database modifications must follow an “all or nothing” rule in which each
transaction is “atomic.” That means that if one part of the transaction fails, the entire
transaction fails. No splitting of atoms allowed! It is critical that the database
management system maintain the atomic nature of transactions in spite of any DBMS,
operating system or hardware failure
43