Database management system
description
Transcript of Database management system
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
1
Unit-1
Data base management system
Introduction Data base is a collection of raw facts and figure users which are arranged f in a proper
manner so than an appropriate record can be maintain. This proper arrangement is known
as DBMS. In each and every CBMS table ae maintained to recorded data. Data is always
represented through relations. There are various kind of relations can be established
between the tables.
A table is a collection of related f information stored so that it is available to many users
for different purpose. The content of data base is obtain by combing data from all the
difference source in an organization so that data available to all the users is redundant.
The data base fundament system is a major software component of data bade system.
Capabilities of data base system 1. Creation of files, addition of data , modification and deletion these are the
important function of data base should perform.
2. Retrieval, collection and deletion of data should be simple.
3. The data should be shorted in form of table and in dense according to the user.
4. Various reports can be provided form system in a standardized way or in a
specific way.
5. Mathematical functions can be performed and can be manipulated easily.
6. There must be data integrity is DB accuracy and consistency.
BASIC CONCEPT OF DBMS
DATA Data is a collection of meaning fact and figure expressed in a form user could
understand it can be resources and processed for further usage.
INFORMATION: Refined data is known as in formation. Any input that foes into
process generate information
PROCESS Any method of reefing data is information data is to information is known as
process.
DATA BASE A collection of related set of data along with necessary details is known as
data base.
DATA BASE BASICS
1. Data item (or domains) the term data item is used for data fields it is the smallest
unit of data. It is also called data elements and elementary item.
Student
Name Age cours
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
2
Lalit 19 BCA
mohit 20 BBA
In the above table values corresponding to the field name is known a data item for
example- lalit, 19, BCA
2. Entity and attribute:
Entity: Any object which can be describe or define is known as entity. Entity are
ways related to the world all such items which have some relevant information to
be strode is known as data base entity entity could be physical and non physical,
tangible or integrity
For eg- student, EMPloyee etc.
Attribute; each entity has a set of particular properties that completely describe it
in context of mini world model. The entity properties are called its attributes
which describe any object for eg an EMPloyee entity may have the attributes like
name EMP_id, address date of birth etc.
3. Logical data and Physical data:
The term logical data or structure refers to the way the programmer see it and
physical sutured refers to the way the data are actually recorded on the storage
media.
4. Schema and sub schema:
Schema it is a logical data base desecration and is down as a chart of types of data
that are used it gives name of entities and attribute and specific the relation ship
between them. The is a frame work in which data values can be fitted for eg
information display system such as that give arrival and departure timing of flight
at airport. The schema will remain same but values are change time to time the
entire format need to be change
FLIGHT
NO
ARRIVAL
TIME
Departure
time
AC001Z 9.00 10.30
AC017T 10.00 11.00
Sub schema the term sub schema refers to the same view but the data item type
and reward type which are used in a particular application or by particular user.
Therefore many different sub schema can be derived from main schema. A simple
analysis distinguished between schema and sun schema may be that if the schema
represented root map of Delhi showing major historical site educational institute
railways station airport etc a subschema could be similar map showing route each
from railway station or form air port.
5. Data dictionary it hold detail information about the different structure and data
type. The different structure and data types the details of logical structure that are
mapped into the differs form details of relationship between data item details o a
all users privileges and access right and performance of recourses wit detail.
PROPERTIES OF DBMS
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
3
1) It should always be certain: A data base about certain part or real world .
this mall part of real world repented in data base in sometimes call mini-
world.
2) Data base should be logical: data base contain persistence data a data
base is a logical coherent collection of which dome inherent meaning once
the data has been accepted by DBMS it can subsequent be remove form
the system only by some explicit request.
3) Data base should have some specific purpose: it is design built and
calculated we data a well define purpose. As intended by group of users
according to their users.
4) Database can be implemented in may available form: it may be
generated and maintained manually or it may be computerized
CHARACTERSITICS OF DBMS
1) Data base system is self describe in nature: data base has a complete definition
or description of data base structure and constraints. It does not depend on any
external information for handling data. It holds information such as strutted of
each file, the time and storage formats of each like and data item and various
constraints on the data.
2) Program data independence: this characteristic allow changing data store
structured and operation without changing the logical structured of DBMS
3) Data abstraction: the form of data I,e actually stored inside the database and
presented to the different user are not the same. A data model is used to hide
storage details and present the user with the conceptual view of database.
4) Multiple view support: it user may see different views of same database
according to the interest of user no matter how the data is stored each user gets
data in his own desire format.
5) Data sharing and multi-user transaction process: a data base may have
multiple users the DBMS must therefore have co-currency control mechanic to
ensure that the result of multi-user access is always correct.
ELEMENT OF DATA BASE MANAGEMENT SYSTEM
1) DDL (Data definition language): DBMS provide a facility known as DDL
which can use to define the concept of schema. It also give some details about
how to implement this schema in physical device used to stored data. This
definition includes all the entity sets and their relation among the entity set. The
definition also including the constraints that have to be maintain including the
constraint on that have to be maintain including the constraints on the values
assign to different attributes in a same or different record. These definition can be
describe meta data about the data in the data base are expressed in DDL of DBMS
and maintain in a complied form the complied form of definition are known as
data dictionary or system catalog.
2) DML(Data manipulation language): DML is a language that access or
manipulated as organized by appropriate data model. Data manipulation includes
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
4
retrieval of data insertion of data deletion or modification of exiting data base.
DML also support query language DML provides command to select and
retrieved data form database command are liked UPDATE, INSERT, DELETE,
etc.
3) DML Pre Compiler: the convert DML statement in an application program to
normal procedural call in the host language the precompiled must interact with
query processor in order to generate the appropriate code.
4) DDL Compiler: the convert’s data definition statement into a set of table these
table contains information related to data based and are in the form that can be
used by other component of database management system.
5) File Manager: it manages the allocation of space on disk storage and the data
structure used to represent information stored in disk the file manager can be
implemented using an interface to the exist file system proved the operating
system to host computer or it can include a file sub system written specially for
DBMS.
6) Data Base manager: it is a program which provides the interface between the
low level data. Stored in data base and the application program and queries
submitted to the system. One of the functions of data base manager is to convert
the user query coming directly through the query processor or indirectly to the
application program.
RESPONSIBILITIES OF DATA BASE MANAGER 1) Interaction with manager: the raw data is stored on the disk using file system
which is unusually provided by a conventional operating system. The data base
manager transaction the various DML statements into low level file system
commands. The Database manager is responsibility for the actual storage retrieval
and updating of data.
2) Integrity enforcement: the data values stored in data base must satisfied certain
types of consistency types of consistency constraints. All the validation and
condition apply to database should be clearly defined.
3) Security enforcement: each and every user of data base need not to have the
access the entire database. It is to have the access the entire database it I the job of
database manager to enforce security requirements.
4) Backup and Recovery: a computer system like any other mechanical device is
subject to failure there are verities of courses of such failure including disk crash.
Power failure software errors. In each of these causes it is the responsibility of
database manager to detect such failure and restored the database as before.
5) Concurrency control: when several user update database concurrently. The
consistency of data may no longer be preserved. It is necessary for the system to
control interaction among the concurrent users are achieving such a control is one
of the responsibility of data base manager.
6) Query Processor: the data base user retrieve data by formulating a query in a
data manipulating language provided by database. The query processor is used to
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
5
interpretation online user query and converts it into an effective series of
operation in base manager for execution. The query processes the structure of
relevant portion of data base and uses this information in modifying a query and
preparing an optimal path to access the database.
7) Data base administrator: the person having total control over the system is
called DBA. The DBA has three level of data base and in consultation with the
overall user community, sets up the definition of global view or conceptual view
of data base it has following responsibility:-
• Schema definition
• Storage structure and access method definition
• Schema and physical organization modification
• Granting of authorization for data access.
• Integrity constraint specification.
DATA BASE USER
1. Data base administration: the user is responsible for creating manipulating and
authorizing access to the database. They are also responsibility for co- ordaining
and monitoring its users. A DBA has complete control on every aspect of data
base. Some time DBA called super user.
2. Data base designer: they are responsible for identifying the data to be stored and
for selecting appropriated structure to represent and store this data.
3. End users: people who’s job require access to database for query updating and
generating report are end users. They carry out their jobs either through
application or by user program.
4. System analyst: System analyses determines the requirement of end users and
develop specifications for transaction.
5. Application programmer: AP implements specification and programs developed
by the analyst so that the specification becomes operational.
6. DBMS system designer and implementation: if somebody has to design and
implement the DBMS module and interface as software package to be
subsequently used.
7. Tool Developers: tool are package of process used are not used very often but are
very important for users at various level
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
6
8. Operators and maintenance personnel: Professional responsibility for actual
execution and maintained of hardware and software are known as operation and
maintenance personnel.
ADVANTAGES OF DBMS
1. Redundancy control: centralized control of data be DBA avoids unnecessary
duplication of data and effectively reduces the total amount of data storage
required Controlling redundancy in data storage and independent and maintained
efforts insure that information is not repeated many times at many places but
stored in single copy which save cost and space and avoiding multiple updating in
case a data item is need to be exchanged.
2. Access control: DBA uses security and authorization around restriction a DBA
has full control on who can use the data in what ways.
3. Persistent for program object and data structure: The object stored in data
base survive the termination of program execution and can later be retrieve the
data remains in the data base even after it has been used many time by users.
4. Multi-user Interface: DBMS provide multi user interface may be implemented
in any of the programming language have compatibility with data base.
5. Complex Relationship Representation: any amount of complexity in the
relationship of given data item can be concisely represented by the database
capability to retrieve and update data easily and effacingly
6. Integrity constraint enforcement: DBMS have capability for defying ad
enforcing constraint that must be satisfied by the data entering by the system and
used by to process
7. Backup and Recovery: A DBMS is a subject to failure due to many reasons
DBMS provide facility for recovering from such software ad hardware failure
8. Data Sharing: since data is stored a single copy many user can use the same
without the need of having separate data for each user. DBMS provide such
facility.
9. Standard Enforcement: A no of international standard may be enforced in the
certain and operation of data base.
10. Flexibility to change data structure: due to data abstraction data structure of
data base can be modified without distrusting the data base users.
11. Reduced application development time: the effort required to develop user
utility reduces considerably and so does the time
12. Availability of update information: the data base always has latest state
providing each user with the up to date information all the time.
DISADVANTAGES OF DBMS
1. Cost: the data base system is a combination of h/w and s/w and training
intensive and calls for a large cost is not justified for a particular situation it is
advisable to look for a cheaper alternative.
2. DBMS are very general in nature if the solution are required for a very
specific purpose it is better to have non- DBMS system.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
7
3. Overhead on processor: generally a lot of overhead is involved in a DBMS
many of these feature may not be required in a particular situation.
4. In real time system where processing time critical it may not be suitable. The
time overhead may be un acceptable in such case.
THEREE VIEWS OF DATA
DBMS is a collection of interrelated files and sets of program that allow several user to
access and modify files. Major purpose of a data base system is to provide user with an
abstraction view of data
system hide certain details of how the data is stored and maintain since DBMS system are
often used system this is done by defining level be view. There are logical view or
external view or connectional view and internal or physical view.
1. External view: this is the highest level of abstraction as seen by a user this level
of abstraction describe only the part of entire data base.
2. Conceptual view: At his is the next higher level of abstraction which is the sum
total of user view. This level describe what data are actually stored in database in
term of small number of relatively simple structure
3. Internal view: This lowest level of abstraction at which one describe how the
data are physically stored. The interrelationship of three level of abstraction is
given internal view.
The view at each level is describing by a schema as mention earlier is an outline or a plan
that describe the records ands relationship exiting in the view. The schema also describe
in the way in which entity one level of abstraction can be mapped to the next level of
abstraction the overall data base design is called format their exist several schema in the
data base these schema are:-
Portioned into the following level of abstraction
1. At lower level we have physical schema
2. At intermediate level we have conceptual schema
3. At higher level we have several sub schema The general any data base contain one physical schema one conceptual sub schema
several sub schemas.
1. External level or sub-schema: the external level is at the highest level of data
base abstraction are concern to a user or application where any those person of
data base are concern to a user or application programs are concern to a user or
application program are included any number of user may exit for a given global
or conceptual view.
2. Conceptual level schema: at this level of data base abstraction all the data base
entity and the relation ship among them. Them are included in conceptual view. It
describe all the record and relationship including in the concept view ad there fore
in the database there is only one concept schema per data base. This schema also
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
8
contains the method of driving object in the conceptual view from the object in
the internal view.
3. Internal level or physical schema: we find the view at the lowest level of
abstraction it is used in physical storage it indicate how data will be stored and
describe the data structure and access method to be used by data base the internal
view is experience by internal schema which contain the definition of stored
record, the method of representing the data field and access method of
representing the data field and access method to be used.
CHAPTER-2
DATA MODEL
ER MODEL
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
9
Entity relationship model is generalization of old hierarchal and network based approach
it represent the relationship between various entities that is understandable very easily.
Various component of ER-model.
a) Entity: it is a thing or any object physical exquisite. Eg car house and any person
in the real world it may be object with a conceptual existence. Eg: job university
course etc.
b) Attribute: each entity has asset of a particular property that complexly describe
any entity in context of mini world. Each property is called attributes there are
various types of attributes.
• simple: each entity has as single atomic values for the attribute is known
as simple attribute.
Eg- name of any student
• Composite attribute: the attribute may be composed of several
components Eg address of any person include house no, road no, sector
no, city state and pin code.
• Multi value attribute: an entity may have multiple values for the
attribute. Any attribute which can have more than one value for that
attribute is known as multi valued attribute.
Eg- degree attribute of a student can contain BCA, MCA, MBA
c) Entity type and set: an entity type defines a collection of entities that have the
same attributes EMPloyee entity type and company entity type. An entity is an
instance of entity type all entity having the same set of properties are grouped into
an entity type. The collection of all entitles of a particular entity type in a data
base in any point in time is called entity set.
d) Relationship
ADDRESS
STREET CITY STATE PIN CODE
HOUSE NO ROAD NO SECTOR NO
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
10
• Binary relationship: if the association in b/w two entities then it is known
as binary relationship.
• Ternary relationship: it the relationship is b/w three or more entities then
it is known as ternary relationship.
Relationship between entity set
1. One to one: in this relationship one instance of first entity is related to exactly
one instance of second entity.
2. One to many: one instance of first entity is related to one or more instances of
second entity.
3. Many to one: one or more instance of first entity is related to exactly one
instance of second entity.
4. Many to many: many instances of first entity to many instances of second entity.
The overall logical structure of database can be expressed graphically by an ER-Diagram
which is build up by following component
Component Represents
1. Rectangle Entity set
2. Ellipses Entity attribute
3. Diamond Entity relationship
4. Lines link between entity
CHARACTERISITICS OF ER-MODEL Abstraction: it is the simplification mechanism. It is used to hide super flow details of
set of object. It allows one to consternate on the property that are interested in the
application. Example – car is an abstraction of personal vehicle but doesn’t revel details
about model year of manufacturing colors and so on.
There are two main abstraction mechanism used in:-
Generalization: it is an abstraction process of set of object as a single general
characteristics of any specific entity while ignoring the basic details related to it is the
union of no of lower level entities types for the purpose of producing a high level entity
set. Eg: STUDENT is generalization of graduate and undergraduate STUDENT can be
part time or full time.
Specialization: it is an abstraction new characteristic of an existing class of object to
create one or more new classes of object. This involves taking a higher level entry and
using additional characteristics generating by lower level entity. The lower level entity
also inherits the chrematistics of higher level entities specialization may be seen as
reverse process of generalization.
The entity set EMPloyee is a generalization of full time EMP. And part time EMP full
time EMP is again a generalization of faculty and staff where as part time EMP. Is
generalization of teaching and non-teaching EMP. The top down approach in the the
diagram represent specialization and bottom up approach represent generalization.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
11
Aggregations: it is the process of compiling information on an object and there by
abstracting higher level object.
Example- an entity PERSON is derived by aggregating the charactisicts like name,
address, phone no, another form of aggregation is the abstraction between the object and
relationship. Example: enroll is the relationship between two entitles students and course.
This whole relationship may be viewed as entity
.
HERARICHAL MODEL In the hierarchal database model data is organized in a hierarchal in a ordered tree
structure and the database is a collection of disjoint tree list organization chart. A
hierarchal is a ordered tree and it is a easy to understand. At the root of the tree their have
none. One or more then one child mode. The mode of the tree represent the record type
each tree efficiency representing a root record type. It we define the root record type to be
level zero then the level of its dependent record type can be defined as level-1 . the
dependence of record type at level are set to be level-2 and so on. An occurrence of
hierarchal tree type consist of one occurrence of root record type along with zero or more
accuracy of its dependent sub tree, each type dependent sub tree in true, hierarchal and
consist of record type as its root node, the node having no child means that there is no
dependent node on it is known as leaf node. Hierarchal mode represent a one to many
relationship between two entities whose both the entity have child and parents.
ADVANTAGES 1. Simplicity:in this form data is easy to represent and understand
2. Security:the data base system can enforce various degree of security feat users
3. Database integrity: because of inheritance feature the degree of integrity is high
4. Efficiency:for one to many relationship type of database it is easy to maintain and
manager all the sub entities and children.
DISADVANTAGES 1. Complexity of implementation: the actual implementation of hierarchal database
depends upon the physical storage of data. This makes implementation
complicated.
2. Difficulty in management: the movement of data segments from one location
causes all excising program to be modified making database management a
complex affair.
PERSON
NAME
ADDRESS PHONE NO
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
12
3. Structural dependency: the database has a rigidly defined relationship and hence
any change in any part of the structure of database would access it. This makes
the maintained very difficult.
4. Complexity of programming: programming at his kind of database is relatively
complex because the programmers must know the physical path of data item.
5. Poor probability: the database is not so portable because of their complex
implementation.
NETWORK MODEL
Network model was developing during 1980 by database task group. A network database
consists of collection of records connected to one another through links. A relationship in
this model is known as set. A link is association between process b/w two records. A link
can be viewed as restricted binary form of relationship. The structure of network database
resemble closely with hierarchal. The major difference between the two is that the
hierarchal database each record can have only one parent. But there can be more parent in
the network database model. Therefore the relationship represent the hierarchal database
is one to many but in network database it could be many to many.
NAME STREET CITY A/C
NO
BALANCE
Neha 86-trinagar Delhi 5-56 60000
Amit a-1 Rohini Delhi 5-52 50000
rohit 45-s
Azadpur
Delhi 5-51 40000
ADVANTAGES
1. Simplicity: since most of the database relationship instances are naturally many
to many this database structure is simple to design
2. Better relationship handling: many to many relationship can accommodate most
of the complex relationship existing in actual data relationship scenario
3. Flexibility in data access: data item can be navigated in more than one way
providing much desired flexibility of data access.
4. Standards: Universal standard have been developed and enforce in these types of
database.
DISADVANTAGES
System complexity:
Structural dependency: since access depends upon the navigational path that exist in
database at any time. The programs are not independent of database structure and need to
be modifying whenever database structure is modify.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
13
RELATIONAL MODEL Relational model was introduced in 1970 by Dr. E. I. Codd. This data model was evolved
using theoretical considerations based on relation calculus by being simple in principle
and the sure can express their queries by using powerful query language. In this model
the relation is the only construct to represent the association among the attributes of any
entity as well as the relationship among the different entity the one of the main reason for
this introducing the model was too increase the productivity of the application program
by eliminating the need of change of application program when change is made to
database users need not to know the exact physical structure to use the database and
protected any change made to these structure they are however still require to know how
the data has been partition into various relation. In this model the user need not to know
the navigational path to data.
Row of the relation are referred as topple and column are referred as attributes each
attribute of a relation has a distinct name the values for a attribute or a column are drawn
form a set of value know as domain. A relationship between the two relation is represent
as ER model by combining primary key of entity involved in the relation and attribute a
correspondence between the two relation is implied by data value of the attribute. In he
relation defined on common domain.
POSITION
EMPLOYEE
EMP NAME DESIGNATION
101 NEHA MANAGER
102 ANJU FACULTY
103 AMIT DIRECTOR
104 PRIYA FACULTY
105 ROHIT MANGER
In this example both EMPloyee and position contain identical name attributes designation
defines on common domain; consequently we join these two relations to form a new
relation position eligibility using common values of attributes designation. Joining the
two or three times taking the value two or there time.
POSITION ELIGIBILTY
EMP_NO POS_NO NAME DESIGNATION
101 301 NEHA MANAGER
PO_ID DESIGNATION
301 MANAGER
302 DIRECTOR
303 FACULTY
304 MANGER
305 FACULTY
306 MANAGER
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
14
101 304 NEHA MANAGER
101 306 NEHA MANAGER
102 305 ANJU FACULTY
102 305 ANJU FACULTY
103 302 AMIT DIRECTOR
104 303 PRIYA FACULTY
104 305 PRIYA FACULTY
105 301 ROHIT MANAGER
105 304 ROHIT MANAGER
105 306 ROHIT MANAGER
ADVANTAGES OF RDBMS
1. Structure independence: since there is no need of navigational arrangement for
data access, this database offers complete structural independence. Any change in
the structure of database doesn’t effect DBMS data access mechanism the
program therefore doesn’t need any modification even when the structure is
modify.
2. Simplicity of design and use: relational database providing data independence
and strut aural independence therefore design and implementation is easier then
other type of database.
3. Advance query capability: query in database system is very simple highly
efficient and very powerful tool. It support SQL because both of their foundation
in relational algebra and relation calculus.
DISADVANTGAE System Overhead: Relational database has one disadvantage I,e it increase overhead on
system because it has to handle most of the responsibility of users.
OBJECT ORIENTED DATA MODEL With the popularity of object oriented technology the need for object oriented database
arise when database capability are integrated with OOP’s language it is known as object
DBMS an ODBMS makes database object appears as programming language object in
one or more oops language with the feature of DBMS like concurrency control, data
recovery and advance query capability. Some of the example of object oriented language
is:-
C++, C#, JAVA ODBMS provides low cost development and bets performance
combination when using the object oriented language because they stored object on disk
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
15
and have transparent program integration with OOP’s. this is because ODBMS store
exactly the same object code I, e used by application program.
ADVANTAGES
There are two benefits of using objects oriented data model. The benefits I that when we
used object based model we have to write less code than if we were writing to DBMS.
The reason for less amount of code is that program written I n java or C++ need not to
translate in any other code.
The second benefits is related to production if we are working in complete and complex
data on ODBMS give better performance which is thousand times faster than RDBMS
because when the data is read off the disk is already in a format I,e used by java or C++
so on translation is required.
OBJECT RELATIONAL DATA MODEL
This model support object oriented and relational concept in this model it is possible to
provide well define interface for the application it facilitates the reusability of data object
a structure once created can be sense which is the fundamental property of object oriented
data model. Oracle is the best example of this kind of model.
ADVANTAGES
1. Simplicity of design: Because of object oriented this approach is orientation
approach is simple to design
2. Data base integrity: it is assured to the maximum level because of inheriting
saving of object.
3. Symantec content handling: object orientation of data in object oriented
database carriers proper meaning of each and every object.
4. Structure to data independence: object relational database provide structure and
data independence.
DISADVANTAGES
1. Increase system overhead:
2. Lack of standards: object oriented data model does not therefore object
relational database uses specific standard.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
16
CHAPTER-3
Relational data manipulation
INTRODUCTION
This model was introduce be TODCORK ins 1970 that user the concept of mathematical
hence the database is considered as a collection of relations. A relation is a table where
each row represent a set of data values. A row in the table called tupple and columns are
attributes. A relational schema (R) is denoted as R(A1,A2,A3….Ai)
Where R is denoted as R(A1,A2,A3….) where R is relation name and A stands for
attributes. The degree of relation depends upon the number of attributes used in a
relation. For e g. In a relational schema students (roll no, name, course) there are 3
attributes so the degree of relation will be three.
CHARACTERSTIC OF RELATION
1. A tupple can be considered as set of attributes and value.
For e.g. t1(<Roll No, 101>,<Name, Amit>,<Course, BCA>)
2. Tupple odering is not a part of relation
for e.g. t1(<name, Amit>,<Roll No,101>,<Course, BCA>)
RELATIONAL MODEL NOTATION
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
17
1. A relational schema R1 is denoted as R(A1,A2,…….Ai)
2. A tupple in a relation is denoted as t1=(V1,V2,………Vi)
3. The letter Q,R,S denotes relation name.
4. The letter t,u,v denotes tupple.
5. An attributes A can be qualified with the relation name R using the denotes tupple
For e.g. student, Roll no, Student, Name
1) DOMAIN CONSTRAINTS The set of all the values that an attribute can accept is known as domain of attributes.
The domain constraint specify that the value of each attributes Ai must be atomic
domain or dom(Ai) atomic domain are general set such as set of integers real no
character string and so on. Domain on any attribute restrict the attribute from taking
the value other then the set of domain domain constraints for e.g an attributes name
can have data type string or its length could be 10 character long. Another constraint
that applied on any attributes is NULL constraint. The absence of particular attribute
values in a tupple is expressed by NULL, present the value is not attributes. But if not
null constraint is applied on attribute then it cant accept NULL values i,e there must
be any value in all tupple of that attributes.
2) ENTITY INTEGRITY CONSTRAINT It implies that if an attribute A of a relation R is a primary attribute then A can’t
accept NULL value this constraint is applied on primary key and restrict it from
having NULL value become if any instance of primary key are permitted to have
NULL then the key cant be used as a unique key.
ID Name
101 Amita
@ Anjali
104 Ajay
107 Anirudh
110 Arjun
3) REFERENTIAL INTEGRITY CONSTRAINTS
Referential integrity constraint status that two relations referred to each other then a
relation having a foreign key which is a primary key of another relation must have a
value which is from set of value from table in which it is a primary key or it may be null.
This rule is concerned with the foreign key that is with the attribute of a relation having
domain that are those of primary key of another relation. Suppose these are two relations
S and R. R refers to the relation and S to the set of attribute that form a primary key of a
ID Name
101 Rohit
102 Ankit
103 Anshul
104 Amita
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
18
relation S. This set of attribute R is known as foreign key in a tupples the value of foreign
key in tupples in R must either be equal to the value of primary key of S or it could be
NULL.
EMPLOYEE
EMP_CODE NAME MGR_ID
E101 Amit M101
E102 Anjali M101
E103 Anju M102
E104 arjun @
MANAGER
Mgr_ID Name
M101 Kiran
M102 Rohit
M103 Rohan
M104 Ritu
M105 Karan
Here relation EMPloyee refers to the relation manager through mgr_id which is the
primary key of manager. So manager Id is a foreign key of EMPloyee relation.
SET ORIENTED OPERTAION
Set Operator Description Pseudo Examples
SELECT Returns all rows in a table that
match a certain criteria
SELECT from A where C2 is equal to 1 = R-5
PROJECT Returns all values for selected
attributes, showing a vertical
view of a table.
PROJECT C1 for table A = R-6
JOIN Combines two or more tables,
using natural, equi, theta, left
outer or right outer joins.
A JOIN E ON C1 and C3 (natural) = R-7
A JOIN E (left outer) = R-8
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
19
A JOIN E (right outer) = R-9
UNION Combines all rows in one table
with all rows in another table,
without including duplicates.
A UNION B = R-1
INTERSECT Compares two tables and
combines only the rows that
appear in both tables
A INTERSECT B = R-2
DIFFERENCE
Compares to tables and
returns all rows that are found
in the one, but not the other
table.
A DIFFERENCE B = R-3
PRODUCT
Create all possible pairs of
rows from two tables,
resulting in the Cartesian
Product
A PRODUCT E = R-10
DIVIDE
Weird operator, where the
one table has two columns
and the other table one
column. Returns value of
Column 2, which is associated
with every value of Column 1
in both Table 1 and 2. Weird ...
C DIVIDE D = R-4
SET OPERATIONS
There are two groups of operations:
• Mathematical set theory based relations:
UNION, INTERSECTION, DIFFERENCE, and CARTESIAN PRODUCT.
• Special database operations:
SELECT (not the same as SQL SELECT), PROJECT, and JOIN.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
20
• SELECT
SELECT is used to obtain a subset of the tupples of a relation that satisfy a
select condition.
For example, find all EMPloyees born after 1st Jan 1950:
SELECT dob '01/JAN/1950'(EMPloyee)
• PROJECT
The PROJECT operation is used to select a subset of the attributes of a relation by
specifying the names of the required attributes.
For example, to get a list of all EMPloyees surnames and EMPloyee numbers:
PROJECTsurname,EMPno(EMPloyee)
• SELECT and PROJECT
SELECT and PROJECT can be combined together. For example, to get a list of
EMPloyee numbers for EMPloyees in department number 1:
Figure : Mapping select and project
Examples:-
Consider two relations R and S.
• UNION of R and S
The union of two relations is a relation that includes all the tupples that are either
in R or in S or in both R and S. Duplicate tupples are eliminated.
• INTERSECTION of R and S The intersection of R and S is a relation that includes all tupples that are both in R
and S.
• DIFFERENCE of R and S
The difference of R and S is the relation that contains all the tupples that are in R
but that are not in S.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
21
SET OPERATIONS - REQUIREMENTS
For set operations to function correctly the relations R and S must be union compatible.
Two relations are union compatible if
• They have the same number of attributes
• The domain of each attribute in column order is the same in both R and S.
UNION Example
Figure : UNION
INTERSECTION Example
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
22
Figure : Intersection
DIFFERENCE Example
Figure : DIFFERENCE
CARTESIAN PRODUCT
The Cartesian product is also an operator which works on two sets. It is sometimes called
the CROSS PRODUCT or CROSS JOIN.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
23
It combines the tupples of one relation with all the tupples of the other relation.
CARTESIAN PRODUCT example
Figure : CARTESIAN PRODUCT
JOIN Operator
JOIN is used to combine related tupples from two relations:
• In its simplest form the JOIN operator is just the cross product of the two
relations.
• As the join becomes more complex, tupples are removed within the cross product
to make the result of the join more meaningful.
• JOIN allows you to evaluate a join condition between the attributes of the
relations on which the join is undertaken.
The notation used is
R JOINjoin condition S
JOIN Example
Figure : JOIN
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
24
NATURAL JOIN
Invariably the JOIN involves an equality test, and thus is often described as an equi-join.
Such joins result in two attributes in the resulting relation having exactly the same value.
A `natural join' will remove the duplicate attribute(s).
• In most systems a natural join will require that the attributes have the same name
to identify the attribute(s) to be used in the join. This may require a renaming
mechanism.
• If you do use natural joins make sure that the relations do not have two attributes
with the same name by accident.
OUTER JOIN
Notice that much of the data is lost when applying a join to two relations. In some cases
this lost data might hold useful information. An outer join retains the information that
would have been lost from the tables, replacing missing data with nulls.
There are three forms of the outer join, depending on which data is to be kept.
• LEFT OUTER JOIN - keep data from the left-hand table
• RIGHT OUTER JOIN - keep data from the right-hand table
• FULL OUTER JOIN - keep data from both tables
OUTER JOIN example 1
Figure : OUTER JOIN (left/right)
OUTER JOIN example 2
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
25
DIFFRENCE OF DBMS AND RDBMS
DBMS:
1)In DBMS no relationship concept
2)It supports Single User only
3)It treats Data as Files internally
4)It supports 3 rules of E.F.CODD out off 12 rules
5)It requires low Software and Hardware Requirements.
6)FoxPro, IMS are Examples
RDBMS:
1)It is used to establish the relationship concept between two database objects, i.e,
tables
2)It supports multiple users
3)It treats data as Tables internally
4)It supports minimum 6 rules of E.F.CODD
5)It requires High software and hardware requirements.
6)SQL-Server, Oracle are examples
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
26
CHAPTER-4
Relational database design
HOW TO DESIGN A DATABASE
PURPOSE The problem with data is that it changes. Not just its individual items' values change, but
their structure and use, especially when kept over extended periods of time. Even for
public records that may have been kept for hundreds of years, there are occasionally
changes in what data elements are captured and recorded and how.
Therefore, a method to avoid problems due to duplication of data values and modification
of structure and content has been developed. This method is called normalization.
You normalize a database in order to ensure data consistency and stability, to minimize
data redundancy, and to ensure consistent updatability and maintainability of the data,
and avoid update and delete anomalies that result in ambiguous data or inconsistent
results.
SOME KEY CONCEPTS
Before we continue, I would like to show the correlation between the formal names of
Tables, Rows, and Columns in Relational Theory and their more common counterparts:
Formal Name Common Name Also Known As
Relation Table Entity
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
27
Tuple Row Record
Attribute Column Field
A PRIMARY KEY is one or more columns whose values uniquely identify a row in a
table (See rule #2 above).
A CANDIDATE KEY is one or more columns whose values could be used to uniquely
identify a row in a table. The Primary Key is chosen among a table's Candidate Keys.
RELATIONAL DATABASE DESIGN
The process of obtaining a set of relation along with respective control if any is known
as database design although tables will suffer from a no of difficult when database
operation are perform on them subsequently this indicates bad database design. A good
database design doesn’t have such problem clearly different designer would arrive at
different design one being better then other in some aspects exactly what makes a
database design good is that it offers both space efficient and process efficiency. Could
be taken as reasonably good designer in other word database should occupies minimum
storage space and yet eliminate the following problem.
1. Redundancy
2. Inconsistency
3. Insertion Anomalies
4. Deletion
5. Modification
6. Functional Dependency
7. Un-Normalization
NORMALISATION
Normalization is the formalization of the design process of making a database compliant
with the concept of a Normal Form. It addresses various ways in which we may look for
repeating data values in a table. There are several levels of the Normal Form, and each
level requires that the previous level be satisfied.
The normalization process is based on collecting an exhaustive list of all data items to be
maintained in the database and starting the design with a few "superset" tables.
Theoretically, it may be possible, although not very practical, to start by placing all the
attributes in a single table. For best results, start with a reasonable breakdown
Normalization the goal of relation database to generate a set of relation that allows
storage of information without unnecessary redundancy yet permits to retrieve
information easily the right approach is to design the schema as that are in appropriate
normal form some of the process of removing functional dependency from a relation is
know as normalization. It is processes of organizing the data in database in such a way so
as to protect all the rules or guide line of database design and to eliminate the problem
like data redundancy and operating anomalies it is basically a process of decomposability
method in which a relation having under desirable dependency is split into two or more
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
28
relation and their by removing the undesirable effect of existing dependency relation are
to be attendant during the life time of database we don’t lose any information or don’t
introduce any inconsistency the type of attention normally needed are:-
1. Insertion of new data value to a relation these should be possible without being
force to leave blank field for some attribute.
2. Deletion of tupples should be possible without loosing any vital information.
3. Updating a value of an attribute in a tupple this should be possible without
extensive searching of all the tupple in the relation.
FIRST NORMAL FORM If the value of a relation instance is atomic for every attribute in a relation then
relation is said to be in first normal form. The attribute item line is not a single
attribute but it is composed of many attribute besides this is the number of item line is
variable this form is not suitable for storage as a file in a computer further retrieval of
data is difficult to fine out how many item with a specified item code are ordered one
must breakup the composite attribute first before attEMPting a search that way this
relation is said to be un normalized to normalized this relation a composite attribute is
converted into individual attribute after doing this common value for a composite
attribute are duplication as many time as there are line in composite attribute.
ORDER NO ORDER
DATE
ITEM
CODE
QUNTITY PRICE/UNIT
101 020199 111 52 50
101 020199 333 30 60
101 020199 222 20 17
102 040299 444 45 20
102 040299 333 30 60
103 120499 333 40 60
The above form this form is also called that file as there are no composite attribute
and every attribute single and describe one property.
Functional dependency: ORDER NO� Order Date
ITEM CODE�Price
ORDER NO �Item code�Quantity
SECOND NORMAL FORM
A relation is said to be in second normal form if it is in first normal form non-key
attribute is functionally dependent on key attribute if the key has more then one
attribute then no non-key attribute. The above example is in first normal form in
which key is order no. and item code. The following dependency is existing in the
table.
ORDER NO���� Order Date
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
29
ITEM CODE����Price
ORDER NO ����Item code����Quantity
Here a non-key attribute quantity is dependent on order no and item code but order
date which is a non-key attribute is dependent on order no which is a part similarity
price is also dependent on item code. Which is again a part of key? Those two non-
key attribute are dependent only on part of key. Those two of key but not on whole.
This relation is not in second normal form it can be transaction to second normal form
by splitting it into there.
ITEM ORDER
ORDER
NO
ORDER
DATE
101 020199
102 040299
103 120499
ORDER
NO
ITEM
CODE
QUNTITY
101 111 52
101 333 30
101 222 20
102 444 45
102 333 30
103 333 40
After transforming the relation form first normal form to second normal form repetitive
data like order date has been remove further if an order for an item is cancelled the price
of an item is not lost.. for example if the order no 102 for the item code 444 is removed in
first normal form table then the forth row will be remove and the price of item is lost but
after converting it in second normal form this with not be a problem.
THIRD NORMAL FORM
A relation is said to be in third normal form if it is in 2nd
normal and non-key attribute of
a relation is functionally dependent on any other no-key attribute.
ITEM
CODE
PRICE/
UNIT
111 50
222 17
333 60
444 20
ROLL NO NAME DEPARTMENT YEAR HOSTEL
101 Neha Physical Edu 1 Ganga
102 Priya Chemistry 1 Ganga
103 Lalit Maths 2 Krishna
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
30
Here roll no is the key and all the other attribute re functionally dependency on it this
table is in second normal form in which it known that in the. Collage the first year
students are accommodated in Krishna and year student in Krishna and third year in
Kaveri and year in Godawari them non-key attribute hostel name is department on key
attribute year.
The dependency of hostel name on year Leeds to duplication of data. If it is decided to
ask all the first year student to move to Kaveri hostel all the second year student to move
to Ganga hostel this change should be made at many place also if the student roll no 106
left the collage the information regarding Godawari hostel is deleted so this table is not in
third to transform third we will introduce another relation which include the functionality
related to non-key attribute.
ROLL
NO
NAME DEPARTMENT YEAR
101 Neha Physical edu 1
102 Priya Chemesrty 1
103 Lalit Maths 2
104 Nitin Botany 2
105 Mohit Geology 3
106 Kunal Zoology 4
YEAR HOSTEL
1 Ganga
2 Krishna
3 Kaveri
4 Godawari
104 Nitin Bootany 2 Krishna
105 Mohit Geology 3 Kaveri
106 Kunal Zoology 4 Godawari
ROLL NO
NAME
DEPT
YEAR
HOSTEL
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
31
BOYCE CODD NORMAL FORM
Reduce third normal form entities to Boyce/Codd normal form (BCNF) by ensuring
that they are in third normal form for any feasible choice of candidate key as primary
key.
In short, Boyce Codd normal form (BCNF) addresses dependencies between columns
that are part of a Candidate Key. Some of the normalizations performed above may
depend on our choice of the Primary Key. BCNF addresses those cases where applying
the normalization rules to a Candidate Key other than the one chosen as the Primary Key
would give a different result. In actuality, if we substitute any Candidate Key for Primary
Key in 2NF and 3NF, 3NF would be equivalent with BCNF. In a way, the BCNF is only
necessary because the formal definitions center around the Primary Key rather than an
entity item abstraction. If we define an entity item as an object or information instance
that correlates to a row, and consider the normalization rules to refer to entity items, this
normal form would not be required.
EXAMPLE:-Consider a scenario of a large development organization, where the
projects are organized in project groups, each with a team leader acting as a liaison
between the overall project and a group of developers in a matrix organization. Assume
we have the following situation:
• Each Project can have many Developers.
• Each Developer can have many Projects.
• For a given Project, each Developer only works for one Lead Developer.
• Each Lead Developer only works on one Project.
• A given Project can have many Lead Developers.
In this case, we could theoretically design a table in two different ways:
ProjectNo Developer Lead Developer
20020123 John Doe Elmer Fudd
20020123 Jane Doe Sylvester
20020123 Jimbo Elmer Fudd
20020124 John Doe Ms. Depesto
Case 1: Project Number and Developer as a Candidate Key can be used to determine the
Lead Developer. In this case, the Lead Developer depends on both attributes of the key,
and the table is 3NF if we consider that our Primary Key.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
32
Lead Developer Developer ProjectNo
Elmer Fudd John Doe 20020123
Sylvester Jane Doe 20020123
Elmer Fudd Jimbo 20020123
Ms. Depesto John Doe 20020124
Case 2: Lead Developer and Developer is another Candidate Key, but in this case, the
Project Number is determined by the Lead Developer alone. Thus it would not be 3NF if
we consider that our Primary Key.
In reality, these three data items contain more than one relation (Project - Lead Developer
and Lead Developer - Developer). To normalize to BCNF, we would remove the second
relation and represent it in a second table. (This also illustrates why a table is formally
named a relation.)
FOURTH NORMAL FORM
Reduce Boyce/Codd normal form entities to fourth normal form (4NF) by removing
any independently multivalued components of the primary key to two new parent
entities. Retain the original (now child) entity only if it contains other, nonkey
attributes.
Where BCNF deals with dependents of dependents, 4NF deals with multiple,
independent dependents of the Primary Key. This is a bit easier to illustrate. Let us say
we wanted to represent the following data: Manager, Manager Awards, and Direct
Reports. Here, a Manager could have multiple Awards, as well as multiple Direct
Reports. 4NF requires that these be split into two separate tables, one for Manager -
Awards, and one for Manager - Direct Reports. We may need to maintain a Managers
table for other Manager attributes.
This table:
Lead Developer Developer
Elmer Fudd John Doe
Elmer Fudd Jimbo
Sylvester Jane Doe
Ms. Depesto John Doe
ProjectNo Lead Developer
20020123 Elmer Fudd
20020123 Sylvester
20020123 Elmer Fudd
20020124 Ms. Depesto
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
33
Manager Awards Direct Reports
Scrooge McDuck Stingy John Donald Duck
Minnie Mouse Mouse of the Month Mickey Mouse
Minnie Mouse Mouse of the Year Pluto
Clara Goofy
becomes two tables:
Manager Awards Table
Manager Awards
Scrooge McDuck Stingy John
Minnie Mouse Mouse of the Month
Minnie Mouse Mouse of the Year
Clara
Direct Reports Table
Manager Direct Reports
Scrooge McDuck Donald Duck
Minnie Mouse Mickey Mouse
Minnie Mouse Pluto
Clara Goofy
FIFTH NORMAL FORM
Reduce fourth normal form entities to fifth normal form (5NF) by removing pair wise
cyclic dependencies (appearing within composite primary keys with three or more
component attributes) to three or more parent entities.
This addresses problems that arise from representing associations between multiple
entities with interdependencies. Making it 5NF consists of adding parent tables, one for
each meaningful combination that has children in the original table.
A table with such information is 5NF if the information cannot be represented in multiple
smaller entities alone.
An example of such a situation may be the representation of Actors, Plays, and Theaters.
In order to know who plays what and where, we need the combination of these three
attributes. However, they each relate to each other cyclically. So to resolve this, we
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
34
would need to establish parent tables with Actor - Play, Play - Theater, and Theater -
Actor. These would each contain a portion of the Primary Key in the Actor, Play, and
Theater table.
Actor Play Theater
Billy Bob Catcher in the Rye West 42nd
Ann Catcher in the Rye West 42nd
John Catch-22 Broadway
Lily Hamlet Broadway
Lisa Cats West 42nd
Andy Cats Darlington
FUNCTIONAL DEPENDENCIES NOW are going to discuss functional Dependencies.
For our discussion on functional dependencies assume that a relational schema has attributes
(A, B, C... Z) and that the whole database is described by a single universal relation called R
= (A, B, C, ..., Z). This assumption means that every attribute in the database has a unique
name.
What is functional dependency in a relation?
A functional dependency is a property of the semantics of the attributes in a relation.
The semantics indicate how attributes relate to one another, and specify the functional
dependencies between attributes. When a functional dependency is present, the
dependency is specified as a constraint between the attributes.
Consider a relation with attributes A and B, where attribute B is functionally dependent
on attribute A. If we know the value of A and we examine the relation that holds this
dependency, we will find only one value of B in all of the tupples that have a given value
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
35
of A, at any moment in time. Note however, that for a given value of B there may be
several different values of A.
In the figure above, A is the determinant of B and B is the consequent of A. The
determinant of a functional dependency is the attribute or group of attributes on the left-
hand side of the arrow in the functional dependency. The consequent of a functional
dependency is the attribute or group of attributes on the right-hand side of the arrow.
CHAPTER-5
STRUCTURE QUERY LANGUAGE
SQL stands for structured query language and it is also pronounce as SEQUEL. It is the
most popular database query language support SQL. SQL is set of command that
program and user may use to access data within the database tools are used to access
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
36
database without directly using SQL. However theses application also translates the
action into SQL FORMAT.
ADVANTAGE OF SQL
1. NON PROCEDURAL LANGUAGE: It is a non procedural language in that the
user do not have to specify how the SQL Commands work like macros that have
already being written for the user. A non-procedural language is free from writing
algorithm a single command can do the job.
2. UNIFIED LANGUAGE: SQL commands for variety of task which includes the
following.
• Inserting, updating and deleting rows in the table.
• Creating, replacing, altering and dropping objects
• Controlling access to the database and its objects.
• Generating database consistency
• Query data.
3. COMMON LANGUAGE FOR ALL RDBMS: Because all major relational
database system support SQL one can transfer all skills one have gain with SQL
from one database to another since all the programs written in SQL are portable
they can often be moved from one database to another with very little
modification.
4. EMBEDDED SQL : It refers to the use SQL commands embedded with
procedural Programming language embedded SQL is collation of these
commands. RDBMS also provided pre-complier that support embedded SQL
statement that can be understanding by procedural language compiler some of the
pre-compiler are some of the precompiled are as follows
• ADA pre-compiler
• C/C++ pre-compiler
• COBOL pre complier
• FORTAN
• PASCAL
• PL/1 5. DATABASE OBJECT: RDBMS two types of database object.
• Schema object: Schema object is a collection of logical structure of data A
schema is owned by database user and has the some name as that object can
be create and manipulated with SQL and included the following types of
object: cluster, index snapshot procedural view like logs synonymous triggers
functions table.
• Non-schema object: Other types of object are also stored n the database and
can be created and manipulated with SQL but are not containing in a schema.
Profile rollback segments user, roles, table space.
OBJECT NAMING CONVENTIONS:
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
37
1. Name must be from 1 to 30 characters long.
2. Name of database are limited to 8 characters but name of database link can be
long as no character.
3. Naming can’t be contained quotation mark.
4. Name is not case sensitive.
5. A name must begin with a alphabet character.
6. Name can also contain alphanumeric character from the database character set
and the character like fewer than score is not permitted.
7. Name of the database link can also contain dot(.), &.
8. Columns in the same table or view can’t have same name.
OBJECT NAME GUIDELINES 1. Use full, descriptive, pronounceable name or well known abbreviations.
2. Use consistence naming rules.
3. Use the same name to describe the same entity or attribute across the table.
4. Name must be short and self explanatory.
5. Using consistence naming rule help the user to understand each part of table.
VIEW AND INDEXES
VIEW
A view is a customized presentation of data form one or more table view derived through
data from the table on which thy are based it is known as based table all operation
perform on a view actually affect the base table of the view can be use for following
reasons
1. It provides an additional level of table security by restricting access to the
predefined table. For e.g. you can create a view of table that does not include
sensitive data link salary, acc_no, and ID.
2. It hide data complexity database usually include many table and by creating a
view combine information form one or more table can be generated. You can
generate a view i.e. a combination of EMPloyee table a department table.
3. To present the data in difference perception from that the base table view provides
a means to rename the column without affecting the base table for e.g. to store a
complex query a query might perform exclusive calculation with the table
information by sharing this query as a view the calculation are perform only when
the view is query.
INDEXES
An index is used to quickly retrieve information from a database project. Indexes help
you to retrieve specific information faster and it also provide the fast access to the
database. Indexing create an ordering of file consisting of list of record in a logical record
order along with the corresponding physical location in the table indexes are created in
one or more columns of table once creating an index is automatically maintain by data
base system.
SQL COMMAND, SYNTAXES AND USAGE:
SQL command can be categorized the following category:-
1. Data definition language command.
2. Data manipulation language command.
3. Transaction control command.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
38
DATA DEFINITION LANGUAGE: There command allow user to create and
modify various database object. It includes the following tasks:
1. Create objects
2. Delete or drop objects
3. Ground and revoke privilege.
4. Analyses information on table or index.
5. Establish auditing options.
1. CREATE COMMAND: This command is used to create commands to
create a table. The create statements specify the name of table columns
create command is used to create indexes and views.
Syntax:
Create table<table name> (<attribute list>);
E.g.: Create table EMP (EMP_no integer, not_null, name
varchar(10), salary integer, job_description varchar(25))
2. ALTER COMMAND: The definition of existing relation can be altered
by using the Alter statement. This statement allows a new column to be
added in an existing column from the relation and existing column from
the relation and all the values from existing tupple will be deleted.
Relation. The existing tupple of altered relation. Are logically considered
to be assign a null value to the added column alter command is used to
delete an existing column from the relation and all the values from
existing tupple will be delete.
• To add a column
Alter table <table name>
Add (column name data type)
E. g alter table EMP add (dept no integer)
• To delete a column:
Alter table<table name>
Delete (column name data type);
E.g. alter table EMP delete (salary integer)
3. DROP COMMAND: This command is used to delete an existing relation
from database.
Syntax:
Drop table <table name>
E. g drop table EMP; 4. Grant command: This command is used to system privileges to user and
groups.
5. Revoke: This command is used to take system privileges from users and
group.
(B) DATA MANIPULATION LANGUAGE COMMAND:
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
39
DML command query and manipulation data in existing schema object these
command implicitly comment the current transaction. These commands are listed
as follow:
1. INSERT: this is used to insert a new tupple into a specified relation the
value for each field o the record is given through this command.
Syntax:
Insert into <table name> values (<value list>);
E.g.: insert into EMP values (101,’Priya’, 10000,’Programmer’);
2. SELECT: this command is used for data retrieval. It is the only retrieval
command in SQL that specify the method of selecting the tupple which is
selected from the specifies relation by using form keyword and the
selecting is done by using where clause this command perform both
selection and projection.
Syntax:
Select [distinct] <target list>
Form<table name> where <predicate>; The distinct option is used in select command to eliminate duplicate tupple in the
result without this option duplicate tupple may appear in the result.
The target is the method of specifying a projection operation of resultant relation
The form clause specify the relation to be used in evaluation of the statement the
where clause is used to specify the predicate (condition) involving the attributes
of relation appearing in the form clause.
Example:
• Select* form EMP; It will select all the tupple and all the attribute from Employee table.
• Select distinct name from EMP;
It will show all values of name attribute without repeating any value.
• Select EMP_no, Name from EMP
where salary>10000;
• Select EMP_no name form EMP
Order by name dec;
3. UPDATE: this command is used to modify one or more record in a
specified relation. This record to be modified are specified by a predicate
in a where clause of a new value of the column to be modified is specified
be set clauses.
Syntax:
Update<table name>
Set<target value list> where <predicate>;
e.g update EMP set salary=15000 where EMP_no<107;
4. DELETE: this command is used to delete one or more record from the
relation the record to be delete are specified by the predicate in where
clauses.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
40
Syntax:
Delete table <table name>
Where<predicate>
e.g delete EMP where salary<1000;
5. ARITHMETIC AND AGGREGATION OPERATION: SQL provide a
full compliment of arithmetic operators and functions. This include
functions to fine avg minimum maximum sum and to count the total
numbers of occurrences.
1) To get average
Select avg<attribute name> from<table name>;
E.g. select avg (price)
From Product;
2) To get maximum and minimum
Select max <attribute name>, mini<attribute name>
from<table name>;
E.g. select max(price), min(price)
from Product;
3) To count number of occurrence select count <attribute name>
from<table name>
E.g select count(distinct name)
From EMP;
4) To find sum
Select sum<attribute>
From<table name>
Select sum(salary)
From EMP;
(C)TRANSACTION CONTROL COMMAND
These commands are used to manage changed made by data
manipulation language commands.
1) COMMIT: It is used to make permanent the changed made by
statement issued at the beginning of transaction.
2) ROLLBACK: It is used to undo all changes since the beginning of
transaction or since a save point.
3) SAVE POINT: It is used to establish a point back to which you may
roll.
4) SET TRANSACTION: It is used to establish properties for the
current transaction.
ARITHMETIC EXPRESSION: An expression is combination of one or more
values operation and function which evaluate to a value. There are following
arithmetic expression used in SQL add, sub multiple, divide. If your arithmetic
expression contain more than one operation the priority is give to *, /, +,-.
e.g. select EMP_name , sal+250*12 from EMP;
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
41
SQL OPERATORS
1) BETWEEN OPERATOR: It test for value between and inclusive of low
and high range for e.g. We want to see those Employee whose salary b/w
1000 to 2000 we need to perform following query.
Select name salary from EMP.
Where salary b/w 1000 and 2000.
2) IN OPERATOR: It test for value in specified list for e.g to find out all
Employee who have one of the three ID nos. 7902,7566,7788
Syntax
Select<attribute list>
Form<table name> where attribute in(V1,V2,V3….Vn);
e.g select name, salary, ID, from EMP
where ID(7902,7566,7788);
3) LIKE OPERATOR: Sometimes you may not know the exist value to be
searched using the like operator it is possible to select a row that match a
character pattern. Select* from EMP
Where name like ’S%’;
4) IS NULL: This operator specify test for value that are null. For e.g to find
all Employee who have no commission the following query will be given.
Syntax:
Select*from<table name>
Where commission is NULL; is not null
CHAPTER-6
MS-ACCESS
Q1. What is MS Access is?
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
42
Ans: MS-Access is Microsoft database management system is a part of Microsoft office
suite. It is very easy to use because of User-friendly interface mechanism it present
almost all the features and characteristics of relational database management system with
the help of MS-Access.
1. We can create database in a tabular format (RDBMS).
2. Two or more then two table can be joined to enhance or to represent RDBMS
capability.
3. We can create query using MS-Access.
4. We can generate reports on the created database.
5. We can add recorded to new table by using forms on the table.
6. Records from the table can be restricted, manipulated inserted or deleted very
easily.
We don’t need any detailed study to learn and use MS-Access if we have knowledge
about DBMS. We can easily use MS-Access for database creation another advantage of
ms-access is that is compatible with most of the front end programming tools like VB
that is we can create front end part of the s/w using VB and is database can be created
using MS-Access whatever, we add or delete in the forms at front end part it will
automatically updated in the table in the table of DBMS in ms-access. Thus using ms-
access, you can develop a fully functional database application.
We can use MS-Access in the following typical situation:
1. To create telephone directory of contact.
2. To create record of Employee of our organization.
3. To create MIS for our organization etc.
Thus whenever a range volume of data needs to be stored, maintained manipulated and
utilized in various decision- making activates, we can use MS-Access.
Ques2. How would you design database in MS-Access?
Ans: steps:
1. Click at file->new
OR
Click at two new two button on the toolbar
OR
Press Ctrl+N
2. In the task pane, click at Blank database.
3. After that access asks you to close a name and location to save the database enter
the name and relation in the file new database dialogues box and then press ok.
4. Accesses create a blank database and a database window appeared on the screen
having two main parts.
a) Database object tab
b) Database definition commands part.
5. Click on table in object tab it will show three options known database definition
command.
a) Create table in design view.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
43
b) Create table by using wizard.
c) Create table by entering.
6. Design view
a) Click on create table in design view.
b) Then a window for designing:
Table will appears. Enter field names in field name set their data type and
mention their respective meaning. In the lower part of the window, there
are various option through which you can put constraints on datable fields
also set on field as primary key by right clicking on it and then select
primary key option.
c) After finishing the structure definition click at the close button of the
table window. Then access ask ”Do you want to save the change to the
design of the table if pres yes button then a dialogue appears that ask
then name of the table enter the appropriate name and press ok
button.”
(B) Wizard
1. Click on “create table by using wizard”.
2. Then a dialogue box named table wizard appeared on the screen
• Select table type-business or personal.
• Select table name from same table.
• Select sample field one by one and press button.
• If you want to rename the fields then select the field and press rename
field button and then give it a new name. Finally press next button to
move ahead.
Then the dialog box access the name for your table gives an appropriate name. it also ask
for the setting the primary key if you select-
Yes set a primary key for me. Then system set a primary key for your table and if you
select click to finish.
DESIGN VIEW
Click on create table in design view
Then a window for designing
Table will appear in feature field comes in field name set their data type and match their
respective meaning in the lower part of the window there are various option through
which you can put constraint on data type also put constraint on data type
Ques3: Who do you mean by Queries in MS-Access? Explain types how query
quires created using a wizard how would you create multi table query in access?
Ans: The primary accurate inform in a proper format the efficiency of a database is
determined by the speed with which it retrieve data and present it in a user
defined format the process of accessing the database and retrieving data
selectively is known as querying.
A query is a database objective that create a datasheet of specified field and
record form one or more table. A query display the answer to a question about the
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
44
data in our data base although table store all data though which we can vie any
required data but with the help o query we can have data in the format specified
by us and also it provide the facility to view data on the specified criteria queries
behaves and appear just like a table but one important difference between a table
and a query is record while a query is stored with only selected recorded and this
selection with is based on some criteria also a query on have record form more
than one table.
Type of queries:- Access provide many different type of queries they can be
grouped into six basic categories.
1. Select query: it is used to extract only specified and selected fields form one or
more table.
2. Parameter Query: it is used to extract data form the table on the basis of
specified criteria can be more than one.
3. Cross tab query; it is used to display summarized valued sum, count, avg of both
the row and columns on the query.
4. Action Query: it is used to perform on action on record that meets the criteria
specified in the query object.
5. SQL Query: it is created using SQL statement is a database query language that
can be used to specify multiple table joins on the bass of foreign key record
selection oriented and data grouping.
Ques4: Write steps to create form using wizard and through Auto format.
Ans: Form through wizard 1. Select form tab form database object tabs in database window.
2. Click crate form by using wizard.
3. A dialogue box named form wizard: A dialogue box named form wizard appears
on the screen in which select your form table Queries combo box.
4. After that select the field of the table which you would line to include in the form
use < or > to more a single field and << or >> to move all the fields after that
press next.
5. There appeared a dialogue box that show a list of various types of forms layout
like columns tabular datasheet, justified etc. Select any one of them then press.
Next button.
6. In the next dialogue box select the style of the form the given list of bytes. Then
press next button.
7. In the next window five the title to your form and then press finish button.
Forms using auto form 1. Click on form in database object tab in database window.
2. There appear an icon named ”new” in the toolbar of the database window click
on new.
3. A dialogue box named new form appears choosing various options to prepare
form select.
• Auto form: columnar
• Auto form: Tabular
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
45
• Auto form: Datasheet 4. This dialoged box also asks the table name on which you have to prepared report
select appropriate table name form the list.
5. After that appears a form showing field of the selected table or query.
6. It the format chosen is columnar then the files are show in columnar then the files
are shown in columnar format and you can insert the data one by one for each
tupple you can move forward and backward by using or button retentively the
record number show in between these buttons tells which record number your are
viewing.
• The form in columnar format: It show having 5 record to insert new record
click > button 4 times to insert sixth record and if you want to see any previous
record press < button. After inserting record save the form by clicking file –then
save or by pressing ctrl +s or save icon on tool bar.
• If the format chosen is tabular: Then the fields are shown in tabular format.
Again you can move backward, forward and by using > and < buttons
respectively. The record number again shown at which record number again
shown at which record number you are inserting value.
Again the button has the same functioning at present we at data number of 2.
• If you choose the data sheet & as you in insert data inv the datasheet in same way
you insert data in the datasheet in same way you insert data in same way you
insert data in the form.
Ques5: what do you mean reports in MS-ACCESS write steps to create report
using wizard and using auto report.
Ans: A report is an effective way to present your data in a printable format. It provide
a flexible way of viewing and printing summary information with the help of report
we can have detained information at the required level picture, graphics, statically
evaluated can be inserted in report to mark it more printable.
The information on a report may be derived table queries report are used for:- 1. Presenting information in a customized way both on screen and on paper.
2. Grouping and sorting data according to your need and in order toy want.
3. Calculating avg, fields’ tool and drawing groups.
Important point to be kept in mind while planning for reports:
Generally hard copy of the report is used to communication database information
with manager, Employee and client. A clearly designed and well organized report is
required to present the database information in an effective manner >
Following point should be kept in mind while designing a report. 1. Identify a meaningful title for the report.
2. Determine he fields and members that the report will present.
3. Decide how those fields should be sorted and grouped within the report.
4. Determine how the records should be sorted a grouped within the report.
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
46
5. Identify any other description information that should be placed at the end of
the report or at the top or bottom of each page of report.
Type of report 1. Tabular reports
2. Columnar report
3. Mailing labels.
Reports using wizard 1. Click on report on the database object tab of database window.
2. Click on create report by using wizard.
3. After that a dialogue box named report wizard appear on the screen in which
select your report from table/ queries combo box.
4. After that select the fields of the table which you would like to include in the
form. Use< and > to move b/w records.
5. Then appears a dialogue box that requires grouping information select the
fields which will be used for grouping the record. Click next button.
6. Then a dialogue box appears in which you can give sorting information. You
can sort your data for sport in ascending or descending order. Click next to
more ahead.
7. Next dialogue box lets you select tabular layout or portrait orientation select
which you like and click next.
8. Now select the print style of the report form the built in list click next.
9. Give name to report and click finish button. Finally report will be presented
on your screen.
Report using auto report.
1. Click on report in database object tab in database window.
2. There appears on icon named new or click inserts then form.
3. A dialogue box named new report appearing having various new option to
prepare the report select.
• Auto report: columnar
• Auto Report: Tabular
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
EDUPROZ INSTITUTE OF PROFESSIONAL STUDIES
SECTOR-7,DWARKA
47