Questions tagged [functional-dependencies]

A functional dependency is a constraint between two sets of attributes in a relation, in relational algebra, databases and type systems.

Functional dependencies (FD) are fundamental to the process of normalization.

Given a relation R, a set of attributes X in R is said to functionally determine a set of attributes Y, also in R, (written X → Y) if, and only if, whenever two tuples coincide on all attributes of X, they also coincide on all attributes of Y. Sound, complete and non-redundant axiomatisation of functional dependencies is given by Armstrong rules. Functional dependencies are also used in the Haskell programming language to describe relations between types, to support type level relational programming.

In other words, a dependency FD: X → Y means that the values of Y are determined by the values of X. Two tuples sharing the same values of X will necessarily have the same values of Y.

Enter image description here

544 questions
4
votes
2 answers

Why does this instance fail the coverage condition?

Why does the following instance declaration fail the coverage condition in the absence of UndecidableInstances? It seems that if the functional dependency is satisfied in the context then it is satisfied in the new instance. {-# LANGUAGE…
Tom Ellis
  • 9,224
  • 1
  • 29
  • 54
4
votes
1 answer

SQL: How to enforce functional dependency using constraints?

Assume we have a table: CREATE TABLE Jobs ( JobID INT PRIMARY KEY , AssignedUser VARCHAR(10) , Zone VARCHAR(10) ) The constraint we need to enforce is this: make sure that no user is assigned jobs in more than one zone,…
4
votes
1 answer

Recursive functional dependency not working

I'm trying to multiply array of units (from dimensional) in a phantom type and I'm having trouble with functional dependencies. A simplified version of the problem is the following : I have the following type data F (a:: [*]) = F String Where the…
mb14
  • 22,276
  • 7
  • 60
  • 102
4
votes
1 answer

Type families get stuck where the equivalent type using functional dependencies can be simplified

I am trying to implement map tagSelf :: [a] -> [Tagged a a] and map untag :: [Tagged a a] -> [a] with good type-inference properties for HList. The TF version is close, but I have a case where a type function gets stuck while the FD version…
aavogt
  • 1,308
  • 6
  • 14
4
votes
1 answer

SQL-Show that R is not in Boyce-Codd Normal Form

R = (J,K,L,M,N) with a set of functional dependencies {J->KL,LM->N,K->M,N->J}. I understand the definition of BCNF. I believe that there exists no trivial functional dependencies and there may not be a super key. I'm not sure about the second part.…
blutuu
  • 590
  • 1
  • 5
  • 20
4
votes
2 answers

Third Normal Form -- transitive dependence between two foreign keys?

I am creating a database containing books that I own and have read. I want to track both the book (or "title") that I own and read, and the edition (or "physical bound paper") of that book that I own and read. Book and Edition are many-to-many. I…
4
votes
2 answers

Is there a general way to tell the number of parameters of a function in Haskell?

I can tell the number of parameters of a function with the following code {-#Language MultiParamTypeClasses#-} {-#Language FunctionalDependencies#-} {-#Language UndecidableInstances#-} data Zero data Succ a class Number a instance Number…
TorosFanny
  • 1,702
  • 1
  • 16
  • 25
4
votes
2 answers

Understanding Functional Dependencies

I'm currently learning about functional dependencies and am struggling to get my head around the concept behind them. Say I have the table: Customer |-----------|--------------|------------|------------------|------------------| |Cust-ID |…
3
votes
1 answer

How do you compute the functional dependencies for decomposition?

Say R has the following attributes: {A,B,C,D,E} and has the following functional dependencies: A -> BC CD -> E B -> D E -> A And there is a decomposition consisting of R1(A,B,C) and R2(A,D,E). How can I compute the functional dependencies of R1…
Jrom
  • 849
  • 1
  • 10
  • 19
3
votes
1 answer

Functional dependency of multiple types

Is the following possible (in spirit) with the GHC? -- Syntax error: parse error on input `a' class Foo a b c | (a, b) -> c where foo :: a -> b -> c What alternatives do I have?
Thomas Eding
  • 35,312
  • 13
  • 75
  • 106
3
votes
0 answers

SELECT Unaggregated Variables, Functionally Dependent on GROUPing Variables

Background I am working in a very restricted T-SQL environment, where one may only define the "body" of a VIEW: presumably the ... in CREATE VIEW My_View AS ... under the hood. Here is my @@VERSION: Microsoft SQL Server 2019 (RTM-CU19)…
Greg
  • 3,054
  • 6
  • 27
3
votes
1 answer

How to determine candidate keys from record schema and functional dependencies?

If I have a schema say R={A,B,C,D} and functional dependencies say {B->C, D->A} will my set of candidate keys be {B,D} or {BD}?
Sean
  • 2,018
  • 4
  • 25
  • 32
3
votes
1 answer

FunctionalDependencies does not unify on uniquely identified type

Here is the definition for MonadState, but question applies to any such class with FunctionalDependencies: class Monad m => MonadState s m | m -> s where ... Consider I have data type that uses s as the type argument and a type class that works…
lehins
  • 9,642
  • 2
  • 35
  • 49
3
votes
1 answer

Ambiguous implicit solution other than sub typing

If you run the code below you'll get an ambiguous implicit error: class Foo[T,I](val msg: I) object Foo { implicit def provide[T]: Foo[T,String] = new Foo("I came from a place you can't touch so subtyping can't help you") } class User object…
shayan
  • 1,211
  • 9
  • 12
3
votes
1 answer

Circular Dependencies in 3NF

I have a table: Customer(username, firstName, lastName, age, gender, race) username determines firstName, lastName, age, gender, race. firstName, lastName can be used to uniquely identify a row in the table, so firstName, lastName determines…