Unit 1
Unit 1
    •   Processed data to carrying out useful the business activities is called information
DATABASE
A database is a collection of data, typically describing the activities of one or more related
organizations.
For example, a university database might contain information about the following:
        Entitiessuch as students, faculty, courses, and classrooms.
       Relationshipsbetween entities, such as students' enrollment in courses, faculty teaching
        courses, and the use of rooms for courses.
DATABASE MANAGEMENT SYSTEM
A database management system, or DBMS, is software designed to assist in maintaining and
utilizing large collections of data.
•    In 1070, EdgarCodd, at IBM's San Jose Research Laboratory, proposed the relational data
    model. This sparked rapid development of several DBMSs based on the relational model.
    The benefits of DBMS were widely recognized, and the use of DBMSs for managing
    corporate data became standard practice.
   As the popularity of relational DBMS started increasing, soon, IBM, in early 1980s, has
    developed a SQL (Structured Query Language) for relational databases through their
    SYSTEM/R project.
•   Later in late 1980s, SQL was standardized and the version SQL-1999 was adopted by ANSI
    (American National Standard Institute and ISO (International Standards Organization).
•   During this period, the concept of concurrent execution of database programs, called
    transactions, was introduced in DBMS system which allowed the user to run their programs
    concurrently. Later in 1999, James Gray won Turing award for his contributions to the field
    of database transaction management.
•   In the late 1980s and the 1990s, advances have been made in many areas of database
    systems. More emphasis is given on new data types such as images and text, and the ability
    to support complex analysis of data within of an enterprise.
•   Over a period of time, a new database system was created, data warehouses, consolidating
    data from several databases, and for carrying out specialized analysis.
•   By introduction of enterprise resource planning (ERP) and management resource
    planning (MRP) packages exciting new features were added to existing database system.
•   Many other packages like Baan, Oracle, PeopleSoft, SAP, and Siebel which were user
                                                GNIT
    friendly and allowed the user to carry out the task easily.
•   Most significant change in DBMS is through integration of DBMS with internet which
    allowed DBMS to store data accessed through web browser.It allowed the users to write their
    queries through web forms, and the formatted output are generated using a markup language
    such as HTML.
•   Today the field is being driven by exciting visions such as multimedia databases, interactive
    video, digital libraries and so on.
                                                                                                2
                 DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
ADVANTAGES OF A DBMS:
Data independence:
Application programs should be as independent as possible from details of data representation
and storage. The DBMS can provide an abstract view of the data to insulate application code
from such details.
Efficient data access:
A DBMS utilizes a variety of sophisticated techniques to store and retrieve data efficiently.
Data integrity and security:
If data is always accessed through the DBMS, the DBMS can enforce integrity constraints on the
data before being accessed. Also, the DBMS can enforce access controlsthat govern what data is
visible to different classes of users.
Data administration:
                                                                                                       3
                 DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
When several users share the data, centralized data administration can be done effectively with
DBMS.
While the Relational Model is the most widely used database model, there are other models too:
   Hierarchical Model
   Network Model
   Entity-relationship Model
                                                 GNIT
   Relational Model
   Object Oriented Data Base Model
                                                                                                  4
                      DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
        This model support only one-to-many relationships, many-to-many relationships are not
         supported.
 • All the records are maintained using pointers and hence the whole database structure
     becomes very complex.
 • The insertion, deletion and updating operations of any record require the large number of
     pointers adjustments.
 • The structural changes to the database are very difficult.
1.3.3 Entity-relationship Model
   This model is useful in developing a conceptual design for the database.
         Entity Relationship model is based on –
            Entity – These are representation of a real world entities in code.
            Attributes – These are the characteristic properties of entities
            Relationship – Logical relationship between various entities involved in the Database
            creation.
                           One to one
                           One to many
                           Many to one
                           Many to many
                                                                                                5
                         DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
     E-R Models(semantic data model) model used to pictorially denote entities and the
      relationships among them.
     The attribute values that describe each entity become a major part of the data stored in the
      database.
     It is very simple and easy to design logical view of data.
In this diagram,
 Rectangle represents the entities. Eg. Doctor and Patient.
 Ellipse represents the attributes. Eg. DocId, Dname, PId, Pname.
 Diamond represents the relationship in ER diagrams. Eg. Doctor diagnoses the Patient.
Disadvantages
            Hardware Overheads: For hiding the complexities and making things easier for the user
             this model requires more powerful hardware computers and data storage devices.
            Bad Design: As the relational model is very easy to design and use. So the users don't need
             to know how the data is stored in order to access it. This ease of design can lead to the
             development of a poor database which would slow down if the database grows.
        But all these disadvantages are minor as compared to the advantages of the relational model.
                                                                                                         6
                 DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
•    The real-world problems are more closely represented through the object-oriented data
     model.
•    In this model, both the data and relationship are present in a single structure known as an
     object. In this model, two are more objects are connected through links. We use this link to
     relate one object to other objects.
•    This can be understood by the example given below.
              Employee
                  Attributes
              eid                          Department
              ename                              Attributes
                                           Did
              Age
              Salary                       Dname
                 Methods                       Methods
              Get_Hired()                  Change_Dept()
              Change_No()
                    Fig 1.5 Object Oriented Data Model
                                                                                               7
                  DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
Data abstraction is a process of hiding the implement details (such as how the data are stored
and maintained) and representing only the essential features to simplify user's interaction with
the system.
The major purpose of a database system is to provide users with an abstract view of the system.
The database description consists of a schema at each of these three levels of abstraction as
shown in fig 1.7:
       Conceptual schema
       Physical schema
       External schema
A physical schema can be defined as the design of a database at its physical level. In this level, it
is expressed how data is stored in blocks of storage.
The process of arriving at a good physical schema is called physical database design.
A logical schema can be defined as the design of the database at its logical level. In this level, the
programmers as well as the database administrator (DBA) work. At this level, data can be
described as certain types of data records which can be stored in the form of data structures.
However, the internal details (such as an implementation of data structure) will be remaining
hidden at this level.
The process of arriving at a good conceptual schema is called conceptual database design
View schema can be defined as the design of the database at view level which generally
describes end-user interaction with database systems.
       Highest level of abstraction.             GNIT
Example: University Database – Schema at the different levels of DBMS is shown below.
                                                                                                    8
                       DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
Conceptual Shema Students(id: int, name: string, login: string, age: integer)
Figure 1.8 shows the structure of a typical DBMS based on the relational data model.
[
                                                                                                         9
                 DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
      Optimizer: is responsible to produce the query evaluation plan which gives the most
       effective way to execute the user request
      Execution Engine: Finally executes the query as per query evaluation plan and display
       the required result.
Files and access methods: It is responsible for the abstraction of file structures stored and for
creating indexes on the files for fast access.
Buffer Manager: It is responsible to bring pages in and out from disk to main memory.
Disk space manager: It manages the space on the disk by providing empty space for new
requests, deleting space allocated for existing files which are deleted by users.
GNIT
                                                                                              10
                    DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
  System Catalog(Data Dictionary): It contains all the information about the database. As the
  name suggests, it is the dictionary of all the data items. It contains description of all the tables,
  view, data files, indexes, triggers etc.
Requirements Analysis
                                 Conceptual Design
                                                                     ER Model
                                   Logical Design
                                                                     Relational Database Schema
                                 Schema Refinement
                                                                    Normalized Data
                                   Physical Design
                                                     GNIT
Application/Security Design
  Requirements Analysis
    Requirements Analysis is the process of determining what the database is to be used for.
    It involves interviews with user groups and other stakeholders to identify what functionality
      they require from the database, what kinds of data they wish to process and the most
      frequently performed operations.
    This discussion is at a non-technical level and enables the database designers to understand
      the business logic behind the desired database.
    Gathered information is organized and presented using suitable tools.
  Conceptual database design:
      Once the information is gathered in the requirements analysis step, a conceptual database
       design is developed. This step is often carried out using the ER model, or a similar high-
       level data model.
      The ER Model is used to create a simple description of the data that matches both how users
       and developers think of the data by identifying entities, relationship between them,
       attributes and integrity constraints.
Logical Database Design:
      In this step, the conceptual database design of a database schema is converted into logical
       data base design.
                                                                                                    11
                       DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
       That is logical data base design involves translating the ER diagrams into actual relational
        database schema
Schema Refinement:
       The fourth step in data base design is to analyze the collection of relations in our relational
        database schema to identify the feature problems such as redundancies, anomalies, etc., , and
        to refine it.
Physical Database Design:
       In this step, the physical features of the database which includes form of file organization and
        the internal storage structure are specified.
       This step may simply involve building indexes on some tables and clustering some tables, or
        it may involve redesign of parts of the database schema obtained from the earlier design
        steps.
Application and Security Design :
     Any software project that involves a DBMS must consider applications that involve
      processes and identify the entities.Example: Users, User groups, departments, etc,.
    We must describe the role of each entity in every process.As a Security design, for each role,
     we must identify the parts of the database that must be accessible and the parts of the
     database that must not be accessible by enforcing access rules.
                                                                                                          12
                  DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
Relationship Set-
A relationship set is a set of relationships of same type.
Example-
Set representation of above ER diagram is-
Example-
                                 Role Indicator
                                                                                                     13
                  DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
Descriptive Attributes:
A relationship can also have some attributes, which are called as ‘descriptive attributes. These
are used to record information about the relationship
Example: GNIT
James of ‘Employees’ entity set works in a department entity set since 1991.
2.4   ADDITIONAL
      FEATURES OF ER MODEL
                                                                                                       14
                   DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
1. Many-to-Many Cardinality-
By this cardinality constraint,
        An entity in set A can be associated with any number (zero or more) of entities in set B.
        An entity in set B can be associated with any number (zero or more) of entities in set A.
Example-
                           Street                                                   Dname
                                           City                         DNo                    Budget
               Name
                   Street                                                        Dname
        Name                        City                            DNo                     Budget
Each employee works in at most one department. Many employees can work in same
department.
3. One-to-Many Cardinality-
By this cardinality constraint,
   An entity in set A can be associated with any number (zero or more) of entities in set B.
   An entity in set B can be associated with at most one entity in set A.
Example-
One employee can be associated with many departments, where as each department can be
associated with at most one employee as its manager.
                  Street                                                     Dname
       Name                     City                            DNo                     Budget
                                                                                                            15
                Employee                      Manages                     Department
                  DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
4. One-to-One Cardinality-
By this cardinality constraint,
    An entity in set A can be associated with at most one entity in set B.
    An entity in set B can be associated with at most one entity in set A.
Example-
Each employee can manage at most 1 department.
                 Street                                               Dname
       Name                  City                         DNo                 Budget
GNIT
                                                                                              16
                     DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
  2.Partial Participation
     In partial participation some entities may not participate in any relationship in the
      relationship set.
     It is indicated by single line.
  Example:
     Not every department has a manager, So “Departments” entity set has partial participation
Entity types that do not have key attributes of their own are called as weak entity types.
A weak entity set can be identified uniquely only by considering the primary key of another
  (Identifying owner) owner.
For any weak entity set, following restrictions must hold.
                                                        GNIT
   a. The owner entity set and the weak entity set must participate in a One-to-many relationship
      set, which is called as the ‘Identifying Relationship Set’ of the weak entity set.
   b. The weak entity set must have total participation in the identifying relationship set.
Partial key(or discriminator) of the weak entity set:
The set of attributes of a weak entity set that uniquely identify a weak entity for a given owner
  entity is called as ‘partial key of the weak entity set’.
         Primary Key of Weak Entity Set = Its own Partial Key + Primary Key of Owner entity
  Representation
  Dark lines: to draw weak entity set & its identifying relationship set (with one-many relationship
  constraint)
  Broken line: to underline a partial key
                                                                                                  17
                      DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
 Example:
 ‘Dependents’ is an example of a weak entity set which is uniquely identified by (ssn, pname)
 ‘dpname’ is a partial key for dependents. Policy: identifying relationship set
     Specialization :
     Specialization is a top-down approach in which one higher level entity can be broken down
      into a set of lower level entities.
    It is the process of identifying the subsets of a superclass that share some special attributes.
    Normally, the superclass is defined first, the subclass and its related attributes are defined
      next, and relationship set are then added.
   Example: EMPLOYEE entity can be specialized as Hourly_Emps and Contract_Emps.
 Class Hierarchy Based On Constraints
1. Overlap constraints(allowed/disallowed) :Overlap constraints determine whether two
   subclasses are allowed to contain the same entity commonly.
Example :     Can John be both an Hourly_Emps entity and a Contract_Emps entity?...Disallowed
                    Can he be both a Contract_Emps entity and a Senior_Emps entity? ...Allowed
2. Covering Constraints(Yes/No) : Covering constraints determine whether all entities in the
   superclass is collectively included in at least one of the subclasses.
Example:  Should every Employee be a Hourly-Emps or Contract-Emps? ….. No.
                Does every hourly employee and contract employee are employees of this organization? … Yes
 2.4.5. Aggregation:
 Aggregation is the process of transforming a relationship set into an entity set for the purpose of
 relating the resulting construct to other entity sets.
                                                                                                    18
                  DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
Example:
• Should address be:
  – attribute of Employees or an entity (related to Employees)?
Depends upon use of address information, and the semantics of the data:
•  If several addresses per employee, address must be an entity (since attributes cannot be set-
      valued).
• If structure (city, street, etc.) is important, address must be modeled as an entity (since
      attribute values are atomic).
Entity vs Relationship
                                                                                             19
                 DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
• Works_In4 does not allow an employee to work in a department for two or more periods.
  If wanting
  to      record
 several working
 periods for an
 employee      in
GNIT
 Constraints:
o Each policy is owned by just 1 employee,
  and,
o Dependents is a weak entity set, and each
  dependent is tied to the covering policy
Better design
In this example: two binary relationships are
better than one ternary relationshipto specify
the above given constraint
                                                                                              20
                     DATA BASE MANAGEMENT SYSTEMS – II CSE II Semester – UNIT 1
    Another example
    The contract specifies that a supplier will
    supply some quantity of a part to a
    department.
    To specify this constraint, a ternary
    relationship is better than three binary
    relationships
21