DBMS Unit-1
DBMS Unit-1
➢ One-to-many relationships.
2. Network model:
Advantages:
➢ Network model is able to model complex relationships and
represents semantics of add/delete on the relationships.
➢ Can handle most situations for modeling using record types and
relationship types.
➢ Language is navigational; uses constructs like FIND, FIND member,
FIND owner, FIND NEXT within set, GET etc. Programmers can do
optimal navigation through the database.
Disadvantages:
➢ Navigational and procedural nature of processing.
Conceptual schema:
▪ The conceptual schema(also called as logical schema) describes the stored
data in terms of the data model of the DBMS.
▪ In a relational DBMS, the conceptual schema describes all relations that
are stored in the database.
▪ In our sample university database, these relations contain information
about entities, such as students and faculty, and about relationships, such as
students’ enrollment in courses.
Students(sid: string, name: string, login: string, age: integer, gpa:
real)
Faculty(fid: string, fname: string, salary : real)
Courses(cid: string, cname: string, credits: integer)
Rooms(nw: integer, address: string, capacity: integer)
Enrolled (sid: string, cid: string, grade: string)
Teaches (fid: string, cid: string)
The choice of relations, and the choice of fields for each relation, is not always
obvious, and the process of arriving at a good conceptual schema is called
conceptual database design.
Physical Schema:
▪ The physical schema specifies storage details.
▪ It summarizes how the relations described in the conceptual schema are
actually stored on secondary storage devices such as disks and tapes.
▪ Decides what file organizations to use to store the relations and create
auxiliary data structures, called indexes, to speed up data retrieval
operations.
▪ A sample physical schema for the university database is to store all
relations as unsorted files of records.
o Create indexes on the first column of the students, faculty and
courses relations, the salary column of faculty, and the capacity of
column of rooms.
External Schema:
▪ This schema allows data access to be customized at the level of individual
users or groups of users.
▪ A database has exactly one conceptual schema and one physical schema,
but it may have several external schemas.
▪ An external schema is a collection of one or more views and relations from
the conceptual schema.
▪ A view is conceptually a relation, but the records in a view are not stored
in the DBMS.
Data Independence
A very important advantage of using a DBMS is that it offers data
independence. That is, application programs are insulated from changes in
the way the data is structured and stored. Data independence is achieved
through use of the three levels of data abstraction; in particular, the
conceptual schema and the external schema provide distinct benefits in this
area.
Relations in the external schema (view relations) are in principle generated
on demand from the relations corresponding to the conceptual schema.3 If
the underlying data is reorganized, that is, the conceptual schema is changed,
the definition of a view relation can be modified so that the same relation is
computed as before. For example, suppose that the Faculty relation in our
university database is replaced by the following two relations:
Faculty_public(fid: string, fname: string, office: integer)
Faculty_private(fid: string, sal: real)
Intuitively, some confidential information about faculty has been placed in a
separate relation and information about offices has been added. The
Courseinfo view relation can be redefined in terms of Faculty public and
Faculty private, which together contain all the information in Faculty, so that
a user who queries Courseinfo will get the same answers as before.
Thus users can be shielded from changes in the logical structure of the data,
or changes in the choice of relations to be stored. This property is called
logical data independence.
In turn, the conceptual schema insulates users from changes in the physical
storage of the data. This property is referred to as physical data
independence. The conceptual schema hides details such as how the data is
actually laid out on disk, the file structure, and the choice of indexes. As long
as the conceptual schema remains the same, we can change these storage
details without altering applications.
Database Architecture
Database architecture uses programming languages to design a particular
type of software for businesses or organizations. Database architecture
focuses on the design, development, implementation and maintenance of
computer programs that store and organize information for businesses,
agencies and institutions.
The functional components of a database system can be broadly divided into
query processor components and storage manager components.
Query Processor:
The query processor components include
• DDL interpreter, which interprets DDL statements and records the
definitions in the data dictionary.
• DML compiler, which translates DML statements in a query language
into an evaluation plan consisting of low-level instructions that the
query evaluation engine understands.
A query can usually be translated into any of a number of alternative
evaluation plans that all give the same result. The DML compiler also
performs query optimization, that is, it picks the lowest cost evaluation
plan from among the alternatives. Query evaluation engine, which executes
low-level instructions generated by the DML compiler.
1. DML Compiler: It translates DML statements in a query language into
low-level instructions that the query evaluation engine understands.
2. Embedded DML Pre-compiler: It converts DML statements embedded in
an application program to normal procedure calls in the host language. The
pre-compiler must interact with the DML compiler to generate the
appropriate code.
3. DDL Interpreter: It interprets DDL Stateline its and records them in a set
of tables containing metadata.
4. Transaction Manager: Ensures that the database remains in a consistent
(correct) state despite system failures, and that concurrent transaction
executions proceed without conflicting.
5. File Manager: Manages the allocation of space on disk storage and the
data structures used to represent information stored on disk.
6. Buffer Manager: Is responsible for fetching data from disk storage into
main memory and deciding what data to cache in memory.
Also some data structures are required as part of the physical system
implementation:
1. Data Files: The data files store the database by itself.
2. Data Dictionary: It stores metadata about the structure of the
database, as it is used heavily.
3. Indices: It provides fast access to data items that hold particular
values.
4. Statistical Data: It stores statistical information about the data in
the database. This information used by the query processor to select
efficient ways to execute a query.
The architecture of a DBMS can be seen as either single tier or multi-tier. The
tiers are classified as follows:
1-tier architecture
2-tier architecture
3-tier architecture
n-tier architecture.
1- tier architecture:
One-tier architecture involves putting all of the required components for
a software application or technology on a single server or platform.
Database Environment
A database management system (DBMS) is a collection of programs that
enables users to create and maintain a database. The DBMS is hence a
general-purpose software system that facilitates the processes of
defining, constructing, manipulating, and sharing databases among
various users and applications.
Defining a database involves specifying the data types, structures, and
constraints for the data to be stored in the database.
Constructing the database is the process of storing the data itself on
some storage medium that is controlled by the DBMS.
Manipulating a database includes such functions as querying the
database to retrieve specific data, updating the database to reflect
changes in the mini world, and generating reports from the data.
Sharing a database allows multiple users and programs to access the
database concurrently.
Other important functions provided by the DBMS include protecting the
database and maintaining it over a long period of time.
Protection includes both system protection against hardware or
software malfunction (or crashes), and security protection against
unauthorized or malicious access. A typical large database may have a
life cycle of many years, so the DBMS must be able to maintain the
database system by allowing the system to evolve as requirements
change over time. We can call the database and DBMS software together
a database system.
Complex Attributes
Composite and multi-valued attributes can be nested. We can represent
such attributes by grouping the components using parenthesis () and
separated by commas (,) and displaying between curly braces {}. Such
attributes are called complex attributes
For eg if a person has more than one residence with different address
{
(housename1, place 1),(house name2,place2),…
}
Entity type and Entity sets
A database usually contains group of entities that are similar. For
example, a company contains hundreds of employees that share the same
attributes such as name, age, salary, designation etc.
Collection of entities that have the same attribute is called entity types. Each
entity type in the database is described by it’s name and attributes
The collection of all entities of particular entity type in the database at any
point in time is called an entity set. The entity set is usually referred using
the same name as the entity type
In the above example of STUDENT entity type, a collection of entities from
the Student entity type would form an entity set. We can say that entity type
is a superset of the entity set as all the entities are included in the entity type
One to many(1:M)
When every entity of first entity set is related to atmost(max) n entities of
other entity set.
Eg:
Many to One(M:1)
When many entity of first entity set is related to one entity of other entity
set.
Eg:
Attribute Inheritance
An entity that is member of a subclass inherits
• All attributes of the entity as a member of the superclass.
• All relationships of the entity as a member of the superclass.
Example: SECRETARY (as well as TECHNICIAN and ENGINEER) inherit the
attributes Name, SSN, …, from EMPLOYEE. Every SECRETARY entity will have
values for the inherited attributes.
2 . Specialization and Generalization
Specialization
• Specialization is the process of defining a set of subclasses of a superclass.
• The set of subclasses is based upon some distinguishing characteristics of
the entities in the superclass
Example: {SECRETARY, ENGINEER, TECHNICIAN} is a specialization
of EMPLOYEE based upon job type. Another specialization of
EMPLOYEE based on method of pay is {SALARIED_EMPLOYEE,
HOURLY_EMPLOYEE}.
Superclass/subclass relationships and specialization can be
diagrammatically represented in EER diagrams
• Attributes of a subclass are called specific or local attributes.
• For example, the attribute TypingSpeed of SECRETARY
The subclass can also participate in specific relationship types. For
example in fig 4.1, a relationship BELONGS_TO of HOURLY_EMPLOYEE
Generalization
The reverse of the specialization process
• Generalization takes common features of subclasses and creates a
superclass.
• Example: CAR, TRUCK generalized into VEHICLE; both CAR,
TRUCK become subclasses of the superclass VEHICLE
– We can view {CAR, TRUCK} as a specialization of VEHICLE
– Alternatively, we can view VEHICLE as a generalization of CAR and TRUCK.
Figure 4.3a shows CAR and TRUCK with several common attributes.
Figure 4.3b showsVEHICLE superclass with CAR and TRUCK subclasses
Diagrammatic notation are sometimes used to distinguish between
generalization and specialization.
• An arrow pointing to the generalized superclass represents a
generalization
• Arrows pointing to the specialized subclasses represent a specialization
• We do not use this notation because it is often subjective as to which
process is more appropriate for a particular situation