If i write a query based on a one to many relationship, how do I know from looking at the output that its based on a 1 to many relationship? Would appreciate your feedback.
For Example:
SalesHeader Table
SalesID CustAccount Product
1 123 21801
2 456 50001
3 789 22550
SalesLine Table
SalesID LineNumber CustAccount Product Amount Qty
1 1 123 21801 100 2
1 2 123 21801 200 4
2 1 456 50001 100 2
3 1 789 22550 150 1
3 2 789 22550 100 3
if I write a query to join these 2 table, I would have the following output:
Query
select
sh.salesid,
sh.custaccount,
sl.salesid,
sl.linenumber
from salesheader sh
join salesline sl
on sh.salesid = sl.salesid
sh.salesid sh.custaccount sl.salesid sl.linenumber
1 123 1 1
1 123 1 2
2 456 2 1
3 789 3 1
3 789 3 2
How from looking at this output can i see that it is based on a one to many relationship?
Do I need to look at what fields I used to join the tables with.
I have used a simple example so would really appreciate your comments.
THe same applies to:
1 to 1
many to many
Are there tools/apps that can be used to identify the relationshio types?
Regards,
Tomas
For Example:
SalesHeader Table
SalesID CustAccount Product
1 123 21801
2 456 50001
3 789 22550
SalesLine Table
SalesID LineNumber CustAccount Product Amount Qty
1 1 123 21801 100 2
1 2 123 21801 200 4
2 1 456 50001 100 2
3 1 789 22550 150 1
3 2 789 22550 100 3
if I write a query to join these 2 table, I would have the following output:
Query
select
sh.salesid,
sh.custaccount,
sl.salesid,
sl.linenumber
from salesheader sh
join salesline sl
on sh.salesid = sl.salesid
sh.salesid sh.custaccount sl.salesid sl.linenumber
1 123 1 1
1 123 1 2
2 456 2 1
3 789 3 1
3 789 3 2
How from looking at this output can i see that it is based on a one to many relationship?
Do I need to look at what fields I used to join the tables with.
I have used a simple example so would really appreciate your comments.
THe same applies to:
1 to 1
many to many
Are there tools/apps that can be used to identify the relationshio types?
Regards,
Tomas