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

Generalization: For Example, Faculty and Student Entities Can Be Generalized and Create A Higher Level

Generalization is a bottom-up approach where lower level entities are combined to form higher level entities if they share attributes. Specialization is the opposite, top-down approach where a higher level entity is broken down into more specific lower level entities. Aggregation treats the relationship between two entities as a single entity at a higher level. An entity relationship diagram can be converted to tables in a relational database by mapping entities and relationships to tables following specific rules.

Uploaded by

Swarnavo Mondal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Generalization: For Example, Faculty and Student Entities Can Be Generalized and Create A Higher Level

Generalization is a bottom-up approach where lower level entities are combined to form higher level entities if they share attributes. Specialization is the opposite, top-down approach where a higher level entity is broken down into more specific lower level entities. Aggregation treats the relationship between two entities as a single entity at a higher level. An entity relationship diagram can be converted to tables in a relational database by mapping entities and relationships to tables following specific rules.

Uploaded by

Swarnavo Mondal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Generalization

o Generalization is like a bottom-up approach in which two or more entities of lower


level combine to form a higher level entity if they have some attributes in common.
o In generalization, an entity of a higher level can also combine with the entities of the
lower level to form a further higher level entity.
o Generalization is more like subclass and superclass system, but the only difference is
the approach. Generalization uses the bottom-up approach.
o In generalization, entities are combined to form a more generalized entity, i.e.,
subclasses are combined to make a superclass.

For example, Faculty and Student entities can be generalized and create a higher level
entity Person.

Specialization
o Specialization is a top-down approach, and it is opposite to Generalization. In
specialization, one higher level entity can be broken down into two lower level
entities.
o Specialization is used to identify the subset of an entity set that shares some
distinguishing characteristics.
o Normally, the superclass is defined first, the subclass and its related attributes are
defined next, and relationship set are then added.

For example: In an Employee management system, EMPLOYEE entity can be specialized as


TESTER or DEVELOPER based on what role they play in the company.

Aggregation
In aggregation, the relation between two entities is treated as a single entity. In
aggregation, relationship with its corresponding entities is aggregated into a higher level
entity.

For example: Center entity offers the Course entity act as a single entity in the relationship
which is in a relationship with another entity visitor. In the real world, if a visitor visits a
coaching center then he will never enquiry about the Course only or just about the Center
instead he will ask the enquiry about both.
Reduction of ER diagram to Table
The database can be represented using the notations, and these notations can be reduced
to a collection of tables.

Conversion of ER Diagram to Relational model


 1) Mapping regular/strong entity
For each strong entity set create a new relational independent table that includes
all attributes as column. For composite attribute include only component
attributes.
 2) Mapping weak entity
Convert every weak entity set into a table where we take the discrimination
attribute of the weak entity set and takes the primary key of the strong entity set
as a foreign key and then declared the combination of discriminator attribute and
foreign key as a primary key.
 3) Mapping 1:1 Relationship
For a 1:1 Relationship between two entities S and T. Choose one of the relations,
Example - S and include as foreign key in S the primary key of T. It is better to
choose on entity total participation on S and include descriptive attribute.
 4) Mapping 1:N Relationship
For 1:N relationship identify the entity S on N side of the relationship. Include a
foreign key in S the Primary key of relation T also include Discipline attributes of
1:N attribute of S.
 5) Mapping N:N Relationship
For each M:N relationship create a new relational table include in the new
relation ,the primary key of the participating entities as a well as descriptive
attributes. The primary key of the table will be the combination of primary keys of
participating entities.
 6) Mapping Multi-valued attribute
For every multi-valued attribute will make a new table where we will take primary
key of main table as a foreign key and multi-valued attribute as a primary key.

Relational Model concept


Relational model can represent as a table with columns and rows. Each row is known as a
tuple. Each table of the column has a name or attribute.

Domain: It contains a set of atomic values that an attribute can take.

Attribute: It contains the name of a column in a particular table. Each attribute Ai must
have a domain, dom(Ai)

Relational instance: In the relational database system, the relational instance is


represented by a finite set of tuples. Relation instances do not have duplicate tuples.

Relational schema: A relational schema contains the name of the relation and name of all
columns or attributes.

Relational key: In the relational key, each row has one or more attributes. It can identify
the row in the relation uniquely.

Example: STUDENT Relation


NAME ROLL_NO PHONE_NO ADDRESS

Ram 14795 7305758992 Noida

Shyam 12839 9026288936 Delhi

Laxman 33289 8583287182 Gurugra

Mahesh 27857 7086819134 Ghaziab

Ganesh 17282 9028 9i3988 Delhi

o In the given table, NAME, ROLL_NO, PHONE_NO, ADDRESS, and AGE are the
attributes.
o The instance of schema STUDENT has 5 tuples.
o t3 = <Laxman, 33289, 8583287182, Gurugram, 20>

Properties of Relations
o Name of the relation is distinct from all other relations.
o Each relation cell contains exactly one atomic (single) value
o Each attribute contains a distinct name
o Attribute domain has no significance
o tuple has no duplicate value
o Order of tuple can have a different sequence

next →← prev

DBMS vs. File System


There are following differences between DBMS and File system:

DBMS File System


DBMS is a collection of data. In DBMS, the user is not File system is a collection of data. In thi
required to write the procedures. procedures for managing the database.

DBMS gives an abstract view of data that hides the File system provides the detail of the da
details.

DBMS provides a crash recovery mechanism, i.e., File system doesn't have a crash mecha
DBMS protects the user from the system failure. entering some data, then the content of

DBMS provides a good protection mechanism. It is very difficult to protect a file under

DBMS contains a wide variety of sophisticated File system can't efficiently store and re
techniques to store and retrieve the data.

DBMS takes care of Concurrent access of data using In the File system, concurrent access ha
some form of locking. file while other deleting some informatio

Join Operations:
A Join operation combines related tuples from different relations, if and only if a given join
condition is satisfied. It is denoted by ⋈.

Example:
EMPLOYEE

EMP_CODE EMP_NAME

101 Stephan

102 Jack

103 Harry

SALARY
EMP_CODE SALARY

101 50000

102 30000

103 25000

1. Operation: (EMPLOYEE ⋈ SALARY)   

Result:

EMP_CODE EMP_NAME

101 Stephan

102 Jack

103 Harry
Types of Join operations:

1. Natural Join:
o A natural join is the set of tuples of all combinations in R and S that are equal on
their common attribute names.
o It is denoted by ⋈.

Example: Let's use the above EMPLOYEE table and SALARY table:

Input:

1. ∏EMP_NAME, SALARY (EMPLOYEE ⋈ SALARY)  

Output:

EMP_NAME SALARY
Stephan 50000

Jack 30000

Harry 25000

2. Outer Join:
The outer join operation is an extension of the join operation. It is used to deal with missing
information.

Example:

EMPLOYEE

EMP_NAME STREET CITY

Ram Civil line Mum

Shyam Park street Kolk

Ravi M.G. Street Delh

Hari Nehru nagar Hyd

FACT_WORKERS

EMP_NAME BRANCH SA

Ram Infosys

Shyam Wipro

Kuber HCL
Hari TCS

Input:

1. (EMPLOYEE ⋈ FACT_WORKERS)  

Output:

EMP_NAME STREET CITY BRANC

Ram Civil line Mumbai Infos

Shyam Park street Kolkata Wipro

Hari Nehru nagar Hyderabad TCS

An outer join is basically of three types:

a. Left outer join


b. Right outer join
c. Full outer join

a. Left outer join:


o Left outer join contains the set of tuples of all combinations in R and S that are equal
on their common attribute names.
o In the left outer join, tuples in R have no matching tuples in S.
o It is denoted by ⟕.

Example: Using the above EMPLOYEE table and FACT_WORKERS table

Input:

1. EMPLOYEE ⟕ FACT_WORKERS   

EMP_NAME STREET CITY BRANC


Ram Civil line Mumbai Infos

Shyam Park street Kolkata Wipro

Hari Nehru street Hyderabad TCS

Ravi M.G. Street Delhi NULL

b. Right outer join:


o Right outer join contains the set of tuples of all combinations in R and S that are
equal on their common attribute names.
o In right outer join, tuples in S have no matching tuples in R.
o It is denoted by ⟖.

Example: Using the above EMPLOYEE table and FACT_WORKERS Relation

Input:

1. EMPLOYEE ⟖ FACT_WORKERS  

Output:

EMP_NAME BRANCH SALARY STREET

Ram Infosys 10000 Civil line

Shyam Wipro 20000 Park street

Hari TCS 50000 Nehru street

Kuber HCL 30000 NULL

c. Full outer join:


o Full outer join is like a left or right join except that it contains all rows from both
tables.
o In full outer join, tuples in R that have no matching tuples in S and tuples in S that
have no matching tuples in R in their common attribute name.
o It is denoted by ⟗.

Example: Using the above EMPLOYEE table and FACT_WORKERS table

Input:

1. EMPLOYEE ⟗ FACT_WORKERS  

Output:

EMP_NAME STREET CITY BRANC

Ram Civil line Mumbai Infos

Shyam Park street Kolkata Wipro

Hari Nehru street Hyderabad TCS

Ravi M.G. Street Delhi NULL

Kuber NULL NULL HCL

3. Equi join:
It is also known as an inner join. It is the most common join. It is based on matched data as per
the equality condition. The equi join uses the comparison operator(=).

Example:

CUSTOMER RELATION

CLASS_ID NAME

1 John
2 Harry

3 Jackson

PRODUCT

PRODUCT_ID CITY

1 Delhi

2 Mumbai

3 Noida

Input:

1. CUSTOMER ⋈ PRODUCT    

Output:

CLASS_ID NAME PRODUCT_ID

1 John 1

2 Harry 2

3 Harry 3

Next Topic DBMS Integrity Constraints

← prevnext →

You might also like