Professional Documents
Culture Documents
Database 7
Database 7
Design phase:
•For small application, database designer will decide the requirements of the
user.
•In case of real world application single person can not understand the
complete data needs of the application.
•The database designer must interact with the user of the application to
understand the needs.
Requirement gathering: The initial phase of the database design is to
characterized the user requirements.
•The database designer must interact with the user of the application to
understand the needs.
•Next, the designer chooses the data model, and translate these requirements
into a schema of database.
•E-R model represents the entities used ,their attributes and relationship
between the entities.
Entity Sets:
An entity is a “thing” or “object” in the real world that is distinguishable
from all other objects.
•The set of all persons who are customers at a given bank, for example, can be defined as
the entity set customer.
•Each entity has a value for each of its attributes. For instance, a particular customer
entity may have the value 321-12-3123 for customer-id, the value Jones for customer
name.
•The customer-id attribute is used to uniquely identify customers, since there may be more
than one customer with the same name, street, and city.
•For each attribute, there is a set of permitted values, called the domain, or value set, of
that attribute.
•The domain of attribute customer-name might be the set of all text strings of a certain
length.
Types of attributes
1) Simple and composite attributes.
•Simple attributes are not divided into subparts.
•Eg:-age,gender
•Composite attributes, on the other hand, can be divided into subparts
•For example, an attribute name could be structured as a composite attribute
consisting of first-name, middle-initial, and last-name.
•attribute ADDRESS can be subdivided into street, city, state, and zip
code.
• The value for this type of attribute can be derived from the values of other
related attributes or entities.
•As another example, suppose that the customer entity set has an attribute
•age, which indicates the customer’s age.
• If the customer entity set also has an attribute date-of-birth, we can calculate
age from date-of-birth and the current date.
•An attribute takes a null value when an entity does not have a value for it.
Relationship Sets
• Consider a relationship set depositor with entity sets customer and account.
•We could associate the attribute access-date to that relationship to specify the
most recent date on which a customer accessed an account.
Constraints
Mapping Cardinalities
1 1
Department has Manager
1 1
One to many. An entity in A is associated with any number (zero or more) of
entities in B. An entity in B, however, can be associated with at most one entity
in A.
• Lines, which link attributes to entity sets and entity sets to relationship sets
•Above ERD consists of two entity sets, customer and loan, related through a
binary relationship set borrower.
•An entity set may not have sufficient attributes to form a primary key. Such
an entity set is termed a weak entity set.
• An entity set that has a primary key is termed a strong entity set.
•consider the entity set payment, which has the three attributes:
•payment-number, payment-date, and payment-amount.
•Thus, although each payment entity is distinct, payments for different loans
may share the same payment number.
•Thus, this entity set does not have a primary key; it is a weak
•entity set.
•For a weak entity set to be meaningful, it must be associated with another
entity set, called the identifying or owner entity set.
• Every weak entity must be associated with an identifying entity; that is, the
weak entity set is said to be existence dependent on the identifying entity set.
•The identifying entity set is said to own the weak entity set that it identifies.
•The relationship associating the weak entity set with the identifying entity
set is called the identifying relationship.
•In our example, the identifying entity set for payment is loan, and a
relationship loan-payment that associates payment entities with their
corresponding loan entities is the identifying relationship.
•Although a weak entity set does not have a primary key, we nevertheless
need a means of distinguishing among all those entities in the weak entity set
that depend on one particular strong entity.
• For example, the discriminator of the weak entity set payment is the
attribute payment-number, since, for each loan, a payment
•number uniquely identifies one single payment for that loan.
• The discriminator of a weak entity set is also called the partial key of the
entity set.
Design Issues
• It can easily be argued that a telephone is an entity in its own right with
attributes telephone-number and location .
• If we take this point of view, we must redefine the employee entity set as:
Emp_id Telephone_num
Employee
Emp_name location
Emp_street
Telephone_num
Telephone_num
Emp_id
Em
Employee p_ Telephone
te
l
It is not always clear whether an object is best expressed by an entity set or a relationship
set.
If every loan is held by exactly one customer and is associated with exactly one
branch, we may find satisfactory the design where a loan is represented as a relationship.
However, with this design, we cannot represent conveniently a situation in
which several customers hold a loan jointly. To handle such a situation, we must define
a separate relationship for each holder of the joint loan. Then, we must replicate
the values for the descriptive attributes loan-number and amount in each such
relationship.
c_name c_street name
city
c_id
loa branch
customer n
Reduction to relational schemas
As an illustration, consider the entity set loan of the E-R diagram in Figure 2.8. This
entity set has two attributes: loan-number and amount. We represent this entity set by
a table called loan, with two columns
c_name
c_street
c_id
C_city
customer
Tabular Representation of Weak Entity Sets
The primary key of the loan entity set, on which payment depends, is loan-number.
Thus, we represent payment by a table with four columns labeled loan-number, payment
number, payment-date, and payment-amount,
Codd’s 12 rules
• The rules are designed to define what is required from a
database management system in order for it to be considered
relational
Rule zero: the rule state that for system to be qualified as
RDBMS ,it must be able to manage database entirely through
the relational capabilities.-
Rule 1: The information rule:
This rule states that all information (data), which is stored in
the database, must be a value of some table cell. Everything in
a database must be stored in table formats. This information
can be user data or meta-data.
Rule 2: The guaranteed access rule:
All data should be accessible without ambiguity. This means
each data item can be uniquely identified using the table name,
primary key, and column name
Rule 3: Systematic treatment of null values:
•The DBMS must allow each field to remain null (or empty).
• A column should be allowed to remain empty.
•"Empty" means containing absolutely nothing, in other words, a
null value, which is distinct from a spaces or a number with a value
of zero.
•Null have several meaning,it can be for missing data,not
applicable or no value.primary key should not be null.
Rule 4: The DBMS must provide access to its structure through the
same tools that are used to access the data.
This means that data can be retrieved from a relational database in sets
constructed of data from multiple rows and/or multiple tables.
This rule states that insert, update, and delete operations should be supported for
any retrievable set rather than just for a single row in a single table.
Rule 8: Physical data independence:
The user is isolated from the physical method of storing and retrieving
information from the database.
•How a user views data should not change when the logical structure
(tables structure) of the database changes.
•For example, adding columns to a table does not affect existing uses of
columns already present
Rule 10: Integrity independence:
•Constraints on user input must be provided to maintain database
integrity.
Rule 12: Users should be no way to modify the database structure other
than through the multiple row database language (SQL).
Introduction to uml diagram
• The UML is an international industry standard
graphical notation for describing software
analysis and designs. When a standardized
notation is used, there is little room for
misinterpretation and ambiguity.
• Four types of uml diagram:
1)Use case daigram
2)Class diagram
3)Activity diagram
Use case diagram
• Use case diagrams model the functionality of a
system using actors and use cases. Use cases are
services or functions provided by the system to its
users.
System
• Draw your system's boundaries using a rectangle that
contains use cases. Place actors outside the system's
boundaries.
Use Case
• Draw use cases using ovals. Label with ovals
with verbs that represent the system's
functions.
Actors
• Actors are the users of a system. When one
system is the actor of another system, label
the actor system with the actor stereotype.
Relationships
• Illustrate relationships between an actor and a use case with
a simple line. For relationships among use cases, use arrows
labeled either "uses" or "extends." A "uses" relationship
indicates that one use case is needed by another in order to
perform a task. An "extends" relationship indicates
alternative options under a certain use case.
Class diagram
• Class diagrams are the backbone of almost every object-
oriented method including UML. The
• A class is shown as a solid-outline rectangle containing the
class name, and optionally with compartments separated by
horizontal lines containing features or other members of the
classifier. y describe the static structure of a system.
• As class is the most widely used classifier, there is no need to
add the "class" keyword. Class name should be centered and
in bold face, with the first letter of class name capitalized
• Features of class are attribute and operation.
• When class is shown with three compartments, the middle
compartment holds a list of attributes and the bottom
compartment holds a list of operations. Attributes and
operations should be left justified in plain face, with the first
letter of the names in lower case.
Activity diagram
• Activity diagram is basically a flow chart to represent the flow
form one activity to another activity. The activity can be
described as an operation of the system.
Action states
• Action states represent the noninterruptible actions of
objects. You can draw an action state in SmartDraw using a
rectangle with rounded corners.
• Action Flow
• Action flow arrows illustrate the relationships
among action states.
• Object Flow
• Object flow refers to the creation and modification of objects
by activities.
• An object flow arrow from an action to an object means that
the action creates or influences the object.
• An object flow arrow from an object to an action indicates
that the action state uses the object.
• Initial State
A filled circle followed by an arrow represents
the initial action state
Final State
An arrow pointing to a filled circle nested inside another circle
represents the final action state.
• Branching
A diamond represents a decision with alternate
paths. The outgoing alternates should be
labeled with a condition or guard expression.
You can also label one of the paths "else.“