Showing posts with label ER Model. Show all posts
Showing posts with label ER Model. Show all posts

Wednesday, February 15, 2017

What is degree of relationship in ER modeling in dbms

What is degree of relationship in ER modeling in dbms, Define degree of relationship, examples for degree of relationship, degree of relationship type


Degree of relationship

Degree of relationship is the number of entity sets that are participated (associated) in that relationship. That is, the number of entity sets that are connected through the relationship in question is called the degree of relationship.
Based on the degree, the relationships may be identified as unary (degree 1), binary (degree 2), ternary (degree 3) and so on.
Below given the ER diagram that shows the degrees of relationships;
Unary relationship
 The relationship ‘Represents’ is an one-to-many Unary relationship. It connects with only one table (relation/entity set).
Binary relationship
 The relationship ‘Registers’ is a many-to-many Binary relationship. It connects (associates) two entity sets, Student and Courses.
Ternary relationship
The relationship ‘STC’ is a many-t-many Ternary relationship. It links the entity sets Student, Courses and Teacher.

*************












Monday, February 6, 2017

What is degree of a relation in dbms

What is degree of a relation in dbms, define degree of a table, example for degree of relational table


Degree of a relation (table)


The degree of a relation is the number of attributes (columns) in the given table. It is also called as Arity.
[Note: In some books, each row of the table is called as degree-tuple, for example, in a table with 3 attributes each row is a 3-tuple.]

EMPLOYEES Table
EMPID
HIREDATE
SALARY
DEPT
JOBCODE
SEX
119012
01JUL1973
42340.58
CSR010
602
F
120591
05DEC1985
31000.55
SHP002
602
F
127845
16JAN1972
75320.34
ACC024
204
M
129540
01AUG1987
56123.34
SHP002
204
F
135673
15JUL1989
46322.58
ACC013
602
F
212916
15FEB1958
52345.58
CSR010
602
F
216382
15JUN1990
34004.65
SHP013
602
F

For the EMPLOYEES table given above, the degree is 6. That is there are 6 attributes (columns/fields) in this table.

STUDENT
RegNo
SName
Gen
Phone
R1
Sundar
M
9898786756
R3
Karthik
M
8798987867
R4
John
M
7898886756
R2
Ram
M
9897786776
For the STUDENT table given above, the degree is 4. That is there are 4 attributes in the STUDENT table.
















Saturday, December 24, 2016

Reduce ER diagram to relation schemas exercise 8

Reduction of an ER diagram to tables, ER diagram to table conversion exercise, mapping er model to relational model, convert er diagram to relational table, how to map er model to relational model, entity relationship diagram to relational tables


ER diagram to Relational schema - Solved Exercise


Question: Convert the following ER diagram to set of relational schemas.




Solution:


Strong entity sets
At first, let us identify and reduce all the strong entity sets (those that have primary keys) into relational schemas.
In the given diagram, ATM, Bank, Transaction, Customer, Branch, and Account are strong entity sets. To do this, we can use the name of the entity sets as schema names and all the attributes as part of the schema. In this way, we have the following schemas;
ATM (ATM_id, cash_limit, location)
Bank (B_id, B_name, B_add)
Branch (Br_id, Br_name, Br_add)
Transaction (Tr_id, Tr_type)
Customer (Cust_id, Cust_name, Cust_add, Ph_no)
Account (Acc_no, Acc_type, Balance)         
Primary keys are underlined

Composite attributes
In entity sets Branch and Customer, the attributes Br_add and Cust_add respectively are composite attributes. To reduce the composite attributes we retain the component attributes in the schema. That is, instead of Br_add, we shall include the component attributes state, country and pin the Branch table as follows;
Branch (Br_id, Br_name, State, Country, Pin)
Likewise, Customer becomes;
Customer (Cust_id, Cust_name, State, Country, Pin, Ph_no)

Multi-valued attributes
Ph_no attribute of Customer entity set is a multi-valued attribute. That is, it can have one or more values in it per record (row). To reduce the multi_valued attribute, we need to create a separate table with a new name with the multi_valued attribute as one attribute along with the primary key of the base entity set as follows;
Customer_Phone (Cust_id, Ph_no)
The primary key for this relation is both (cust_id, ph_no).


Relationship sets

We have the following type of relationships in the given ER diagram;
Belongs – a one-to-many relationship from Bank to ATM. One bank can have many ATMs (and an ATM can belong to at most one Bank).
Has – a one-to-many relationship from Bank to Branch. One bank can have many branches (and a branch can belong to only one bank).
Operates – a many-to-many relationship from ATM to Customer. A customer can operate many ATMs and an ATM can be operated by many customers.
Performs – a many-to-one relationship from Transaction to Customer. A transaction can be performed by only one customer (and a customer can perform any number of transactions).
Holds – a many-to-many relationship from Customer to Account. A customer can have any number of accounts and an account can be maintained by more than one customer as joint accounts.

-         For a many-to-many relationship, we need to create a separate schema by including the primary keys of participating entity sets as attributes.
-         For all others, the primary key of one side has to be included as the foreign key of the other side (no need to create a separate table).
Hence, we have the following changes;

  • Operates (ATM_id, Cust_id) - many-to-many
  • Holds (Cust_id, Acc_no) – many-to-many
  • For Belongs, include B_id (primary key of Bank, one side) in ATM entity set (many side).
    • ATM (ATM_id, cash_limit, location, B_id)
  • For Has, include B_id (primary key of Bank, one side) in Branch entity set (many side).
    • Branch (Br_id, Br_name, State, Country, Pin, B_id)
  • For Performs, include Cust_id (primary key of Customer, one side) in Transaction entity set (many side).
    • Transaction (Tr_id, Tr_type, Cust_id).

At the end, after reduction and modification, we have the following set of relation schemas for the given ER diagram;

Bank (B_id, B_name, B_add)
Customer (Cust_id, Cust_name, State, Country, Pin)
Customer_Phone (Cust_id, Ph_no)
Account (Acc_no, Acc_type, Balance)
ATM (ATM_id, cash_limit, location, B_id)
Branch (Br_id, Br_name, State, Country, Pin, B_id)
Transaction (Tr_id, Tr_type, Cust_id)
Operates (ATM_id, Cust_id)
Holds (Cust_id, Acc_no)








Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery