DBMS Unit 2
DBMS Unit 2
► Requirements Collection and Analysis: During this step, the database designers
interview prospective database users to understand and document their data
requirements.
► This step results in a concise set of user requirements, which should be detailed
and complete.
► The functional requirements should be specified, as well as the data
requirements. Functional requirements consist of user operations that will be
applied to the database, including retrievals and updates.
► Functional requirements can be documented using diagrams such as sequence
diagrams, data flow diagrams etc.
Main phases of database design (Contd…)
► Once the requirements have been collected and analysed, the next step is to
create a conceptual schema for the database, using high level conceptual data
model.
► Conceptual schema: includes descriptions of data requirements of the users, and
detailed description of the entity types, relationships and constraints.
► The concepts do not include implementation details; therefore the end users
easily understand them, and they can be used as a communication tool.
► The conceptual schema is used to ensure all user requirements are met, and they
do not conflict.
Main phases of database design (Contd…)
► Implementation: The conceptual schema is transformed from the high level data
model into the implementation data model.
► This step is called logical design or data model mapping;
► Its result is a database schema in the implementation data model of the DBMS.
► Physical Design : Purpose is to decide upon the internal storage structures,
access paths(indexes), etc, that will be used.
► In parallel with these activities, application programs are designed and
implemented as database transactions corresponding to the high level transaction
specifications.
Entity Relationship (ER) Model
► Entity : An entity represents a thing in the real world with an independent existence, i.e., about
which we want to maintain some data.
► An entity could represent a physical object (eg. house, person, automobile, widget) or less
tangible concept (eg. Company, job, academic course).
► Entities are specific objects or things in the mini-world that are represented in the database.
► For example the EMPLOYEE John Smith, the Research DEPARTMENT, the ProductX
PROJECT
Attributes
► For example an EMPLOYEE entity may have a Name, SSN, Address, Gender, Birthdate.
► For example a specific employee entity may have Name='John Smith', SSN='123456789',
Address ='731, Fondren, Houston, TX', Gender='M', Birthdate='09-JAN-55‘
► Each attribute has a value set (or data type) associated with it – e.g. integer, string, subrange,
enumerated type, …
Types of Attributes
► Here, the attributes “Name” and “Address” are composite attributes as they are
composed of many other simple attributes.
Single Valued Attributes
► Single valued attributes are those attributes which can take only one value for a
given entity from an entity set.
► For example − Social_Security_Number.
Here, all the attributes are single valued attributes as they can take only one specific value for each
entity.
Multi Valued Attributes
► Multi valued attributes are those attributes which can take more than one value
for a given entity from an entity set.
Here, the attributes “Mob_no” and “Email_id” are multi valued attributes as they can take
more than one values for a given entity.
Derived Attributes vs Stored Attribute
► Derived attributes are those attributes which can be derived from other attribute(s).
► Derived attributes are the attributes that do not exist in the physical database, but their values
are derived from other attributes present in the database.
► For example, average_salary in a department should not be saved directly in the database,
instead it can be derived. For another example, age can be derived from data_of_birth.
► The age attribute is hence called a derived attribute and is said to be derivable from the
birth_date attribute, which is called stored attribute.
Key Attribute
► Key attributes are those attributes which can identify an entity uniquely in an
entity set.
Here, the attribute “Roll_no” is a key attribute as it can identify any student uniquely.
The Null value
► In some cases a particular entity might not have an applicable value for a particular
attribute. Or that value may be unknown, Or, in the case of a multi-valued attribute,
the appropriate value might be the empty set.
► Example: The attribute DataOfDeath is not applicable to a living person who have
died.
► For example, A person can have many phone numbers,many e-mail addresses,home addresses
etc. So if there is a attribute in the name of 'Contact detail',it can be a complex attribute.
Entity Types, Entity Sets, Keys, and Domains
► The entity set is usually referred to using the same name as the entity type.
► For example, EMPLOYEE refers to both a type of entity as well as the current set of all
employee entities in the database.
Entity Types, Entity Sets
Entity Types, Entity Sets
► An attribute of an entity type for which each entity must have a unique value
is called a key attribute of the entity type. For example, SSN of EMPLOYEE.
► A key attribute may be composite. For example, VehicleTagNumber is a key of the CAR entity
type with components (Number, State).
► An entity type may have more than one key. For example, the CAR entity type may have two keys:
► VehicleIdentificationNumber (popularly called VIN) and
► VehicleTagNumber (Number, State), also known as license_plate number.
ENTITY SET corresponding to the
ENTITY TYPE CAR
CAR
Registration(RegistrationNumber, State), VehicleID, Make, Model, Year, (Color)
car1
((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1999, (red, black))
car2
((ABC 123, NEW YORK), WP9872, Nissan 300ZX, 2-door, 2002, (blue))
car3
((VSY 720, TEXAS), TD729, Buick LeSabre, 4-door, 2003, (white, blue))
.
.
.
Value Sets (Domains) of Attributes
► Each simple attribute of an entity type is associated with a value set (or
domain of values), which specifies the set of values that may be assigned to
that attribute for each individual entity.
► Value sets are not displayed in ER diagrams. Value sets are typically specified using the basic
datatypes available, such as integer, string, Boolean, float and so on.
► Additional data types to represent date, time, and other concepts are also employed.
Initial Conceptual Design of the COMPANY Database
Relationship Type
Relationship Type
► A relationship type R among n entity types E1, E2,
E3,….En defines a set of associations or a relationship set
among entities from these entity types.
Relationship Degree
►
Relationship Degree
► The role name signifies the role that a participating entity from the entity type plays in
each relationship instance, and helps to explain what the relationship means.
► For example, in the WORKS_FOR relationship type, EMPLOYEE plays the role of
employee or worker.
► Role names are not technically necessary on relationship types where all the
participating entity types are distinct.
Recursive Relationships
Supervisor Supervisee
Recursive Relationship
► Constraints, that limit the possible combinations of entities that may participate
in the corresponding relationship set.
► For example, if the company has a rule that each employee must work for
exactly one department, then this constraint is described in the schema.
► The cardinality ratio for a binary relationship specifies the maximum number of
relationship instances that an entity can participate in.
► Means that, each department can be related to(that is employs) any number of
employees, but an employee can be related to (works for) only one department.
Cardinality Ratios for Binary Relationships
► Cardinality defines the number of entities in one entity set, which can be associated
with the number of entities of other set via relationship set.
• When a single instance of an entity is associated with a single instance of another
entity, then it is called as one to one cardinality
• Here each entity of the entity set participate only once in the relationship
Cardinality Ratio (1:1)
1 1
Employee WORKS_FOR Department
Cardinality Ratio (1:N)
► Many-to-one − When entities in one entity set can participate only once in a
relationship set and entities in another entity can participate more than once in the
relationship set, then such type of cardinality is called many-to-one.
• Many-to-many − Here more than one instance of an entity is associated with more
than one instance of another entity then it is called many to many relationships
• In this cardinality, entities in all entity sets can take participate any number of
times in the relationship cardinality is many to many.
► Here, Double line between the entity set “Student” and relationship set
“Enrolled” in signifies total participation.
• It specifies that each entity in the entity set may or may not participate in the
relationship instance in that relationship set.
• That is why, it is also called as optional participation.
• Partial participation is represented using a single line between the entity set and
relationship set.
Partial Participation
► Here, Single line between the entity set “Course” and relationship set
“Enrolled in” signifies partial participation.
► It specifies that there might exist some courses for which no enrolments are
made.
Relationship between Cardinality and Participation
Constraints
► Relationship types can also have attributes, similar to those of entity types.
► For example: Hours for the works on relationship type.
Hours
► Entity types that do not have key attributes of their own are called as weak entity
types.
► Entity types that do have key attributes are called as regular entity types or
strong entity types.
► An entity of a weak identity type is uniquely identified by the specific entity to
which it is related in combination with some set of its own attributes.
► A relationship type that relates a weak entity type to its owner is called the
identifying relationship of the weak entity type.
Weak Entity Types
► Use singular Names for Entity Types, rather than plural ones, because the entity
type name applies to each individual entity belonging to that entity type.
► Entity Type names and relationship types are written in uppercase.
► Attribute names are initial capitalized.
► Role names are in lower case letters.
► Nouns will be taken as entities and verbs as relationship types.
► Attribute names generally arise from additional nouns that describe the nouns
corresponding to entity types.
ER diagram for COMPANY Database