Recent posts in Databases

4,904
4,904 views

Let $E1$ and $E2$ be two entities and $R$ is a relation between $E1$ and $E2$, then what is the minimum no of tables required to represent $E1, E2$ and $R$ if -

1. $E1$ and $E2$ have $1:m$ cardinality($E1$ on $1$ side, $E2$ on $m$ side); $E1$ has total participation and $E2$ has partial participation.

2. $E1$ and $E2$ have $1:m$ cardinality($E1$ on $1$ side, $E2$ on $m$ side); $E2$ has total participation and $E1$ has partial participation.

3. $E1$ and $E2$ have $1:m$ cardinality($E1$ on $1$ side, $E2$ on $m$ side); both $E1$ and $E2$ have partial participation.

4. $E1$ and $E2$ have $1:m$ cardinality($E1$ on $1$ side, $E2$ on $m$ side); both $E1$ and $E2$ have total participation.

5.$ E1$ and $E2$ have $m:n$ cardinality; $E1$ has total participation and $E2$ has partial participation.

6. $E1$ and $E2$ have $m:n$ cardinality; both $E1$ and $E2$ have partial participation.

7. $E1$ and $E2$ have $m:n$ cardinality; both $E1$ and $E2$ have total participation.

8. $E1$ and $E2$ have $1:1$ cardinality; $E1$ has total participation and $E2$ has partial participation.

9. $E1$ and $E2$ have $1:1$ cardinality; both $E1$ and $E2$ have partial participation.

10. $E1$ and $E2$ have $1:1$ cardinality; both $E1$ and $E2$ have total participation.

Assume that there is no multi-valued attribute is present in any of the $10$ cases.


I’m assuming minimum requirement is 1NF.

1) if relationship is many to many and both entities are partially participation

        you can't merge ===> require 3 tables

2) if relationship is many to many and  either of the entities are partially participation but not both side

        you can't merge ===> require 2 tables

3) if relationship is many to many and both entities are total participation

        you can merge all in one table and key of the relation is pk(E1)+pk(E2) but data is redundant and so many partial functional dependencies you get but not transitive dependencies

Why we do normalization ? 

   By normalization tables get increased then what you achieved by merging the tables


1) if relationship is many to one and both entities are partially participation

        you can't merge in one table  ===> 2 tables required

2) if relationship is many to one and many side entity is only partially participation

        you can merge in one table  ===> redundancy and transitive dependencies get but not partial functional dependencies.  because of pk(new table)=pk(E1)

3) if relationship is many to one and one side entity is only partially participation

        you can't merge in one table ===> 2 tables required

4) if relationship is many to one and both entities are totally participation

you can merge in one table  ===> redundancy and transitive dependencies get but not partial functional dependencies.  because of pk(new table)=pk(E1)


1) if relationship is one to one and both entities are partially participation

        you can't merge in one table ===> require 2 tables

2) if relationship is one to one and  either of the entities are partially participation

        you can merge in one table ===> but pk of resultant table should be pk of partial participation otherwise you require 2 tables.

3) if relationship is one to one and both entities are total participation

        you can merge all in one table and pk(new table)=either pk(E1) or pk(E2) is sufficient.



The issue with the above answer is introducing many NULL entries. 

Now the question is whether NULL entries are allowed or not while converting the ER diagram into tables?

This screenshot is from FUNDAMENTALS OF DATABASE SYSTEMS by Ramez Elmasri and Shamkant B. N avathe.

Last Para suggesting that, we can have NULL.

in last para, it is saying that, a new table approach can be used in case of 1:N relation types to avoid excessive nulls in the foreign keys. Can is used in the statement. That means, we can still go for excessive NULLS depends upon our requirement.

 

However, I found some contradiction too in the same book.

This is contradicting. Here, they're saying that M:N relation must create a separate relationship relation. If NULLs are allowed, we always need not to be create a separate table for M:N relation ( i.e., atleast one side total participation case). 

 

 

 

This screenshot is from Silberschatz−Korth−Sudarshan : Database System Concepts, Fourth Edition book, which specifically mentioned about Total participation only. Nothing about NULL values.

 


https://gateoverflow.in/218954/what-an-interesting-dbms-question

1,121
1,121 views

Found this note quite useful in clearing my doubts with NULL. Hope this may help you!

http://www-cs-students.stanford.edu/~wlam/compsci/sqlnulls

1,186
1,186 views

Here is a concise note on Indexing, B & B+ Tree

http://www.cs.montana.edu/~halla/csci440/n18/n18.html

1,036
1,036 views

For this course we will be using the LAB exercises given here which are from Silberschatz book. 
Solutions to Practice Exercises of Silberschatz book.
 

 
Day Date Contents Slides Assignments
1 Oct 7 Introduction to Databases- topics to be covered    
2 Oct 8 Relational Databases
Tuple, Domain, Attribute
Keys- candidate key, primary key, super key, foreign key
Relational algebra, SQL, Relational calculus- same power
Examples
Join- equijoin left/right outer join, natural join- minimum and maximum number of elements
Normalisation
1NF- No multi-valued dependency
2NF- No partial dependency
3NF-No transitive dependency BCNF
BCNF, 4NF
Is normalisation good?- additional join operations, expensive, it is good theoretically
Given a relation, can we make BCNF?
Is there an algorithm for this?
It is possible- but we lose something!
Normalization Notes Assignment 1
3 Oct 9 Relational Algebra
Join- theta join, equi join, natural join, semi join, outer join
Examples
Division operator
Relational Calculus- Tuple Calculus, Domain Calculus- both have same power, examples
safe and unsafe query

 
Assignment-2
Assignment-3
4 Oct 10 Normalisation revisited- Functional dependency    
5 Nov 5 Indexing
index- <key, block address>
primary index, clustered index, secondary index
How many clustered index a table can have?- atmost one clusteed index
Sparse index and dense index
primary-dense/ sparse ,clustering- sparse/ dense, secondary-dense
   
6 Nov 7 B tree and B+ tree
B tree- record pointer present in all nodes whereas in B+ tree record pointer present 
in leaf nodes only
Indexing- order of leaf and non-leaf node
B+ tree more advantage (no unnecessary block access- in B tree record 
pointer present in internal nodes)
Insertion and deletion algorithm
Entity Relationship Model- entity, attributes
Conversion of ER diagram to relational tables- 1:1, m:1, m:n, weak entity
total and partial participation
minimal normalisation satisfied- 2NF because a table formed from an entity with composite key may have a partial dependency
   

 

1,537
1,537 views
  1. Split the fd's such that rhs contains single attribute. 
  2. Find the redundant fd's and remove redundant ones. 
  3. Find the redundant attributes on lhs and remove them.like AB->C ,A can be deleted if closure of B contains A
To see more, click for the full list of questions or popular tags.