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
7
votes
1 answer

Haskell: shuffling data without functional dependencies

I'm trying to implement a Fisher-Yates shuffle of some data. This algorithm is easy to implement for one-dimensional arrays. However, I need to be able to shuffle data in a two-dimensional matrix. An approach which I think could generalize nicely to…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
7
votes
3 answers

F# application structure logging / repositories etc

I'm gradually switching into F# for a lot of my home projects but I'm a little stumped as to how to wire together complete applications, and more particularly cross-cutting concerns. In C# if I want to log stuff I'd use dependency injection to pass…
Dylan
  • 1,306
  • 1
  • 11
  • 29
7
votes
1 answer

Functional dependency does not unify when bound in GADT

In the following code: class FD a b | a -> b data Foo a where Foo :: FD a b => b -> Foo a unFoo :: FD a b => Foo a -> b unFoo (Foo x) = x By common sense this should work, since a is the same in constraints in both GADT and function, and it…
Ryba
  • 681
  • 4
  • 13
7
votes
0 answers

Functionally dependant wrapped in a newtype

I wonder why the below code does not compile and if there is an implementation mkYVal that GHC would accept. class C x y | x -> y newtype YVal x = YVal { getYVal :: forall y . C x y => y } mkYVal :: C x y => y -> YVal x mkYVal y = YVal y I also…
fakedrake
  • 6,528
  • 8
  • 41
  • 64
7
votes
4 answers

Difference between canonical cover and minimal cover

I know how to calculate a minimal cover-- ensure each functional dependency only has one attribute on the RHS, remove extraneous/redundant LHS attributes by calculating the closure of each, examining all FD's, seeing if any can be removed (again by…
7
votes
1 answer

Final-tagless encoding of mutually recursive types

I am trying to express a pair of mutually recursive data types in the final-tagless encoding. I am able to write: {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE ExplicitForAll #-} module Test where class ExprSYM repr where expr ::…
Michael Thomas
  • 1,354
  • 7
  • 18
7
votes
1 answer

more efficient type-level computations using type families?

Based on the article in the Monad Reader, Issue #8, I've coded up the type-level solution to the "Instant Insanity" puzzle using both Functional Dependencies and Type Families: fundeps solution: http://lpaste.net/113108 type family solution:…
7
votes
6 answers

Non trivial functional dependency in DBMS

What are the non-trivial functional dependencies in the following table? A B C 1 1 1 1 1 0 2 3 2 2 3 2 What the basic…
vashu
  • 105
  • 1
  • 2
  • 5
7
votes
2 answers

Dependency preserving

So I am looking over my database notes and material trying to refresh myself on the general concepts and terminology for upcoming interviews. I have gotten stuck at dependency however and lossless-join decompositions though. I have searched all over…
Austin
  • 3,010
  • 23
  • 62
  • 97
7
votes
1 answer

How Type inference work in presence of Functional Dependencies

Consider the code below : {-# LANGUAGE MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts #-} class Foo a c | a -> c instance Foo Int Float f :: (Foo Int a) => Int -> a f = undefined Now when I…
6
votes
4 answers

Lossless Join Decomposition

I am studying for a test, and this is on the study guide sheet. This is not homework, and will not be graded. Relation Schema R = (A,B,C,D,E) Functional Dependencies = (AB->E, C->AD, D->B, E->C) Is r1 = (A,C,D) r2 = (B,C,E) OR x1 = (A,C,D) x2 =…
6
votes
2 answers

What can type families do that multi param type classes and functional dependencies cannot

I have played around with TypeFamilies, FunctionalDependencies, and MultiParamTypeClasses. And it seems to me as though TypeFamilies doesn't add any concrete functionality over the other two. (But not vice versa). But I know type families are pretty…
semicolon
  • 2,530
  • 27
  • 37
6
votes
2 answers

Haskell: nonobvious examples of functional dependencies

The examples of functional dependencies I've seen boil down to mapping container -> element, and arguments -> result (as in Mult Matrix Vector Vector). They seem to be better expressed with type functions. In database theory, more complex…
sdcvvc
  • 25,343
  • 4
  • 66
  • 102
6
votes
1 answer

Haskell functional dependency a b -> c depending on c?

Consider the following Haskell code: {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-} class C a b c | a b -> c instance C (l (i,j)) (r i j) j instance C (l i j) (r (i,j)) j -- Conflict between the following…
5
votes
1 answer

How to get around the Coverage Condition for Functional Dependencies without using -XUndecidableInstances

Wen using functional dependencies, I frequently hit the Coverage Condition. It is possible to lift it with UndecidableInstances, but I usually try to stay away from that extension. Here is a somewhat contrived example, that works without…
user1078763
  • 728
  • 5
  • 15
1 2
3
36 37