Unit-I - Database Design
Unit-I - Database Design
htm
Unit2
Database design
Requirement Analysis
Conceptual Database Design (ER-Diagram)
Logical Database Design (Tables, Normalization etc)
Schema refinement
Physical Database design (Table Indexing, Clustering etc)
Application development & security
Interview
Analyzing documents
Survey
Site visit
Schema Refinement: The fourth step in database design is to analyze the collection of
relations in our relational database schema to identify potential problems, and refine it
by normalizing relations and restructuring them.
Physical Database Design: It deals with the physical implementation of the database
in a database management system. This step may simply involve building indexes on
some tables and clustering some tables, or it may involve a substantial redesign of
parts of the database schema obtained from the earlier design steps. All these
information are stored in the data dictionary.
Application and Security Design: Any software project that involves a DBMS must
consider aspects of the application that go beyond the database itself. Design
methodologies like UML try to address the complete software design and development
cycle. Briefly, we must identify the entities (e.g., users, user groups, departments) and
processes involved in the application. We must describe the role of each entity in every
process that is reflected in some application task, as part of a complete workflow for
that task. 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, and we must take
steps to ensure that these access rules are enforced.
Entities: - An entity is a thing or object in the real world that is distinguishable from
all other objects. For example ‘Person’ in an organization is an entity. An entity has a
set of properties. At the E-R modeling level an entity actually refers to an entity set. In
other words, entity in ER model corresponds to a table. The ER model refers to a
specific table row as an entity instance or entity occurrence.
Entity set:-Collection of similar entities (Entity Set) often corresponds to a table. Each
entity set has a key. All entities in an entity set have the same set of attributes. Thus
entity set is a set of entities of the same type that share the same properties or
attributes. An entity is represented by a rectangle containing the entity name.
Each Employees entity is denoted by its ssn, and each Departments entity is denoted
by its did, for simplicity. The since value is shown beside each relationship.
Attribute Types:
In ER Model attributes can be classified into the following types.
Simple and Composite Attribute: - Simple attribute that consist of a single atomic
value. A composite attribute is an attribute that can be further subdivided. For
example the attribute ADDRESS can be subdivided into street, city, state, and zip
code. A simple attribute cannot be subdivided. For example the attributes age, sex etc
are simple attributes.
Single Valued and Multi Valued Attribute: - A single valued attribute can have only a
single value. For example a person can have only one 'date of birth', 'age' etc. That is a
single valued attributes can have only single value. But it can be simple or composite
attribute. That is 'date of birth' is a composite attribute, 'age' is a simple attribute. But
both are single valued attributes.
Multi valued attributes can have multiple values. For instance a person may have
multiple phone numbers, multiple degrees etc.Multivalued attributes are shown by a
double line connecting to the entity in the ER diagram.
Stored and Derived Attributes: - The value for the derived attribute is derived from
the stored attribute (An attribute that supplies a value to the related attribute). For
example 'Date of birth' of a person is a stored attribute. The value for the attribute
'AGE' can be derived by subtracting the 'Date of Birth'(DOB) from the current date.
Stored attribute supplies a value to the related attribute.
Complex Attribute: - A complex attribute that is both composite and multi valued.
Descriptive attributes: - are used to record information about the relationship, rather
than about any one of the participating entities
Types of relationships:-
Unary Relationship:-
The entity sets that participate in a relationship set need not be distinct; sometimes a
relationship might involve two entities in the same entity set. For example, consider
the Reports_To relationship set shown in Figure
If an entity set plays more than one role, the role indicator concatenated with an
attribute name from the entity set gives us a unique name for each attribute in the
relationship set. For example, the Reports_To relationship set has attributes
corresponding to the ssn of the supervisor and the ssn of the subordinate, and the
names of these attributes are supervisor_ssn and subordinate_ssn.
Binary Relationship:-
A binary relationship exists when two entities are associated. Below figure shows that
the relationship set Works_In, in which each relationship indicates a department in
which an employee works.
Ternary Relationship:-
A ternary relationship exists when three entities are associated. Suppose that each
department has offices in several locations and we want to record the locations at
which each employee works. This relationship is ternary because we must record an
association between an employee, a department, and a location. The ER diagram for
this variant of Works_In, which we call Works.ln2, is shown in the following Figure.
Key Constraints:-
Consider the Works-In relationship, an employee can work in several departments, and
a department can have several employees, as illustrated in the Works_In instance
shown in Figure.
If we add the restriction that each employee can manage at most one department to
the Manages relationship set, which would be indicated by adding an arrow from
Employees to Manages in Figure 2.6, we have a one-to-one relationship set.
Consider the Works_In relationship set, it is natural to expect that each employee
works in at least one department and that each department has at least one employee.
This means that the participation of both Employees and Departments in Works_In is
total.
If the participation of an entity set in a relationship set is total, the two are connected
by a thick line; independently, the presence of an arrow indicates a key constraint.
Weak Entities:-
Thus far, we have assumed that the attributes associated with an entity set include a
key. This assumption does not always hold. For example, suppose that employees can
purchase insurance policies to cover their dependents. We wish to record information
about policies, including who is covered by each policy, but this information is really
our only interest in the dependents of an employee. If an employee quits, any policy
owned by the employee is terminated and we want to delete all the relevant policy and
dependent information from the database.
Aggregation:-
Used when we have to model a relationship involving (entitity sets and) a relationship
set. Aggregation allows us to treat a relationship set as an entity set for purposes of
participation in (other) relationships.
Suppose that we have an entity set called Projects and that each Projects entity is
sponsored by one or more departments. The Sponsors relationship set captures this
information. A department that sponsors a project might assign employees to monitor
the sponsorship. Intuitively, Monitors should be a relationship set that associates a
Sponsors relationship (rather than a Projects or Departments entity) with an
Employees entity. However, we have defined relationships to associate two or more
entities.
To define a relationship set such as Monitors, we introduce a new feature of the ER
model, called aggregation. Aggregation allows us to indicate that a relationship set
(identified through a dashed box) participates in another relationship set. This is
illustrated in Figure 2.13, with a dashed box around Sponsors (and its participating
entity sets) used to denote aggregation. This effectively allows us to treat Sponsors as
an entity set for purposes of defining the Monitors relationship set.
CONCEPTUAL DESIGN WITH THE ER MODEL
Developing an ER diagram presents several choices, including the following:
Should a concept be modeled as an entity or an attribute?
Should a concept be modeled &'3 an entity or a relationship?
What arc the relationship sets and their participating entity sets? Should we use
binary or ternary relationships?
Should we use aggregation?
We now discuss the issues involved in making these choices.
Works_In4 does not allow an employee to work in a department for two or more
periods .A relationship is uniquely identified by the participating entities.
Similar to the problem of wanting to record several addresses for an employee: We
want to record several values of the descriptive attributes for each instance of this
relationship.
Accomplished by introducing new entity set, Duration.
Set-valued, then attribute