Cardinality and Determinents


website design company in bangalore
Cardinality – Combination Join and Occurrences

City Table
Country Code
City Code
City Name
101
201
New York
102
202
Hyderabad
102
203
Mumbai
103
204
London
105
205
Tokyo
Join
Country Table
Country Code
Country Name
101
US
102
India
103
UK
104
Australia

·      Joining using Country Code column from both of the tables



1.1   to     1.1 - Inner Join - Fetches only matching records
Country
City
US
New York
India
Hyderabad
India
Mumbai
UK
London

0.1   to     1.1 - Right outer Join - Fetches matching records + Right side non-matching records
Country
City
US
New York
India
Hyderabad
India
Mumbai
UK
London

Tokyo

1.1   to     0.1 - Left outer Join - Fetches matching records + Left side non-matching records
Country
City
US
New York
India
Hyderabad
India
Mumbai
UK
London
Australia


0.1   to     0.1 - Full Outer Join - Fetches matching records + Left side non-matching records + Right side non-matching records
Country
City
US
New York
India
Hyderabad
India
Mumbai
UK
London
Australia


Tokyo

Occurrences

1.1to 1.1- One to One
City
STD code
Delhi
011
Mumbai
022
Kolkata
033
Chennai
044
Hyderabad
040
Bangalore
080



1.1to 1.n - One to Many
Country
City
US
New York
US
Washington
India
Mumbai
India
Hyderabad


1.n  to 1.1 -  Many to One
Student
Teacher
Student A
Teacher B
Student B
Teacher B
Student C
Teacher B

Employee
Manager
Drew
Tom
Micky
Tom
Julie
James
Rocky
James


1.n  to 1.n  - Many to Many
Student
Subject
Student A
Maths
Student B
Science
Student C
Science
Student C
Maths



Determinants 

A determinant can define the set of database columns (query items) that uniquely identify a set of data. Determinants are most closely related to the concept of keys and indexes in the data source and are imported based on key and index information in the data source. We recommend that you always review the determinants that are imported.

Sales Area Table
State
City
Store
Employee
CA
San Fransisco
Bayside
Bill Withers
CA
San Fransisco
Bayside
Elaine Wiley
CA
San Fransisco
Bayside
Jack Tom
CA
Reading
Wallmart
Gomez
CA
Reading
Wallmart
Clark

Budget Table
Store
Month
Sales Target
Bayside
Jan 2013
200,000
Wallmart
Jan 2013
150,000


If you join above tables, then result is as below without determinants





Wrong Result
State
City
Store
Sales Target
CA
San Fransisco
Bayside
200,000
CA
San Fransisco
Bayside
200,000
CA
San Fransisco
Bayside
200,000
CA
Reading
Wallmart
150,000
CA
Reading
Wallmart
150,000

If you join above tables, then result is as below with determinants
Right Result
State
City
Store
Sales Target
CA
San Fransisco
Bayside
200,000
Pensulvania
Reading
Wallmart
150,000



Comments

Post a Comment

Popular posts from this blog