CS2255 Notes
Transcript of CS2255 Notes
-
8/12/2019 CS2255 Notes
1/45
ww
w.5st
arnot
es.co
m CS 2255 DATABASE MANAGEMENT SYSTEMS
UNIT1. INTRODUCTION
A databaseis a structured collection of data. The data are typically organized to model relevant
aspects of reality (for example, the availability of rooms in hotels), in a way that supports
processes requiring this information (for example, finding a hotel with vacancies).
The term databaseis correctly applied to the data and their supporting data structures, and not to
the database management system (DBMS). The database data collection with DBMS is called a
database system.
The term database systemimplies that the data are managed to some level of quality (measured
in terms of accuracy, availability, usability, and resilience) and this in turn often implies the use
of a general-purpose database management system (DBMS).[1]
A general-purpose DBMS is
typically a complex software system that meets many usage requirements to properly maintain
its databases which are often large and complex.
This is specially the case with client-server, near-real time transactional systems, in which
multiple users have access to data, data is concurrently entered and inquired for in ways that
preclude single-thread batch processing. Most of the complexity of those requirements are still
present with personal, desktop-based database systems.
Well known DBMSs include Oracle, FoxPro, IBM DB2, Linter, Microsoft Access, Microsoft
SQL Server, MySQL,PostgreSQL and SQLite. A database is not generally portable across
different DBMS, but different DBMSs can inter-operate to some degree by using standards like
SQL and ODBC together to support a single application built over more than one database. A
DBMS also needs to provide effective run-time execution to properly support (e.g., in terms of
performance, availability, and security) as many database end-users as needed.
A way to classify databases involves the type of their contents, for example: bibliographic,
document-text, statistical, or multimedia objects. Another way is by their application area, for
example: accounting, music compositions, movies, banking, manufacturing, or insurance.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Bibliographic_databasehttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Bibliographic_databasehttp://en.wikipedia.org/wiki/End-userhttp://en.wikipedia.org/wiki/Securityhttp://en.wikipedia.org/wiki/Availabilityhttp://en.wikipedia.org/wiki/IT_Performance_Managementhttp://en.wikipedia.org/wiki/Run_time_%28program_lifecycle_phase%29http://en.wikipedia.org/wiki/ODBChttp://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Technical_standardhttp://en.wikipedia.org/wiki/Interoperationhttp://en.wikipedia.org/wiki/Software_portabilityhttp://en.wikipedia.org/wiki/SQLitehttp://en.wikipedia.org/wiki/PostgreSQLhttp://en.wikipedia.org/wiki/MySQLhttp://en.wikipedia.org/wiki/Microsoft_SQL_Serverhttp://en.wikipedia.org/wiki/Microsoft_SQL_Serverhttp://en.wikipedia.org/wiki/Microsoft_Accesshttp://en.wikipedia.org/wiki/Linter_SQL_RDBMShttp://en.wikipedia.org/wiki/IBM_DB2http://en.wikipedia.org/wiki/FoxProhttp://en.wikipedia.org/wiki/Oracle_Databasehttp://en.wikipedia.org/wiki/Computer_softwarehttp://en.wikipedia.org/wiki/Database#cite_note-Ullman-1http://en.wikipedia.org/wiki/Accuracy#In_information_systemshttp://en.wikipedia.org/wiki/Database_systemhttp://en.wikipedia.org/wiki/Database_management_systemhttp://en.wikipedia.org/wiki/Data_structures -
8/12/2019 CS2255 Notes
2/45
ww
w.5st
arnot
es.co
mThe term databasemay be narrowed to specify particular aspects of organized collection of data
and may refer to the logical database, to the physical database as data content in computer data
storage or to many other database sub-definitions.
Purpose of Database System
A DBMS has evolved into a complex software system and its development typically requires
thousands of person-years of development effort. Some general-purpose DBMSs, like Oracle,
Microsoft SQL Server, FoxPro, and IBM DB2, have been undergoing upgrades for thirty years
or more. General-purpose DBMSs aim to satisfy as many applications as possible, which
typically makes them even more complex than special-purpose databases. However, the fact that
they can be used "off the shelf", as well as their amortized cost over many applications and
instances, makes them an attractive alternative (Vs. one-time development) whenever they meet
an application's requirements.
Though attractive in many cases, a general-purpose DBMS is not always the optimal solution:
When certain applications are pervasive with many operating instances, each with many users, a
general-purpose DBMS may introduce unnecessary overhead and too large "footprint" (too large
amount of unnecessary, unutilized software code). Such applications usually justify dedicated
development. Typical examples are email systems, though they need to possess certain DBMSproperties: email systems are built in a way that optimizes email messages handling and
managing, and do not need significant portions of a general-purpose DBMS functionality.
Views of data
In database theory, a viewconsists of a stored[clarify]
query accessible as a virtual[clarify]
table in a
relational database or a set of documents in a document-oriented database composed of the result
set of a query or map-and-reduce functions. Unlike ordinary tables (base tables) in a relational
database, a view does not form part of the physical schema: it is a dynamic, virtual table
computed or collated from data in the database. Changing the data in a table alters the data
shown in subsequent invocations of the view. In someNoSQL databases views are the only way
to query data.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/NoSQLhttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/NoSQLhttp://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Database_designhttp://en.wikipedia.org/wiki/Fold_%28higher-order_function%29http://en.wikipedia.org/wiki/Map_%28higher-order_function%29http://en.wikipedia.org/wiki/Query_languagehttp://en.wikipedia.org/wiki/Result_sethttp://en.wikipedia.org/wiki/Result_sethttp://en.wikipedia.org/wiki/Document-oriented_databasehttp://en.wikipedia.org/wiki/Document-oriented_database#Documentshttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Wikipedia:Please_clarifyhttp://en.wikipedia.org/wiki/Database_queryhttp://en.wikipedia.org/wiki/Wikipedia:Please_clarifyhttp://en.wikipedia.org/wiki/Database_theoryhttp://en.wikipedia.org/wiki/Emailhttp://en.wikipedia.org/wiki/Computer_data_storagehttp://en.wikipedia.org/wiki/Computer_data_storage -
8/12/2019 CS2255 Notes
3/45
ww
w.5st
arnot
es.co
mViews can provide advantages over tables:
Views can represent a subset of the data contained in a table
Views can join and simplify multiple tables into a single virtual table
Views can act as aggregated tables, where the database engine aggregates data (sum,
average etc.) and presents the calculated results as part of the data
Views can hide the complexity of data; for example a view could appear as Sales2000 or
Sales2001, transparently partitioning the actual underlying table
Views take very little space to store; the database contains only the definition of a view,
not a copy of all the data it presents
Depending on the SQL engine used, views can provide extra security
Views can limit the degree of exposure of a table or tables to the outer world
Just as functions (in programming) can provide abstraction, so database users can create
abstraction by using views. In another parallel with functions, database users can manipulate
nested views, thus one view can aggregate data from other views. Without the use of views the
normalization of databases above second normal form would become much more difficult.
Views can make it easier to create lossless join decomposition.
Just as rows in a base table lack any defined ordering, rows available through a view do notappear with any default sorting. A view is a relational table, and the relational model defines a
table as a set of rows. Since sets are not ordered - by definition - the rows in a view are not
ordered, either. Therefore, an ORDER BY clause in the view definition is meaningless. The SQL
standard (SQL:2003) does not allow an ORDER BY clause in a subselect[clarify]
in a CREATE
VIEW statement, just as it is not allowed in a CREATE TABLE statement. However, sorted data
can be obtained from a view, in the same way as any other table - as part of a query statement.
Nevertheless, some DBMS (such as Oracle Database and SQL Server[ambiguous]
) allow a view to
be created with an ORDER BY clause in a subquery, affecting how data is displayed.
Data models A data model is an abstract structure that provides the means to effectively
describe specific data structures needed to model an application. As such a data model needs
sufficient expressive power to capture the needed aspects of applications. These applications are
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Wikipedia:Disambiguationhttp://en.wikipedia.org/wiki/Oracle_Databasehttp://en.wikipedia.org/wiki/Statement_%28programming%29http://en.wikipedia.org/wiki/Wikipedia:Please_clarifyhttp://en.wikipedia.org/wiki/SQL:2003http://en.wikipedia.org/wiki/Order_by_%28SQL%29http://en.wikipedia.org/wiki/Row_%28database%29http://en.wikipedia.org/wiki/Second_normal_formhttp://en.wikipedia.org/wiki/Abstraction_%28computer_science%29http://en.wikipedia.org/wiki/Function_%28computing%29http://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Partition_%28database%29http://en.wikipedia.org/wiki/Averagehttp://en.wikipedia.org/wiki/Sumhttp://en.wikipedia.org/wiki/Database_enginehttp://en.wikipedia.org/wiki/Join_%28SQL%29 -
8/12/2019 CS2255 Notes
4/45
ww
w.5st
arnot
es.co
moften typical to commercial companies and other organizations (like manufacturing, human-
resources, stock, banking, etc.). For effective utilization and handling it is desired that a data
model is relatively simple and intuitive. This may be in conflict with high expressive power
needed to deal with certain complex applications. Thus any popular general-purpose data model
usually well balances between being intuitive and relatively simple, and very complex with high
expressive power. The application's semantics is usually not explicitly expressed in the model,
but rather implicit (and detailed by documentation external to the model) and hinted to by data
item types' names (e.g., "part-number") and their connections (as expressed by generic data
structure types provided by each specific model).
Hierarchical model
In the Hierarchical model different record types (representing real-world entities) are embedded
in a predefined hierarchical (tree-like) structure. This hierarchy is used as the physical order of
records in storage. Record access is done by navigating through the data structure using pointers
combined with sequential accessing.
This model has been supported primarily by the IBM IMS DBMS, one of the earliest DBMSs.
Various limitations of the model have been compensated at later IMS versions by additional
logical hierarchies imposed on the base physical hierarchy.
Network model
In this model a hierarchical relationship between two record types (representing real-world
entities) is established by the set construct. A set consists of circular linked lists where one
record type, the set owner or parent, appears once in each circle, and a second record type, the
subordinate or child, may appear multiple times in each circle. In this way a hierarchy may be
established between any two record types, e.g., type A is the owner of B. At the same time
another set may be defined where B is the owner of A. Thus all the sets comprise a general
directed graph (ownership defines a direction), or networkconstruct. Access to records is either
sequential (usually in each record type) or by navigation in the circular linked lists.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Directed_graphhttp://en.wikipedia.org/wiki/Linked_listhttp://en.wikipedia.org/wiki/Information_Management_Systemhttp://en.wikipedia.org/wiki/Pointer_%28computer_programming%29http://en.wikipedia.org/wiki/Tree_%28data_structure%29 -
8/12/2019 CS2255 Notes
5/45
ww
w.5st
arnot
es.co
mThis model is more general and powerful than the hierarchical, and has been the most popular
before being replaced by the Relational model. It has been standardized by CODASYL. Popular
DBMS products that utilized it were Cincom Systems' Total and Cullinet's IDMS. IDMS gained
a considerable customer base and exists and supported until today. In the 1980s it has adopted
the Relational model and SQL in addition to its original tools and languages.
An inverted fileor inverted indexof a first file, by a field in this file (the inversion field), is a
second file in which this field is the key. A record in the second file includes a key and pointers
to records in the first file where the inversion field has the value of the key. This is also the
logical structure of contemporary database indexes. The related Inverted file data modelutilizes
inverted files of primary database files to efficiently directly access needed records in these files.
Notable for using this data model is the ADABAS DBMS of Software AG, introduced in 1970.
ADABAS has gained considerable customer base and exists and supported until today. In the
1980s it has adopted the Relational model and SQL in addition to its original tools and
languages.
Relational model
The relational model is a simple model that provides flexibility. It organizes data based on two-
dimensional arrays known as relations, or tables as related to databases. These relations consist
of a heading and a set of zero or more tuples in arbitrary order. The heading is an unordered set
of zero or more attributes, or columns of the table. The tuples are a set of unique attributes
mapped to values, or the rows of data in the table. Data can be associated across multiple tables
with a key. A key is a single, or set of multiple, attribute(s) that is common to both tables. The
most common language associated with the relational model is the Structured Query Language
(SQL), though it differs in some places.
Entity-relationship model
been applied in areas such as engineering and spatial databases, telecommunications and in
various scientific domains. The conglomeration of object oriented programming and database
technology led to this new kind of database. These databases attempt to bring the database world
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Tuple#Relational_modelhttp://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Software_AGhttp://en.wikipedia.org/wiki/ADABAShttp://en.wikipedia.org/wiki/Index_%28database%29http://en.wikipedia.org/wiki/Inverted_indexhttp://en.wikipedia.org/wiki/IDMShttp://en.wikipedia.org/wiki/Cullinethttp://en.wikipedia.org/wiki/Cincom_Systemshttp://en.wikipedia.org/wiki/CODASYLhttp://en.wikipedia.org/wiki/Standardization -
8/12/2019 CS2255 Notes
6/45
ww
w.5st
arnot
es.co
mand the application-programming world closer together, in particular by ensuring that the
database uses the same type system as the application program. This aims to avoid the overhead
(sometimes referred to as the impedance mismatch) of converting information between its
representation in the database (for example as rows in tables) and its representation in the
application program (typically as objects). At the same time, object databases attempt to
introduce key ideas of object programming, such as encapsulation and polymorphism, into the
world of databases.
A variety of these ways have been tried[by whom?]
for storing objects in a database. Some products
have approached the problem from the application-programming side, by making the objects
manipulated by the program persistent. This also typically requires the addition of some kind of
query language, since conventional programming languages do not provide language-levelfunctionality for finding objects based on their information content. Others
[which?]have attacked
the problem from the database end, by defining an object-oriented data model for the database,
and defining a database programming language that allows full programming capabilities as well
as traditional query facilities.
Object relati onal model
the relational model are sometimes classified as post-relational.
[7]
Alternate terms include"hybrid database", "Object-enhanced RDBMS" and others. The data model in such products
incorporates relations but is not constrained by E.F. Codd's Information Principle, which requires
that
all information in the database must be cast explicitly in terms of values in relations and in no
other way
Some of these extensions to the relational model integrate concepts from technologies that pre-
date the relational model. For example, they allow representation of a directed graph with trees
on the nodes. The German companysonesimplements this concept in its GraphDB.
Some post-relational products extend relational systems with non-relational features. Others
arrived in much the same place by adding relational features to pre-relational systems.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/GraphDBhttp://en.wikipedia.org/wiki/Tree_data_structurehttp://en.wikipedia.org/wiki/E.F._Coddhttp://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Database#cite_note-CONR-7http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_wordshttp://en.wikipedia.org/wiki/Persistence_%28computer_science%29http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_wordshttp://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29http://en.wikipedia.org/wiki/Encapsulation_%28computer_science%29http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatchhttp://en.wikipedia.org/wiki/Type_system -
8/12/2019 CS2255 Notes
7/45
ww
w.5st
arnot
es.co
mParadoxically, this allows products that are historically pre-relational, such as PICK and
MUMPS, to make a plausible claim to be post-relational.
The resource space model (RSM) is a non-relational data model based on multi-dimensional
classification.
Database languages
Database languages are dedicated programming languages, tailored and utilized to
define a database (i.e., its specific data types and the relationships among them),
manipulate its content (e.g., insert new data occurrences, and update or delete existing
ones), and
query it (i.e., request information: compute and retrieve any information based on its
data).
Database languages are data-model-specific, i.e., each language assumes and is based on a
certain structure of the data (which typically differs among different data models). They typically
have commands to instruct execution of the desired operations in the database. Each such
command is equivalent to a complex expression (program) in a regular programming language,
and thus programming in dedicated (database) languages simplifies the task of handling
databases considerably. An expressions in a database language is automatically transformed (by
a compiler or interpreter, as regular programming languages) to a proper computer program that
runs while accessing the database and providing the needed results. The following are notable
examples:
SQL for the Relati onal model
A major Relational model language supported by all the relational DBMSs and a standard.
SQL was one of the first commercial languages for the relational model. Despite not adhering to
the relational model as described by Codd, it has become the most widely used database
language.[10][11]
Though often described as, and to a great extent is adeclarative language,SQL
also includesprocedural elements. SQL became astandard of theAmerican National Standards
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Codd%27s_12_ruleshttp://en.wikipedia.org/wiki/Database#cite_note-SQL-Fundamentals-10http://en.wikipedia.org/wiki/Database#cite_note-SQL-Fundamentals-10http://en.wikipedia.org/wiki/Database#cite_note-SQL-Fundamentals-10http://en.wikipedia.org/wiki/Declarative_programminghttp://en.wikipedia.org/wiki/Procedural_programminghttp://en.wikipedia.org/wiki/Technical_standardhttp://en.wikipedia.org/wiki/American_National_Standards_Institutehttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/American_National_Standards_Institutehttp://en.wikipedia.org/wiki/Technical_standardhttp://en.wikipedia.org/wiki/Procedural_programminghttp://en.wikipedia.org/wiki/Declarative_programminghttp://en.wikipedia.org/wiki/Database#cite_note-SQL-Fundamentals-10http://en.wikipedia.org/wiki/Database#cite_note-SQL-Fundamentals-10http://en.wikipedia.org/wiki/Codd%27s_12_ruleshttp://en.wikipedia.org/wiki/Compilerhttp://en.wikipedia.org/wiki/MUMPShttp://en.wikipedia.org/wiki/Pick_operating_system -
8/12/2019 CS2255 Notes
8/45
ww
w.5st
arnot
es.co
mInstitute (ANSI) in 1986, and of the International Organization for Standards (ISO) in 1987.
Since then the standard has been enhanced several times with added features. However, issues of
SQL code portability between major RDBMS products still exist due to lack of full compliance
with, or different interpretations of the standard. Among the reasons mentioned are the large size,
and incomplete specification of the standard, as well as vendor lock-in.
OQL for the Object model
An object model language standard (by the Object Data Management Group) that has influenced
the design of some of the newer query languages like JDOQL and EJB QL, though they cannot
be considered as different flavors of OQL.
XQuery for the XM L model
XQuery is an XML based database language (also named XQL). SQL/XML combines XQuery
and XML with SQL.
Database System Architecture
Database architecture (to be distinguished from DBMS architecture; see below) may be viewed,
to some extent, as an extension of data modeling. It is used to conveniently answer requirements
of different end-users from a same database, as well as for other benefits. For example, a
financial department of a company needs the payment details of all employees as part of the
company's expenses, but not other many details about employees, that are the interest of the
human resources department. Thus different departments need different viewsof the company's
database, that both include the employees' payments, possibly in a different level of detail (and
presented in different visual forms). To meet such requirement effectively database architecture
consists of three levels: external, conceptualand internal. Clearly separating the three levels was
a major feature of the relational database model implementations that dominate 21st century
databases.[13]
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Database#cite_note-date31-13http://en.wikipedia.org/wiki/Human_resourceshttp://en.wikipedia.org/wiki/Data_modelinghttp://en.wikipedia.org/wiki/Database#DBMS_architecture:_major_DBMS_componentshttp://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/XQueryhttp://en.wikipedia.org/wiki/SQL/XMLhttp://en.wikipedia.org/wiki/XQLhttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/XQueryhttp://en.wikipedia.org/wiki/EJB_QLhttp://en.wikipedia.org/w/index.php?title=JDOQL&action=edit&redlink=1http://en.wikipedia.org/wiki/Object_Data_Management_Grouphttp://en.wikipedia.org/wiki/Object_databasehttp://en.wikipedia.org/wiki/Vendor_lock-inhttp://en.wikipedia.org/wiki/International_Organization_for_Standardshttp://en.wikipedia.org/wiki/American_National_Standards_Institute -
8/12/2019 CS2255 Notes
9/45
ww
w.5st
arnot
es.co
mThe external level defines how each end-user type understands the organization of its
respective relevant data in the database, i.e., the different needed end-user views. A single
database can have any number of views at the external level.
The conceptual level unifies the various external views into a coherent whole, global
view.[13]
It provides the common-denominator of all the external views. It comprises all
the end-user needed generic data, i.e., all the data from which any view may be
derived/computed. It is provided in the simplest possible way of such generic data, and
comprises the back-bone of the database. It is out of the scope of the various database
end-users, and serves database application developers and defined by database
administrators that build the database.
The Internal level (or Physical level) is as a matter of fact part of the database
implementation inside a DBMS (see Implementation section below). It is concerned with
cost, performance, scalability and other operational matters. It deals with storage layout
of the conceptual level, provides supporting storage-structures like indexes, to enhance
performance, and occasionally stores data of individual views (materialized views),
computed from generic data, if performance justification exists for such redundancy. It
balances all the external views' performance requirements, possibly conflicting, in
attempt to optimize the overall database usage by all its end-uses according to the
database goals and priorities.
All the three levels are maintained and updated according to changing needs by database
administrators who often also participate in the database design.
The above three-level database architecture also relates to and being motivated by the concept of
data independencewhich has been described for long time as a desired database property and
was one of the major initial driving forces of the Relational model. In the context of the above
architecture it means that changes made at a certain level do not affect definitions and software
developed with higher level interfaces, and are being incorporated at the higher level
automatically. For example, changes in the internal level do not affect application programs
written using conceptual level interfaces, which saves substantial change work that would be
needed otherwise.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Data_independencehttp://en.wikipedia.org/wiki/Materialized_viewhttp://en.wikipedia.org/wiki/Index_%28database%29http://en.wikipedia.org/wiki/Database#cite_note-date31-13 -
8/12/2019 CS2255 Notes
10/45
ww
w.5st
arnot
es.co
mIn summary, the conceptual is a level of indirection between internal and external. On one hand
it provides a common view of the database, independent of different external view structures,
and on the other hand it is uncomplicated by details of how the data are stored or managed
(internal level). In principle every level, and even every external view, can be presented by a
different data model. In practice usually a given DBMS uses the same data model for both the
external and the conceptual levels (e.g., relational model). The internal level, which is hidden
inside the DBMS and depends on its implementation (see Implementation section below),
requires a different level of detail and uses its own data structure types, typically different in
nature from the structures of the external and conceptual levels which are exposed to DBMS
users (e.g., the data models above): While the external and conceptual levels are focused on and
serve DBMS users, the concern of the internal level is effective implementation details
Database users and AdministratorA database administrator (short form DBA) is a
person responsible for the installation, configuration, upgrade, administration, monitoring and
maintenance of databases in an organization.[1]
The role includes the development and design of database strategies, system monitoring and
improving database performance and capacity, and planning for future expansion requirements.
They may also plan, co-ordinate and implement security measures to safeguard the database.
EntityRelationship model (E-R model )
an EntityRelationship model(ER modelfor short) is an abstract way to describe a database.
It usually starts with a relational database, which stores data in tables. Some of the data in these
tables point to data in other tables - for instance, your entry in the database could point to several
entries for each of the phone numbers that are yours. The ER model would say that you are an
entity, and each phone number is an entity, and the relationship between you and the phone
numbers is 'has a phone number'. Diagrams created to design these entities and relationships are
called entityrelationship diagramsor ER diagrams.
This article refers to the techniques proposed inPeter Chen's 1976 paper.[1]
However, variants of
the idea existed previously,[2]
and have been devised subsequently such as supertype and subtype
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Peter_Chenhttp://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-Peter-Chen-paper-1http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-Peter-Chen-paper-1http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-Peter-Chen-paper-1http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-2http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-2http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-2http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-2http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-Peter-Chen-paper-1http://en.wikipedia.org/wiki/Peter_Chenhttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Computer_securityhttp://en.wikipedia.org/wiki/Implementation_%28computer_science%29http://en.wikipedia.org/wiki/Cooperationhttp://en.wikipedia.org/wiki/Planninghttp://en.wikipedia.org/wiki/Capacity_managementhttp://en.wikipedia.org/wiki/Computer_performancehttp://en.wikipedia.org/wiki/System_monitoringhttp://en.wikipedia.org/wiki/Strategyhttp://en.wikipedia.org/wiki/Designhttp://en.wikipedia.org/wiki/Software_developmenthttp://en.wikipedia.org/wiki/Database_administrator#cite_note-SFIA-1http://en.wikipedia.org/wiki/Databaseshttp://en.wikipedia.org/wiki/Software_maintenancehttp://en.wikipedia.org/wiki/System_Monitoringhttp://en.wikipedia.org/wiki/System_administratorhttp://en.wikipedia.org/wiki/Upgradehttp://en.wikipedia.org/wiki/Computer_configurationhttp://en.wikipedia.org/wiki/Installation_%28computer_programs%29 -
8/12/2019 CS2255 Notes
11/45
ww
w.5st
arnot
es.co
mdata entities
[3] and commonality relationships (an example with additional concepts is the
enhanced entityrelationship model).
Using the three schema approach to software engineering, there are three levels of ER models
that may be developed. The conceptual data model is the highest level ER model in that it
contains the least granular detail but establishes the overall scope of what is to be included within
the model set. The conceptual ER model normally defines master reference data entities that are
commonly used by the organization. Developing an enterprise-wide conceptual ER model is
useful to support documenting the data architecture for an organization.
A conceptual ER model may be used as the foundation for one or more logical data models. The
purpose of the conceptual ER model is then to establish structural metadata commonality for the
master data entities between the set of logical ER models. The conceptual data model may be
used to form commonality relationships between ER models as a basis for data model
integration.
A logical ER model does not require a conceptual ER model especially if the scope of the logical
ER model is to develop a single disparate information system. The logical ER model contains
more detail than the conceptual ER model. In addition to master data entities, operational and
transactional data entities are now defined. The details of each data entity are developed and theentity relationships between these data entities are established. The logical ER model is however
developed independent of technology into which it will be implemented.
One or more physical ER models may be developed from each logical ER model. The physical
ER model is normally developed be instantiated as a database. Therefore, each physical ER
model must contain enough detail to produce a database and each physical ER model is
technology dependent since each database management system is somewhat different.
The physical model is normally forward engineered to instantiate the structural metadata into a
database management system as relational database objects such as database tables, database
indexes such asunique key indexes, and database constraints such as aforeign key constraint or
a commonality constraint. The ER model is also normally used to design modifications to the
relational database objects and to maintain the structural metadata of the database.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Unique_keyhttp://en.wikipedia.org/wiki/Foreign_key_constrainthttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Foreign_key_constrainthttp://en.wikipedia.org/wiki/Unique_keyhttp://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Database_tablehttp://en.wikipedia.org/wiki/Database_management_systemhttp://en.wikipedia.org/wiki/Master_datahttp://en.wikipedia.org/wiki/Metadatahttp://en.wikipedia.org/wiki/Logical_data_modelhttp://en.wikipedia.org/wiki/Data_architecturehttp://en.wikipedia.org/wiki/Conceptual_data_modelhttp://en.wikipedia.org/wiki/Software_engineeringhttp://en.wikipedia.org/wiki/Three_schema_approachhttp://en.wikipedia.org/wiki/Enhanced_entity%E2%80%93relationship_modelhttp://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-3 -
8/12/2019 CS2255 Notes
12/45
ww
w.5st
arnot
es.co
mThe first stage of information system design uses these models during the requirements analysis
to describe information needs or the type of information that is to be stored in a database. The
data modeling technique can be used to describe any ontology (i.e. an overview and
classifications of used terms and their relationships) for a certain area of interest. In the case of
the design of an information system that is based on a database, the conceptual data model is, at a
later stage (usually called logical design), mapped to a logical data model, such as the relational
model; this in turn is mapped to a physical model during physical design. Note that sometimes,
both of these phases are referred to as "physical design".
E-R Diagrams
Two related entities
An entity with an attribute
A relationship with an attribute
Primary key
An entity may be defined as a thing which is recognized as being capable of an independent
existence and which can be uniquely identified. An entity is an abstraction from the complexities
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Entityhttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/File:Erd-id-as-primary-key.pnghttp://en.wikipedia.org/wiki/File:Erd-relationship-with-attribute.pnghttp://en.wikipedia.org/wiki/File:Erd-entity-with-attribute.svghttp://en.wikipedia.org/wiki/File:Erd-entity-relationship-example1.svghttp://en.wikipedia.org/wiki/File:Erd-id-as-primary-key.pnghttp://en.wikipedia.org/wiki/File:Erd-relationship-with-attribute.pnghttp://en.wikipedia.org/wiki/File:Erd-entity-with-attribute.svghttp://en.wikipedia.org/wiki/File:Erd-entity-relationship-example1.svghttp://en.wikipedia.org/wiki/File:Erd-id-as-primary-key.pnghttp://en.wikipedia.org/wiki/File:Erd-relationship-with-attribute.pnghttp://en.wikipedia.org/wiki/File:Erd-entity-with-attribute.svghttp://en.wikipedia.org/wiki/File:Erd-entity-relationship-example1.svghttp://en.wikipedia.org/wiki/File:Erd-id-as-primary-key.pnghttp://en.wikipedia.org/wiki/File:Erd-relationship-with-attribute.pnghttp://en.wikipedia.org/wiki/File:Erd-entity-with-attribute.svghttp://en.wikipedia.org/wiki/File:Erd-entity-relationship-example1.svghttp://en.wikipedia.org/wiki/Entityhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Logical_data_modelhttp://en.wikipedia.org/wiki/Conceptual_data_modelhttp://en.wikipedia.org/wiki/Universe_of_discoursehttp://en.wikipedia.org/wiki/Ontology_%28computer_science%29http://en.wikipedia.org/wiki/Data_modelinghttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Informationhttp://en.wikipedia.org/wiki/Requirements_analysishttp://en.wikipedia.org/wiki/Information_system -
8/12/2019 CS2255 Notes
13/45
ww
w.5st
arnot
es.co
mof a domain. When we speak of an entity, we normally speak of some aspect of the real world
which can be distinguished from other aspects of the real world.[4]
An entity may be a physical object such as a house or a car, an event such as a house sale or a car
service, or a concept such as a customer transaction or order. Although the term entity is the one
most commonly used, following Chen we should really distinguish between an entity and an
entity-type. An entity-type is a category. An entity, strictly speaking, is an instance of a given
entity-type. There are usually many instances of an entity-type. Because the term entity-type is
somewhat cumbersome, most people tend to use the term entity as a synonym for this term.
Entities can be thought of as nouns. Examples: a computer, an employee, a song, a mathematical
theorem.
Introduction to relational databases
A relational database is a collection of data items organized as a set of formally described
tables from which data can be accessed easily. A relational database is created using the
relational model. The software used in a relational database is called a relational database
management system (RDBMS). A relational database is the predominant choice in storing data,
over other models like the hierarchical database model or the network model.
The relational database was first defined in June 1970 by Edgar Codd, of IBM's San Jose
Research Laboratory.
Terminology
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/File:Relational_database_terms.svghttp://en.wikipedia.org/wiki/File:Relational_database_terms.svghttp://en.wikipedia.org/wiki/File:Relational_database_terms.svghttp://en.wikipedia.org/wiki/File:Relational_database_terms.svghttp://en.wikipedia.org/wiki/IBM_Almaden_Research_Centerhttp://en.wikipedia.org/wiki/IBM_Almaden_Research_Centerhttp://en.wikipedia.org/wiki/E.F._Coddhttp://en.wikipedia.org/wiki/Network_modelhttp://en.wikipedia.org/wiki/Hierarchical_database_modelhttp://en.wikipedia.org/wiki/Relational_database#Relational_database_management_systemshttp://en.wikipedia.org/wiki/Relational_database#Relational_database_management_systemshttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Nounhttp://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#cite_note-4 -
8/12/2019 CS2255 Notes
14/45
ww
w.5st
arnot
es.co
mRelational database terminology.
Relational database theory uses a set of mathematical terms, which are roughly equivalent to
SQL database terminology. The table below summarizes some of the most important relational
database terms and their SQL database equivalents.
Relational term SQL equivalent
relation, base relvar table
derived relvar view, query result, result set
tuple row
attribute (name) column name
relation scheme, set of attributes set of column names
attribute value column (data)
UNIT II RELATIONAL MODEL
The relational model
The relational model for database management is a database model based on first-order
predicate logic, first formulated and proposed in 1969 by Edgar F. Codd.[1][2] In the relational
model of a database, all data is represented in terms of tuples, grouped into relations. A database
organized in terms of the relational model is arelational database.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Relational_databasehttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Relational_model#cite_note-1http://en.wikipedia.org/wiki/Relational_model#cite_note-1http://en.wikipedia.org/wiki/Edgar_F._Coddhttp://en.wikipedia.org/wiki/First-order_logichttp://en.wikipedia.org/wiki/First-order_logichttp://en.wikipedia.org/wiki/Database_modelhttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Relvarhttp://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/SQL -
8/12/2019 CS2255 Notes
15/45
ww
w.5st
arnot
es.co
m
Diagram of an example database according to the Relational model.
In the relational model, related records are linked together with a "key".
The purpose of the relational model is to provide a declarative method for specifying data and
queries: users directly state what information the database contains and what information they
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Declarative_programminghttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/File:Relational_key.pnghttp://en.wikipedia.org/wiki/File:Relational_Model.svghttp://en.wikipedia.org/wiki/File:Relational_key.pnghttp://en.wikipedia.org/wiki/File:Relational_Model.svghttp://en.wikipedia.org/wiki/Declarative_programming -
8/12/2019 CS2255 Notes
16/45
ww
w.5st
arnot
es.co
mwant from it, and let the database management system software take care of describing data
structures for storing the data and retrieval procedures for answering queries.
Most implementations of the relational model use the SQL data definition and query language. A
tablein an SQL database schema corresponds to a predicate variable; the contents of a table to a
relation; key constraints, other constraints, and SQL queries correspond to predicates. However,
SQL databases, including DB2, deviate from the relational model in many details; Codd fiercely
argued against deviations that compromise the original principles.
The catalog:
TypesKeys
* Alternate key- An alternate key is any candidate key which is not selected to be the primary
key
* Candidate key- A candidate key is a field or combination of fields that can act as a primary
key field for that table to uniquely identify each record in that table.
For Eg:
The table:
Emloyee(Name,Address,Ssn,Employee_Idprimary_key,Phone_ext)
In the above example Ssn no. and employee identity are ccandidate keys.
* Compound key- compound key (also called a composite key or concatenated key) is a key
that consists of 2 or more attributes.
* Primary key- a primary key is a value that can be used to identify a unique row in a table.
Attributes are associated with it. Examples of primary keys are Social Security numbers
(associated to a specific person) or ISBNs (associated to a specific book).
In the relational model of data, a primary key is a candidate key chosen as the main method of
uniquely identifying a tuple in a relation.
For Eg:
Emloyee(Name,Address,Ssn,Employee_Idprimary_key,Phone_ext)
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/SQL -
8/12/2019 CS2255 Notes
17/45
ww
w.5st
arnot
es.co
m*Superkey- A superkey is defined in the relational model as a set of attributes of a relation
variable (relvar) for which it holds that in all relations assigned to that variable there are no two
distinct tuples (rows) that have the same values for the attributes in this set. Equivalently a
superkey can also be defined as a set of attributes of a relvar upon which all attributes of the
relvar are functionally dependent.
For Eg:
Emloyee(Name,Address,Ssn,Employee_Idprimary_key,Phone_ext)
All the above are super keys.
* Foreign key- a foreign key (FK) is a field or group of fields in a database record that points to
a key field or group of fields forming a key of another database record in some (usually
different) table. Usually a foreign key in one table refers to the primary key (PK) of another
table. This way references can be made to link
For Eg:
For a Student....
School(Name,Address,Phone,School_Reg_noprimary_key
Relational algebra
In computer science, relational algebrais an offshoot of first-order logic and of algebra of sets
concerned with operations over finitary relations, usually made more convenient to work with by
identifying the components of a tuple by a name (called attribute) rather than by a numeric
column index, which is what is called a relation in database terminology.
The main application of relational algebra is providing a theoretical foundation for relational
databases, particularly query languages for such databases, chiefly among which is
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Query_languagehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Finitary_relationhttp://en.wikipedia.org/wiki/Operation_%28mathematics%29http://en.wikipedia.org/wiki/Algebra_of_setshttp://en.wikipedia.org/wiki/First-order_logichttp://en.wikipedia.org/wiki/Computer_science -
8/12/2019 CS2255 Notes
18/45
-
8/12/2019 CS2255 Notes
19/45
ww
w.5st
arnot
es.co
mFive primitive operators of Codd's algebra are the selection, the projection, the Cartesian
product (also called the cross product or cross join), the set union, and the set difference.
Another operator, renamewas not noted by Codd, but the need for it is shown by the inventors of
ISBL. These six operators are fundamental in the sense that omitting any one of them causes a
loss of expressive power. Many other operators have been defined in terms of these six. Among
the most important are set intersection, division, and the natural join. In fact ISBL made a
compelling case for replacing the Cartesian product with the natural join, of which the Cartesian
product is a degenerate case.
Altogether, the operators of relational algebra have identical expressive power to that of domain
relational calculus or tuple relational calculus. However, for the reasons given in section
Introduction, relational algebra is less expressive than first-order predicate calculus withoutfunction symbols. Relational algebra corresponds to a subset of first-order logic, namely Horn
clauses without recursion and negation.
Set operators
Although three of the six basic operators are taken from set theory, there are additional
constraints that are present in their relational algebra counterparts: For set union and set
difference, the two relations involved must be union-compatiblethat is, the two relations musthave the same set of attributes. Because set intersection can be defined in terms of set difference,
the two relations involved in set intersection must also be union-compatible.
The Cartesian product is defined differently from the one in set theory in the sense that tuples are
considered to be 'shallow' for the purposes of the operation. That is, the Cartesian product of an
n-tuple by an m-tuple has the 2-tuple "flattened" into an (n+ m)-tuple. In set theory, the
Cartesian product is a set of 2-tuples. More formally,R Sis defined as follows:
R S= {(r1, r2, ..., rn,s1,s2, ...,sm) | (r1, r2, ..., rn) R, (s1,s2, ...,sm) S}
Like the Cartesian product, the cardinality of the result is the product of the cardinalities of its
factors, i.e., |R S| = |R| |S|. In addition, for the Cartesian product to be defined, the two
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Set_%28mathematics%29http://en.wikipedia.org/wiki/Set_intersectionhttp://en.wikipedia.org/w/index.php?title=Set_of_attributes&action=edit&redlink=1http://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Set_differencehttp://en.wikipedia.org/wiki/Set_differencehttp://en.wikipedia.org/wiki/Set_unionhttp://en.wikipedia.org/wiki/Algebrahttp://en.wikipedia.org/wiki/Set_theoryhttp://en.wikipedia.org/wiki/Horn_clausehttp://en.wikipedia.org/wiki/Horn_clausehttp://en.wikipedia.org/wiki/First-order_logichttp://en.wikipedia.org/wiki/First-order_predicate_calculushttp://en.wikipedia.org/wiki/Relational_algebra#Introductionhttp://en.wikipedia.org/wiki/Tuple_relational_calculushttp://en.wikipedia.org/wiki/Domain_relational_calculushttp://en.wikipedia.org/wiki/Domain_relational_calculushttp://en.wikipedia.org/wiki/Set_intersectionhttp://en.wikipedia.org/wiki/ISBLhttp://en.wikipedia.org/wiki/Rename_%28relational_algebra%29http://en.wikipedia.org/wiki/Set_differencehttp://en.wikipedia.org/wiki/Set_unionhttp://en.wikipedia.org/wiki/Cartesian_producthttp://en.wikipedia.org/wiki/Cartesian_producthttp://en.wikipedia.org/wiki/Projection_%28relational_algebra%29http://en.wikipedia.org/wiki/Selection_%28relational_algebra%29 -
8/12/2019 CS2255 Notes
20/45
ww
w.5st
arnot
es.co
mrelations involved must have disjoint headersthat is, they must not have a common attribute
name.
Projection ()
A projectionis a unary operation written as where is a set of attribute
names. The result of such projection is defined as the set that is obtained when all tuples in Rare
restricted to the set .
This specifies the specific subset of columns (attributes of each tuple) to be retrieved. To obtain
the names and phone numbers from an address book, the projection might be written
. The result of that projection would bea relation which contains only the contactName and contactPhoneNumber attributes for each
unique entry in addressBook.
Selection ()
A generalized selection is a unary operation written as where is a propositional
formula that consists of atoms as allowed in the normal selection and the logical operators
(and), (or) and (negation). This selection selects all those tuples inRfor which holds.
To obtain a listing of all friends or business associates in an address book, the selection might be
written as . The result would be a
relation containing every attribute of every unique record where isFriend is true or where
isBusinessContact is true.
Rename ()
A renameis a unary operation written as where the result is identical toRexcept that
the b attribute in all tuples is renamed to an a attribute. This is simply used to rename the
attribute of arelation or the relation itself.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Relation_%28database%29http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Relation_%28database%29http://en.wikipedia.org/wiki/Unary_operationhttp://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Negationhttp://en.wikipedia.org/wiki/Logical_disjunctionhttp://en.wikipedia.org/wiki/Logical_conjunctionhttp://en.wikipedia.org/wiki/Selection_%28relational_algebra%29http://en.wikipedia.org/wiki/Atomic_formulahttp://en.wikipedia.org/wiki/Propositional_formulahttp://en.wikipedia.org/wiki/Propositional_formulahttp://en.wikipedia.org/wiki/Unary_operationhttp://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Set_%28mathematics%29http://en.wikipedia.org/wiki/Unary_operationhttp://en.wikipedia.org/w/index.php?title=Attribute_name&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=Attribute_name&action=edit&redlink=1 -
8/12/2019 CS2255 Notes
21/45
ww
w.5st
arnot
es.co
mTo rename the 'isFriend' attribute to 'is BusinessContact' in a relation,
might be used.
Domain relational calculus
In computer science, domain relational calculus (DRC) is a calculus that was introduced by
Michel Lacroix and Alain Pirotte as a declarative database query language for the relational data
model.[1]
In DRC, querieshave the form:
where each Xi is either a domain variable or constant, and denotes a
DRCformula. The result of the query is the set of tuples X ito Xnwhich makes the DRC formula
true.
This language uses the same operators as tuple calculus, the logical connectives (and), (or)
and (not). The existential quantifier () and the universal quantifier () can be used to bind the
variables.
Its computational expressiveness is equivalent to that of Relational algebra.[2]
Examples
Let (A, B, C) mean (Rank, Name, ID)
and (D, E, F) to mean (Name, DeptName, ID)
Find all captains of the starship USS Enterprise:
In this example, A, B, C denotes both the result set and a set in the table Enterprise.
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/USS_Enterprise_%28NCC-1701%29http://en.wikipedia.org/wiki/Domain_relational_calculus#cite_note-Codd72a-1http://en.wikipedia.org/wiki/Relational_algebrahttp://en.wikipedia.org/wiki/Universal_quantificationhttp://en.wikipedia.org/wiki/Existential_quantificationhttp://en.wikipedia.org/wiki/Tuple_calculushttp://en.wikipedia.org/wiki/Domain_relational_calculus#cite_note-LP77-0http://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Query_languagehttp://en.wikipedia.org/wiki/Declarative_programminghttp://en.wikipedia.org/w/index.php?title=Alain_Pirotte&action=edit&redlink=1http://en.wikipedia.org/wiki/Michel_Lacroixhttp://en.wikipedia.org/wiki/Computer_science -
8/12/2019 CS2255 Notes
22/45
ww
w.5st
arnot
es.co
mFind Names of Enterprise crewmembers who are in Stellar Cartography:
In this example, we're only looking for the name, and that's B. F = C is a requirement, because
we need to find Enterprise crew members AND they are in the Stellar Cartography Department.
Tuple relational calculus
Tuple calculus is a calculus that was introduced by Edgar F. Codd as part of the relational
model, in order to provide a declarative database-query language for this data model. It formed
the inspiration for the database-query languages QUEL and SQL, of which the latter, although
far less faithful to the original relational model and calculus, is now the de-facto-standard
database-query language; viz., a dialect of SQL is used by nearly every relational-database-
management system. Lacroix and Pirotte proposed domain calculus, which is closer to first-order
logic and which showed that both of these calculi (as well as relational algebra) are equivalent in
expressive power. Subsequently, query languages for the relational model were called
relationally completeif they could express at least all of these queries.
Definition of the calculus
Relational database
Since the calculus is a query language for relational databases we first have to define a relational
database. The basic relational building block is the domain, or data type. A tuple is an ordered
multiset of attributes, which are ordered pairs of domain and value; or just a row. A relvar
(relation variable) is a set of ordered pairs of domain and name, which serves as the header for arelation. A relation is a set of tuples. Although these relational concepts are mathematically
defined, those definitions map loosely to traditional database concepts. A table is an accepted
visual representation of a relation; a tuple is similar to the concept of row.
We first assume the existence of a set C of column names, examples of which are "name",
"author", "address" et cetera. We define headers as finite subsets of C. A relational databaseschemais defined as atuple S= (D,R, h) whereDis the domain of atomic values (seerelational
www.5starnotes.com
www.5starnotes.com
http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Relational_modelhttp://5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://www.5starnotes.com/http://5starnotes.com/http://5starnotes.com/http://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Row_%28database%29http://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/w/index.php?title=Relational_concept&action=edit&redlink=1http://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Header_%28information_technology%29http://en.wikipedia.org/wiki/Ordered_pairhttp://en.wikipedia.org/wiki/Relation_variablehttp://en.wikipedia.org/wiki/Attribute_%28computing%29http://en.wikipedia.org/wiki/Multisethttp://en.wikipedia.org/wiki/Tuplehttp://en.wikipedia.org/wiki/Data_typehttp://en.wikipedia.org/wiki/Data_domainhttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_algebrahttp://en.wikipedia.org/wiki/First-order_predicate_calculushttp://en.wikipedia.org/wiki/First-order_predicate_calculushttp://en.wikipedia.org/wiki/Domain_calculushttp://en.wikipedia.org/w/index.php?title=Alain_Pirotte&action=edit&redlink=1http://en.wikipedia.org/wiki/Michel_Lacroixhttp://en.wikipedia.org/wiki/Relational_database_management_systemhttp://en.wikipedia.org/wiki/Relational_database_management_systemhttp://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/QUEL_query_languageshttp://en.wikipedia.org/wiki/Data_modelhttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Relational_modelhttp://en.wikipedia.org/wiki/Edgar_F._Coddhttp://en.wikipedia.org/wiki/Calculus_%28disambiguation%29 -
8/12/2019 CS2255 Notes
23/45
ww
w.5st
arnot
es.co
mmodel for more on the notions of domainand atomic value),Ris a finite set of relation names,
and
h:R 2C
a function that associates a header with each relation name inR. (Note that this is a simplificationfrom the full relational model where there is more than one domain and a header is not just a set
of column names but also maps these column names to a domain.) Given a domain Dwe define
a tupleoverDas a partial function
t: CD
that maps some column names to an atomic value in D. An example would be (name : "Harry",age : 25).
The set of all tuples over Dis denoted as TD. The subset of Cfor which a tuple tis defined is
called the domainof t(not to be confused with the domain in the schema) and denoted as dom(t).
Finally we define a relational databasegiven a schema S= (D,R, h) as a function
db:R 2TD
that maps the relation names inRto finite subsets of TD, such that for every relation name rinRand tuple tin db(r) it holds that
dom(t) = h(r).
The latter requirement simply says that all the tuples in a relation should contain the samecolumn names, namely those defined for it in the schema.
Fundamental operationsAdditional operations
SQLor Structured Query Language is a special-purpose programming language designed formanaging data in relational database management systems (RDBMS).
Originally based upon relational algebra and tuple relational calculus, its scope includes data
insert, query, update and delete, schema creation and modification, and data access control.
SQL was one of the first commercial languages for Edgar F.