functional-dependencies

Associated Parameter Restriction using Functional Dependency

ぐ巨炮叔叔 提交于 2019-12-02 02:43:30
问题 The function f below, for a given type 'a', takes a parameter of type 'c'. For different types 'a', 'c' is restricted in different ways. Concretely, when 'a' is any Integral type, 'c' should be allowed to be any 'Real' type. When 'a' is Float, 'c' can ONLY be Float. One attempt is: {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, UndecidableInstances #-} class AllowedParamType a c | a -> c class Foo a where f :: (AllowedParamType a c) => c -> a fIntegral ::

Prolog union fails

耗尽温柔 提交于 2019-12-01 20:39:13
I'm trying to understand the use of union (the built in predicate) in Prolog. In many cases it seems to fail when it should succeed. It seems it has something to do with the order of the elements of the lists. All of the below cases fail (they come back with "false."). ?- union([1,2,3],[],[2,3,1]). ?- union([1,5,3], [1,2], [1,5,3,2]). ?- union([4,6,2,1], [2], [1,2,4,6]). ?- union([1,2], [], [2,1]). Shouldn't all of these be true? Any explanation as to why these cases keep failing would be very helpful. Also: Why does the below not succeed and find the correct list for A? ?- union([1,5,3], A,

Prolog union fails

自作多情 提交于 2019-12-01 19:34:39
问题 I'm trying to understand the use of union (the built in predicate) in Prolog. In many cases it seems to fail when it should succeed. It seems it has something to do with the order of the elements of the lists. All of the below cases fail (they come back with "false."). ?- union([1,2,3],[],[2,3,1]). ?- union([1,5,3], [1,2], [1,5,3,2]). ?- union([4,6,2,1], [2], [1,2,4,6]). ?- union([1,2], [], [2,1]). Shouldn't all of these be true? Any explanation as to why these cases keep failing would be

Role of functional dependency in `Unfoldable` typeclass of Haskell Collection API

微笑、不失礼 提交于 2019-12-01 19:15:50
Im trying to understand the design of Haskell's Data.Collection library, coming from a Scala-literate background. It uses Functional Dependencies (which have a Scala analog ) but the way they're used doesn't make sense to me. In the Unfoldable class, reproduced below, the element type i is shown as determined by the collection type c . class Unfoldable c i | c -> i Class of collection with unobservable elements. It is the dual of the Foldable class. Please explain the role that the dependency c -> i is playing here and the design intent, ideally with an example of usage? The constraint

Cross Table Dependency/Constraint in SQL Database

对着背影说爱祢 提交于 2019-12-01 11:55:38
Take the example that I have of a table called classes that holds university classes and a table called students that holds students. A class has many students and a student can only take one class. (1 to many relationship). If I had a column in classes that stored the total number of students a class has, this feels like it should violate 3NF. But the dependency is in a separate table. What is this dependency called? And can we say this is violating 3NF? Because in some sense it has all the problems of a 3NF violation. I was wondering if this was a related case. TL;DR But the dependency is in

Cross Table Dependency/Constraint in SQL Database

折月煮酒 提交于 2019-12-01 08:15:59
问题 Take the example that I have of a table called classes that holds university classes and a table called students that holds students. A class has many students and a student can only take one class. (1 to many relationship). If I had a column in classes that stored the total number of students a class has, this feels like it should violate 3NF. But the dependency is in a separate table. What is this dependency called? And can we say this is violating 3NF? Because in some sense it has all the

Determine Keys from Functional Dependencies

大城市里の小女人 提交于 2019-11-29 19:32:15
I'm taking a database theory course, and it's not clear to me after doing the reading how I can infer keys, given a set of functional dependencies. I have an example problem: Find all keys of the relation R(ABCDEFG) with functional dependencies AB → C CD → E EF → G FG → E DE → C BC → A Demonstrate your knowledge by identifying which of the following is a key. a. BCDEF b. ADFG c. BDFG d. BCDE Can someone walk me through how I should decompose the functional dependencies to conclude that some combination of attributes is a key? I expect I'll face a number of these types of problems and I need to

Are Determinants and Candidate Keys same or different things?

隐身守侯 提交于 2019-11-28 09:16:37
Here I found this: Definition: A determinant in a database table is any attribute that you can use to determine the values assigned to other attribute(s) in the same row. Examples: Consider a table with the attributes employee_id, first_name, last_name and date_of_birth. In this case, the field employee_id determines the remaining three fields. The name fields do not determine the employee_id because the firm may have more than one employee with the same first and/or last name. Similarly, the DOB field does not determine the employee_id or the name fields because more than one employee may

BCNF decomposition algorithm explanation

半腔热情 提交于 2019-11-28 00:36:02
I looked in Decomposing a relation into BCNF answers and tried it on my homework, but i don't get the correct answers, so i ask for help in BCNF decomposition Consider R=(ABCDEG) & F={BG->CD, G->A, CD->AE, C->AG, A->D} . I start pick A->D . Now i got S=(AD), R'=(ABCEG). I pick G->A . Now i got S=(AD,AG) R'=(BCEG) . I pick C->G . Now i think i need to get S=(AD,AG,CG) and R'=(BCE) , But the answer in the end is (AD,AG,CGE,BC) .what went wrong? or perhaps, a better algorithm? To convert a relation R and a set of functional dependencies( FD's ) into 3NF you can use Bernstein's Synthesis . To

Partial Dependency(Databases)

两盒软妹~` 提交于 2019-11-27 07:08:20
I need closure on this. I fabricated a definition that partial dependency is when fields are indirectly dependent on the primary key or partially dependent but are also dependent on other keys that depend on the primary such that if the field which another field depends on id deleted that field will still exist due to its dependence on the primary key. I am not sure if it is correct. I have researched and every definition sounds misleading.Is my definition correct and if not please explain? A FD (functional dependency) that holds in a relation is partial when removing one of the determining