0% found this document useful (0 votes)
11 views

Dbms File 2

The document describes a 3-tier database architecture. It has 3 tiers - the database tier containing the database, the application tier containing application servers and programs that access the database, and the user tier containing end users. The tiers are separated and users on one tier are unaware of what is on other tiers. The application tier acts as a mediator between the database and user tiers. Entities, attributes, relationships, keys, and other database concepts are then defined along with examples.

Uploaded by

gunda rishita
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Dbms File 2

The document describes a 3-tier database architecture. It has 3 tiers - the database tier containing the database, the application tier containing application servers and programs that access the database, and the user tier containing end users. The tiers are separated and users on one tier are unaware of what is on other tiers. The application tier acts as a mediator between the database and user tiers. Entities, attributes, relationships, keys, and other database concepts are then defined along with examples.

Uploaded by

gunda rishita
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Explain database system 3 tier architecture with clear diagram in detail.

Most widely used architecture is 3-tier architecture.

Database tier:
 3-tier architecture separates it tier from each other on basis of users
 At this tier, only database resides.
 Database along with its query processing languages sits in layer-3 of 3-tier architecture.
 It also contains all relations and their constraints.
Application (Middle) Tier
 At this tier, the application server and program, which access database, resides.
 For a user this application tier works as abstracted view of database.
 Users are unaware of any existence of database beyond application.
 For database-tier, application tier is the user of it.
 Database tier is not aware of any other user beyond application tier.
 This tier works as mediator between the two.
User (Presentation) Tier
 An end user sits on this tier.
 From a user’s aspect, this tier is everything.
 He/she doesn’t know about any existence or form of database beyond this layer.
 At this layer multiple views of database can be provided by the application.
 All views which are generated by an application, resides in application tier.

Define the following terms.


Entity
 An entity is a thing or object or person in the real world that is distinguishable from all other
object.
 E.g. book, student, employee, college etc...
Entity sets
 An entity set is a set of entities of same type that share the same properties or attributes.
 E.g. the set of all students in a college can be defined as entity set student.
Relationship
 Relationship is an association (connection) between several entities.

1
 Relationship between 2 entities is called binary relationship.
 E.g. book is issued by student where book and student are entities and issue is relation.
Relationship set
 Relationship set is a set of relationships of the same type.
Attributes
 Attributes are properties hold by each member of an entity set.
 E.g. entity is student and attributes of student are enrollmentno, name, address, cpi etc
Types of attributes
 Simple attribute: It cannot be divided into subparts. E.g. cpi, rollno
 Composite attribute: It can be divided into subparts. E.g. name (first-name, middle- name, last-
name), address.
 Single valued attribute: It has single data value. E.g. enrollmentno, birthdate
 Multi valued attribute: It has multiple data value. E.g. phoneno (may have multiple phones).
 Stored attribute: It’s value is stored manually in database. E.g. birthdate
 Derived attribute: It’s value is derived or calculated from other attributes. E.g. age (can be
calculated using current date and birthdate).
Descriptive attributes
 A relationship may also have attributes like an entity. These attributes are called descriptive
attributes.
 E.g. Student gets degree certificate on 14th March 2011. Student and Degree are entities, gets
certificate is relation and certificate date is an attribute of relationship.

student issue degree certificate

Recursive relationship set


 The same entity set participates in a relationship set more than once then it is called recursive
relationship set.
 E.g. an employee entity participated in relationship under with department entity as an employee
as well manager also.

Degree of relationship
 The degree of a relationship is the number of entity types that participate in the relationship.
 The three most common relationships in ER models are Unary, Binary and Ternary.
 A unary relationship is when both participant entities in the relationship are the same entity.
 Example: Subjects may be prerequisites for other subjects.
subject

is prerequisite for
 A binary relationship is the relationship
rel between two different entities.
 The University might need to record which teachers taught which subjects.

teacher teaches subject

 A ternary relationship is the relationship between three different entities.


 The University might need to record which teachers taught whiwhich
ch subjects in which courses.

teacher teaches subject

course

Explain various mapping cardinality (cardinality constraint).


Mapping cardinality (cardinality constraints)
 It represents the number of entities of another entity set which are connected to an eentity using a
relationship set.
 It is most useful in describing binary relationship sets.
 For a binary relationship set the mapping cardinality must be one of the following types:
1. One to one
2. One to many
3. Many to one
4. Many to many
One-to-one relationship
A B

 An entity in A is associated with at most (only) one entity in B and an entity in B is associated
with at most (only) one entity in A.

3
loan
 A customer is connected with only one loan using the relationship borrower and a loan is
connected with only one customer using borrower.
One-to-many Relationship
lationship
A B

An entity in A is associated with any number (zero or more) of entities in B and an entity in B is
associated with at most (only) one entity in A.

loan

 In the one-to-many
many relationship a loan is connected with only one customer using borrower and a
customer is connected with more than one loans using borrower.
Many-to-one relationship
A B

 An entity in A is associated with at most (only) one entity in B and an entity in B is associated
with any number (zero or more) of entities in A.

loan
 In a many-to-one
one relationship a loan is connected with more than one customer using borrower
and a customer is connected with only one loan using borrower.
Many-to-man relationship
A B

 An entity in A is associated with any number (zero or more) of entities in B and an entity in B is
associated with any number (zero or more) of entities in A.

loan

 A customer is connected with more than one loan using borrower and a loan is cconnected with
more than one customer using borrower.

Explain various participation constraints.


Participation constraints
 It specifies the participation of an entity set in a relationship set.
 There are two types participation constraints
1. Total participation
2. Partial participation
Total participation
 In total participation, every entity in the entity set participates in at least one relationship in the
relationship set.
 It specifies that every entity in super class must be member of some of its sub class.
 E.g.
.g. participation of loan in borrower is total because every loan must be connected to a
customer using borrower.
 It is indicated by double line.
Partial participation
 In partial participation, some entities may not participate in any relationship in the rrelationship
set.
 It specifies that an entity may not belong to any sub class.
 E.g. participation of customer in borrower is partial because every customer is not connected to
loan using borrower.
 It is indicated by single line.

loan

Partial Participation Total Participation

Explain weak entity set with the help of example.


Weak entity set
 An entity set that does not have a primary key is called weak entity set.
 The existence of a weak entity set depends on the existence of a strong entity set.
 Weak entity set is indicated by double rectangle.
 Weak entity relationship set is indicated by double diamond.
 The discriminator (partial key) of a weak entity set is the set of attributes that distinguishes
between all the entities of a weak entity set.
 The primary key of a weak entity set is created by combining the primary key of the strong entity
set on which the weak entity set is existence dependent and the weak entity set’s discriminator.
 We underline the discriminator attribute of a weak entity set with a dashed line.
 E.g. in below fig. there are two entities loan and payment in which loan is strong entity set and
payment is weak entity set.
 Payment entity has payment-no which is discriminator.
 Loan entity has loan-no as primary key.
 So primary key for payment is (loan-no, payment-no).

Strong Entity
Weak Entity Relationship Weak Entity
Explain the Superclass and Subclass in E-R diagram with the
help of example.
Superclass
 A superclass is an entity from which another entity can be derived.
 A superclass is a generic entity set which has a relationship with one or more subclasses.
 For example, an entityset account has two subsets saving_account and current_account. So an
account is superclass.
 Each member of subclass is also a member of superclass. So any saving account or a current
account is a member of entity set account.
Subclass
 A subclass is an entity that is derived from another entity.
 A class is a subset of entities in an entity set which has attributes distinct from those in other
subset.
 For example, entities of the entity set account are grouped in to two classes saving_account and
current_account. So saving_account and current_account are subclasses.
superclass
account

sublass saving account current account

Explain the difference between Specialization and


Generalization in E-R diagram.
Explain Specialization and Generalization in E-R diagram with
example.
 For all practical purposes, generalization and specialization is inversion of each other.
Specialization
 A top-down design process that creates subclasses based on some different characteristics of the
entities in the superclass.
 An entity set may include sub groupings of entities that are distinct in some way from other
entities in the set.
 For example, a subset of entities within an entity set may have attributes that are not shared by all
the entities in the entity set.
 Consider an entity set person, with attributes name, street and city.
 A person may be further classified as one of the following:
o customer
o Employee
 For example, customer entities may be described further by the attribute customer-id, credit-rating
and employee entities may be described further by the attributes employee-id and salary.
 The process of designating sub groupings within an entity set is called specialization. The
specialization of person allows us to distinguish among persons according to whether they are
employees or customers.
 Now again, employees may be further classified as one of the following:
o officer
o teller
o secretary
 Each of these employee types is described by a set of attributes that includes all the attributes of
entity set employee plus additional attributes.
 For example, officer entities may be described further by the attribute office-number, tellerentities
by the attributes station-number and hours-per-week, and secretary entities by the attribute hours-
per-week.
 In terms of an E-R diagram, specialization is depicted by a triangle component labeled ISA.
 The label ISA stands for “is a” and represents, for example, that a customer “is a” person.
 The ISA relationship may also be referred to as a superclass subclass relationship.
Generalization
 A bottom-up design process that combines number of entity sets that have same features into a
higher-level entity set.
 The design process proceed in a bottom-up manner, in which multiple entity sets are synthesized
into a higher level entity set on the basis of common features.
 The database designer may have to first identify a customer entity set with the attributes name,
street, city, and customer-id, and an employee entity set with the attributes name, street, city,
employee-id, and salary.
 But customer entity set and the employee entity set have some attributes common. This
commonality can be expressed by generalization, which is a containment relationship that exists
between a higher level entity set and one or more lower level entity sets.
 In our example, person is the higher level entity set and customer and employee are lower level
entity sets.
 Higher level entity set is called superclass and lower level entity set is called subclass. So the
person entity set is the superclass of two subclasses customer and employee.
 Differences in the two approaches may be characterized by their starting point and overall goal.

person

salary

employee customer

ISA

officer teller secretary

Explain types of constraints on specialization and Generalization.


 There are mainly two types of constraints apply to a specialization/generalization:
Disjoint Constraint
 Describes relationship between members of the superclass and subclass and indicates whether
member of a superclass can be a member of one, or more than one subclass.
 It may be disjoint or non-disjoint (overlapping).
1. Disjoint Constraint
 It specifies that the subclasses of the specialization must be disjointed (an entity can be a member
of only one of the subclasses of the specialization).
 Specified by ‘d’ in EER diagram or by writing disjoint.
2. Non-disjoint (Overlapping}
 It specifies that is the same entity may be a member of more than one subclass of the
specialization.
 Specified by ‘o’ in EER diagram or by writing overlapping.

Participation Constraint
 Determines whether every member in super class must participate as a member of a
subclass or not.
 It may be total (mandatory) or partial (optional).
1. Moral (Mandato )
 Total specifies that every entity in the superclass must be a member of some subclass in
the specialization.
 Specified by a double line in EER diagram.
2. Partial (Optional}
 Partial specifies that every entity in the super class not belong to any of the subclass of
specialization.
 Specified by a single line in EER diagram.
 Based on these two different kinds of constraints, a specialization or generalization can
be one of four types
o Total, Disjoint
o Total, Overlapping
o Partial, Disjoint
o Partial, Overlapping.

Explain aggregation in E-R diagram.


 The E-R model cannot express relationships among relationships.
 When would we need such a thing at that time aggregation is used.
 Consider a database with information about employees who work on a particular project and use a
number of machines doing that work.

hours hours
number name id number

e ect emp work project

work uses

machinery machinery
uses

id id
machinery
Fig. A Fig. B
 Relationship sets work and uses could be combined into a single set. We can combine them by
using aggregation.
 Aggregation is an abstraction through which relationships are treated as higher-level entities.
 For our example, we treat the relationship set work and the entity sets employee and project as a
higher-level entity set called work.
 Transforming an E-R diagram with aggregation into tabular form is easy. We create a table for
each entity and relationship set as before.
 The table for relationship set uses contains a column for each attribute in the primary key of
machinery and work.

Explain the steps to reduce the ER diagram to ER database schema.


Step 1: Entities and Simple Attributes:
 An entity type within ER diagram is turned into a table. You may preferably keep the same name
for the entity or give it a sensible name but avoid DBMS reserved words as well as avoid the use
of special characters.
 Each attribute turns into a column (attribute) in the table. The key attribute of the entity is the
primary key of the table which is usually underlined. It can be composite if required but can never
be null.
 It is highly recommended that every table should start with its primary key attribute
conventionally named as TablenamelD.
 Consider the following simple ER diagram:

 The initial relational schema is expressed in the following format writing the table names with the
attributes list inside a parentheses as shown below
Persons( personid, name, address, email )
Persons
personid name address email

 Persons and Phones are Tables and personid, name, address and email are Columns (Attributes).
 personid is the primary key for the table : Person

Step 2: Multi-Valued Attributes


 A multi-valued attribute is usually represented with a double-line oval.

PersonlD Person
Phone
 If you have a multi-valued attribute, take that multi-valued attribute and turn it into a new entity or
table of its own.
 Then make a 1:N relationship between the new entity and the existing one.
 In simple words.
1. Create a table for that multi-valued attribute.
2. Add the primary (id) column of the parent entity as a foreign key withinthe
new table as shown below:
First table is Persons ( personid, name, address, email )Second
table is Phones ( phoneid , personid, phone )
• personid within the table Phones is a foreign key referring to the personid of Persons

Phones
phoneid personid phone

Step 3: 1:1 Relationship

 Let us consider the case where the Person has one wife. You can place the primary key of the wife
table wifeid in the table Persons which we call in this case Foreign key as shown below.
Persons( personid, name, address, email , wifeid )
Wife ( wifeid , name )
• Or vice versa to put the personid as a foreign key within the wife table as shown below:
Persons( personid, name, address, email )
Wife ( wifeid , name , personid)
 For cases when the Person is not married i.e. has no wifelD, the attribute can set to NULL.

Step 4: 1:N Relationships


• For instance, the Person can have a House from zero to many, but a House can have only one
Person.
• In such relationship place the primary key attribute of table having 1 mapping in to the table
having many cardinality as a foreign key.
• To represent such relationship the personid as the Parent table must be placed within the Child
table as a foreign key.
• It should convert to :
Persons( personid, name, address, email )
House ( houseid, name , address, personid)
Persons House
personid name address email houseid name address personid

Step 5: N:N Relationships

• For instance, The Person can live or work in many countries. Also, a country can have many
people. To express this relationship within a relational schema we use a separate table as
shown below:
• It should convert into :
Persons(personid, name, address, email)
Countries ( countryid, name)
HasRelat ( hasrelatid, personid , countryid)

Persons
personid name address email
Countries
countryid name

HasRelat
hasrelatid personid countryid

What is E-R model (Entity-Relationship) model (diagram) also


draw various symbols using in E-R diagram.
E-R model
• Entity-relationship (ER) model/diagram is a graphical representation of entities and their
relationships to each other with their attributes.
What is a Database Models?
• A database model is a type of data model that defines the logical structure of a database.
• It determine how data can be stored, accessed and updated in a database management system
• The most popular example of a database model is the relational model, which uses a table-
based format.
• Type of Database Models are:
1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model
5. Object-oriented database model

1. Hierarchical Model
• The hierarchical model organizes data into a tree-like structure, where each record has a
single parent or root.

department

student professor

• The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the
parent nodes.
• In hierarchical model, data is organized into tree-like structure with one-to-many relationship
between two different types of data, for example, one department can have many professors
and many students.

2. Network Model
• This is an extension of the hierarchical model, allowing many-to-many relationships in a tree-
like structure that allows multiple parents.
3. Entity-relationship Model
• In this database model, relationships are created by dividing object of interest into entity and
its characteristics into attributes.

4. Relational Model
• In this model, data is organized in two-dimensional tables and the relationship is maintained
by storing a common attribute.

5. Object-oriented database model


• This data model is another method of representing real world objects.
• It considers each object in the world as objects and isolates it from each other.
• It groups its related functionalities together and allows inheriting its functionality to other
related sub-groups.

What is Integrity Constraints?


• Integrity constraints are a set of rules. It is used to maintain the quality of information.
• Integrity constraints ensure that the data insertion, updating, and other processes have to be
performed in such a way that data integrity is not affected.
• Thus, integrity constraint is used to guard against accidental damage to the database.
• Various Integrity Constraints are:
1. Check
o This constraint defines a business rule on a column. All the rows in that column must
satisfy this rule.
o Limits the data values of variables to a specific set, range, or list of values. The
constraint can be applied for a single column or a group of columns.
o E.g. value of SPI should be between 0 to 10.
2. Not null
o This constraint ensures all rows in the table contain a definite value for the column
which is specified as not null. Which means a null value is not allowed.
o E.g. name column should have some value.
3. Unique
o This constraint ensures that a column or a group of columns in each row have a distinct
(unique) value.
o A column(s) can have a null value but the values cannot be duplicated.
o E.g enrollmentno column should have unique value.
4. Primary key
o This constraint defines a column or combination of columns which uniquely identifies
each row in the table.
o Primary key = Unique key + Not null
o E.g enrollmentno column should have unique value as well as can’t be null.
5. Foreign key
o A referential integrity constraint (foreign key) is specified between two tables.
o In the referential integrity constraints, if a foreign key column in table 1 refers to the
primary key column of table 2, then every value of the foreign key column in table 1
must be null or be available in primary key column of table 2.

You might also like