UNIT 2 RECENT EDIT
UNIT 2 RECENT EDIT
Syllabus
Following are the six steps of database design process. The ER model is most relevant to
irst three steps
• In this step, it is necessary to understand what data need to be stored in the database,
what applications must be built, what are all those operations that are frequently used by
the system.
• There are several methods for organizing and presenting information gathered inthis
step.
• This is a steps in which E-R Model i.e. Entity Relationship model is built.
• The goal of this design is to create a simple description of data that matches with the
requirements of users.
• In this step, relational database schema is analyzed to identify the potential smise
problems and to re ine it.
• The schema re inement can be done with the help of normalizing and restructuring the
relations.
• The tasks that are performed in this step are building indexes on tables and clustering
tables, redesigning some parts of schema obtained from earlier design steps.
• Using design methodologies like UML (Uni ied Modeling Language) the design of the
database can be accomplished.
• The role of each entity in every process must be re lected in the application task.
• For each role, there must be the provision for accessing the some part of database and
prohibition of access to some other part of database.
• Thus some access rules must be enforced on the application(which is accessing the
database) to protect the security features.
2.1.2 ER Model
The ER data model speci ies enterprise schema that represents the overall logical
structure of a database.
The E-R model is very useful in mapping the meanings and interactions of real-world
entities onto a conceptual schema.
1) Entity Sets
• Entity: An entity is an object that exists and is distinguishable from other objects. For
example - Student named "Poonam" is an entity and can be identi ied by her name. The
entity can be concrete or abstract. The concrete entity can be - Person, Book, Bank.The
abstract entity can be like - holiday, concept entity is represented as a box.
• Entity set: The entity set is a set of entities of the same types. For example - All students
studying in class X of the School. The entity set need not be disjoint. Each entity in entity
set have the same set of attributes and the set of attributes will distinguish it from other
entity sets. No other entity set will have exactly the same set of attributes.
2) Relationship Sets
The association between entity sets is called as participation. That is, the entity sets E1,
E2,..., En participate in relationship set R.
The function that an entity plays in a relationship is called that entity's role.
3) Attributes
Attributes de ine the properties of a data object of entity. For example if student is an
entity, his ID, name, address, date of birth, class are its attributes. The attributes help in
determining the unique entity. Refer Fig. 2.1.3 for Student entity set with attributes - ID,
name, address. Note that entity is shown by rectangular box and attributes are shown in
oval. The primary key is underlined.
Types of Attributes
1) Simple attributes are attributes that are drawn from the atomic value domains
• There are some attributes that can be represented using a single value. For example
• Multivalued attributes: Attributes that have a set of values for each entity. It is
represented by concentric ovals
3) Derived attribute:
Derived attributes are the attributes that contain values that are calculated from other
attributes. To represent derived attribute there is dotted ellipse inside the solid ellipse.
For example Age can be derived from attribute DateOfBirth. In this situation, DateOfBirth
might be called Stored Attribute.
Mapping Cardinality represents the number of entities to which another entity can be
associated via a relationship set.
The mapping cardinalities are used in representing the binary relationship sets. Various
types of mapping cardinalities are –
1) One to One: An entity A is associated with at least one entity on B and an entity B is
associated with at one entity on A. This can be represented as,
2.3 ER Diagrams
An E-R diagram can express the overall logical structure of a database graphically. E-R
diagrams are used to model real-world objects like a person, a car, a company and the
relation between these real-world objects.
Features of ER model
i) E-R diagrams are used to represent E-R model in a database, which makes them easy to
be converted into relations (tables).
ii) E-R diagrams provide the purpose of real-world modelling of objects which makes
them intently useful.
iv) These diagrams are very easy to understand and easy to create even by a naive user.
There are four types of relationships that are considered for key constraints.
i) One to one relation: When entity A is associated with at the most one entity B then it
shares one to one relation. For example - There is one project manager who manages only
one project.
ii) One to many: When entity A is associated with more than one entities at a time then
there is one to many relation. For example - One customer places order at a time.
iii) Many to one: When more than one entities are associated with only one entity then
there is many to one relation. For example – Many students take a ComputerSciCourse
iv) Many to many: When more than one entities are associated with more than one
entities. For example -Many teachers can teach many students.
The relationship in which three entities are involved is called ternary relationship. For
example –
2.3.3 Binary and Ternary Relationships
• Ternary relationships are required when binary relationships are not suf icient to
accurately describe the semantics of an association among three entities.
• For example - Suppose, you have a database for a company that contains the entities,
PRODUCT, SUPPLIER, and CUSTOMER. The usual relationships might be PRODUCT/
SUPPLIER where the company buys products from a supplier - a normal binary
relationship. The intersection attribute for PRODUCT/SUPPLIER is wholesale_price
Now consider the CUSTOMER entity, and that the customer buys products. If all customers
pay the same price for a product, regardless of supplier, then you have a simple binary
relationship between CUSTOMER and PRODUCT. For the CUSTOMER/PRODUCT
relationship, the intersection attribute is retail_price.
• Single ternary relation: Now consider a different scenario. Suppose the customer buys
products but the price depends not only on the product, but also on the supplier. Suppose
you needed a customerID, a productID, and a supplierID to identify a price. Now you have
an attribute that depends on three things and hence you have a relationship between
three entities (a ternary relationship) that will have the intersection attribute, price.
• A weak entity is an entity that cannot be uniquely identi ied by its attributes alone. The
entity set which does not have suf icient attributes to form a primary key is called as weak
entity set.
The entity set that has primary key is called as strong entity set
• A weak entity set has one or more many-one relationships to other (supporting) entity
sets.
• The key for a weak entity set is its own underlined attributes and the keys for the
supporting entity sets. For example - player-number and team-name is a key for Players.
• Some entities have relationships that form hierarchies. For instance, Employee can be
an hourly employee or contracted employee.
• In this relationship hierarchies, some entities can act as superclass and some other
entities can act as subclass.
• Superclass: An entity type that represents a general concept at a high level, is called
superclass.
• Subclass: An entity type that represents a speci ic concept at lower levels, is called
subclass.
• The subclass is said to inherit from superclass. When a subclass inherits from one or
more superclasses, it inherits all their attributes. In addition to the inherited attributes, a
subclass can also de ine its own speci ic attributes.
• The process of making subclasses from a general concept is called specialization. This is
top-down process. In this process, the sub-groups are identi ied within an entity set
which have attributes that are not shared by all entities.