Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Functional dependency

Author  Topic 

blanc-de-poulet
Starting Member

4 Posts

Posted - 2005-04-06 : 19:50:48
ok this is prolly the biggest noob question around but hey...
I m asked to write a statement to show that the data in R(A,B,C) supports the FD A -> B

and I wrote
SELECT count(*)
FROM R A1, R A2
WHERE a1.A=A2.A AND A1.B != A2.B;

which is wrong
Someone?

thanks,
JD

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-06 : 19:51:44
What does this mean: R(A,B,C) supports the FD A -> B?


Tara
Go to Top of Page

blanc-de-poulet
Starting Member

4 Posts

Posted - 2005-04-06 : 21:10:39
show that the data in the relation R(A,B,C) supports the supposed Functional Dependency A -> B
Go to Top of Page

blanc-de-poulet
Starting Member

4 Posts

Posted - 2005-04-06 : 21:15:30
Oh did i misinterpreted your answer?
hmm
I thought could answer the original question by
"If 2 tuples in R agree in their A attribute, then their B attribute should also be the same"
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2005-04-06 : 21:59:18
Let's use a "real life" example...

Given R = Employee (EmployeeID PK, LastName, FirstName)

The FD: (EmployeeID -> LastName) is saying that for any value of EmployeeID there is just one LastName value. Or "If I know the EmployeeID, I must know the LastName". It also says that another EmployeeID may also have the same LastName.

So.... We need to write a query that verifies the saying "An EmployeeID value has only one LastName value"

If any rows are returned then the FD does not hold...
SELECT EmployeeID, COUNT(LastName) AS LastNameCNT
FROM Employees
GROUP BY EmployeeID
HAVING COUNT(LastName) != 1



DavidM

A front-end is something that tries to violate a back-end.
Go to Top of Page

blanc-de-poulet
Starting Member

4 Posts

Posted - 2005-04-06 : 23:15:17
that is exactly what I was looking for. The xplanation is also perfectly clear.
Thank you
Go to Top of Page
   

- Advertisement -