dbis-functional-dependencies 0.0.8__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. dbis_functional_dependencies-1.0.1/PKG-INFO +180 -0
  2. dbis_functional_dependencies-1.0.1/README.md +153 -0
  3. dbis_functional_dependencies-1.0.1/pyproject.toml +47 -0
  4. {dbis-functional-dependencies-0.0.8/functional_dependencies → dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies}/BCNF.py +1761 -1380
  5. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies/fdcheck.py +113 -0
  6. {dbis-functional-dependencies-0.0.8/functional_dependencies → dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies}/fds.py +14 -10
  7. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies/fdsbase.py +207 -0
  8. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies.egg-info/PKG-INFO +180 -0
  9. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies.egg-info/SOURCES.txt +21 -0
  10. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies.egg-info/requires.txt +15 -0
  11. dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies.egg-info/top_level.txt +1 -0
  12. dbis_functional_dependencies-1.0.1/tests/test_bcnf.py +1233 -0
  13. dbis_functional_dependencies-1.0.1/tests/test_bitplan.py +77 -0
  14. dbis_functional_dependencies-1.0.1/tests/test_cheung.py +68 -0
  15. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1}/tests/test_dbis.py +58 -52
  16. dbis_functional_dependencies-1.0.1/tests/test_fdfromdata.py +68 -0
  17. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1}/tests/test_fds.py +47 -47
  18. dbis_functional_dependencies-1.0.1/tests/test_fdsbase.py +43 -0
  19. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1}/tests/test_tum.py +15 -15
  20. dbis-functional-dependencies-0.0.8/PKG-INFO +0 -24
  21. dbis-functional-dependencies-0.0.8/README.md +0 -8
  22. dbis-functional-dependencies-0.0.8/dbis_functional_dependencies.egg-info/PKG-INFO +0 -24
  23. dbis-functional-dependencies-0.0.8/dbis_functional_dependencies.egg-info/SOURCES.txt +0 -22
  24. dbis-functional-dependencies-0.0.8/dbis_functional_dependencies.egg-info/top_level.txt +0 -1
  25. dbis-functional-dependencies-0.0.8/functional_dependencies/fdcheck.py +0 -96
  26. dbis-functional-dependencies-0.0.8/functional_dependencies/fdsbase.py +0 -197
  27. dbis-functional-dependencies-0.0.8/setup.py +0 -36
  28. dbis-functional-dependencies-0.0.8/tests/test_bcnf.py +0 -1190
  29. dbis-functional-dependencies-0.0.8/tests/test_bitplan.py +0 -76
  30. dbis-functional-dependencies-0.0.8/tests/test_cheung.py +0 -71
  31. dbis-functional-dependencies-0.0.8/tests/test_fdfromdata.py +0 -83
  32. dbis-functional-dependencies-0.0.8/tests/test_fdsbase.py +0 -46
  33. dbis-functional-dependencies-0.0.8/tests/test_mquiz.py +0 -32
  34. dbis-functional-dependencies-0.0.8/tests/test_ub7.py +0 -473
  35. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1}/LICENSE +0 -0
  36. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1}/setup.cfg +0 -0
  37. {dbis-functional-dependencies-0.0.8/functional_dependencies → dbis_functional_dependencies-1.0.1/src/dbis_functional_dependencies}/__init__.py +0 -0
  38. {dbis-functional-dependencies-0.0.8 → dbis_functional_dependencies-1.0.1/src}/dbis_functional_dependencies.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: dbis-functional-dependencies
3
+ Version: 1.0.1
4
+ Summary: RWTH Aachen Computer Science i5/dbis assets for Lecture Datenbanken und Informationssysteme
5
+ Author-email: DBIS i5 RWTH Aachen <dbis-vl@dbis.rwth-aachen.de>
6
+ Project-URL: Homepage, https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: graphviz~=0.20
14
+ Requires-Dist: networkx~=2.7
15
+ Requires-Dist: numpy~=1.26
16
+ Requires-Dist: sphinx~=7.2
17
+ Requires-Dist: sphinxcontrib-apidoc~=0.4
18
+ Requires-Dist: functional-dependencies~=1.3
19
+ Requires-Dist: build~=1.0
20
+ Requires-Dist: pylodstorage~=0.4.11
21
+ Provides-Extra: test
22
+ Requires-Dist: black==23.12.1; extra == "test"
23
+ Provides-Extra: build
24
+ Requires-Dist: twine==6.*; extra == "build"
25
+ Requires-Dist: build==1.*; extra == "build"
26
+ Dynamic: license-file
27
+
28
+ # DBIS Functional Dependencies
29
+
30
+ Functional Dependencies and Normal Forms for Relational Databases
31
+
32
+ [![PyPI Status](https://img.shields.io/pypi/v/dbis-functional-dependencies.svg)](https://pypi.python.org/pypi/dbis-functional-dependencies/)
33
+ [![pypi](https://img.shields.io/pypi/pyversions/dbis-functional-dependencies)](https://pypi.org/project/dbis-functional-dependencies/)
34
+ [![License](https://img.shields.io/pypi/l/dbis-functional-dependencies)](https://www.apache.org/licenses/LICENSE-2.0)
35
+ [![Pipeline Status](https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies/badges/main/pipeline.svg)](https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies/-/packages)
36
+
37
+ This library provides a Python implementation of the [synthesis algorithm](https://de.wikipedia.org/wiki/Synthesealgorithmus) and decomposition algorithm according to the DBIS lecture. For more background and application of functional dependencies and the algorithms, see [Doku-FunctionalDependencies](https://git.rwth-aachen.de/i5/teaching/dbis-jupyter/dbis-ss-2023-test/-/blob/main/doku/Doku-FunctionalDependencies.ipynb).
38
+
39
+ # Features
40
+ - Create sets of Functional dependencies (FDSets).
41
+ - Calculate candidate keys of an FDSet.
42
+ - Calculate attribute closure of an attribute or set of attributes.
43
+ - Test whether an FDSet is in 2NF, 3NF or BCNF.
44
+ - Execute the synthesis algorithm to transform the FDSet into 3NF.
45
+ - Execute the decomposition algorithm to transform the FDSet into BCNF.
46
+ - Generate the closure $F^+$ of an FDSet $F$.
47
+ - Generate true/false questions w.r.t. synthesis and decomposition algorithm.
48
+
49
+ # Installation
50
+ Install via pip:
51
+ ```bash
52
+ pip install dbis-functional-dependencies
53
+ ```
54
+
55
+ # Usage
56
+ ### Creating an FDSet
57
+ Create a new instance of `FunctionalDependencySet`. The set of attributes is passed as parameter.
58
+ ```python
59
+ fdset = FunctionalDependencySet('ABCDE')
60
+ ```
61
+ You can add more attributes later by using the `add_attribute` function.
62
+ ```python
63
+ fdset.add_attribute('F')
64
+ ```
65
+ Add dependencies with the `add_dependency` function ...
66
+ ```python
67
+ fdset.add_dependency("AC", "DE")
68
+ fdset.add_dependency("DEF", "B")
69
+ fdset.add_dependency("B", "D")
70
+ ```
71
+ ... or remove them with the `remove_dependency` function.
72
+ ```python
73
+ fdset.remove_dependency("B", "D")
74
+ ```
75
+
76
+ Printing an FDSet shows the dependencies in a more readable form.
77
+ ```python
78
+ print(f"{fdset}")
79
+ ```
80
+
81
+ ### Attribute closure and candidate keys
82
+ Calculate the attribute closure of one or multiple attributes.
83
+ ```python
84
+ closureA = fdset.get_attr_closure('A')
85
+ closureAC = fdset.get_attr_closure('AC')
86
+ ```
87
+
88
+ Calculate all candidate keys.
89
+ ```python
90
+ ckeys = fdset.find_candidate_keys()
91
+ ```
92
+
93
+ ### Check for normal forms
94
+ Since we only work with schemas (no actual values for the attributes), we assume that a corresponding database is in 1NF.
95
+
96
+ Check whether the FDSet is in 2NF, 3NF or BCNF.
97
+ ```python
98
+ is2NF = fdset.is2NF()
99
+ is3NF = fdset.is3NF()
100
+ isBCNF = fdset.isBCNF()
101
+ ```
102
+
103
+ ### Execute the synthesis algorithm
104
+ Execute the synthesis algorithm on an FDSet to generate a corresponding list of FDSets in 3NF.
105
+ ```python
106
+ fdslist = fdset.synthesize()
107
+ ```
108
+ The algorithm performs the following steps:
109
+
110
+ 0. Find the candidate keys.
111
+ 1. Calculate the canonical cover.
112
+ - left reduction
113
+ - right reduction
114
+ - remove dependencies with empty rhs
115
+ - combine dependencies with same lhs
116
+ 2. Create a new relation for every dependency in the canonical cover.
117
+ 3. Create the optional key scheme if no candidate key is included in the attribute set of one of the relations of step 2.
118
+ 4. Remove subset relations.
119
+
120
+ You receive additional information on the steps of the algorithm by toggling the parameter `verbose`.
121
+ ```python
122
+ fdslist = fdset.synthesize(vebose=True)
123
+ ```
124
+ Alternatively, you can also execute the single steps with the following functions:
125
+ ```python
126
+ fdset_step.canonical_cover()
127
+ fdslist_step = fdset_step.create_new_fdsets()
128
+ fdslist_step_with_key = FunctionalDependencySet.create_optional_key_scheme(self, ckeys, fdslist_step)
129
+ reduced_fdslist_step = FunctionalDependencySet.remove_subset_relations(self, fdslist_step_with_key)
130
+ ```
131
+ The verbose option exists for all steps.
132
+
133
+ ### Execute the decomposition algorithm
134
+ Execute the decomposition algorithm on an FDSet to generate a corresponding decomposition of FDSets in BCNF.
135
+ ```python
136
+ fdslist = fdset.decompose2()
137
+ ```
138
+ Before performing the actual algorithm, the the closure of the FDSet is calculated.
139
+
140
+ ### Closure of an FDSet
141
+ Calculate the closure $F^+$ of an FDSet $F$.
142
+ ```python
143
+ fdset.completeFDsetToClosure()
144
+ ```
145
+ This function just adds dependencies with all subset combinations of the attribute set with their corresponding closures on the rhs of the dependency, so that no implicit dependency is missed by the decomposition algorithm.
146
+
147
+ ### Exercise generator
148
+ Generate true/false statements based on the different steps of the algorithms.
149
+ ```python
150
+ fdslist = fdset.synthesize(genEx=True)
151
+ ```
152
+ The `genEx` option is available for the following functions:
153
+ * `find_candidate_keys`
154
+ * `synthesize`
155
+ * `canonical_cover`
156
+ * `left_reduction`
157
+ * `right_reduction`
158
+ * `remove_empty_fds`
159
+ * `combine_fds`
160
+ * `create_new_fdsets`
161
+ * `create_optional_key_scheme`
162
+ * `remove_subset_relations`
163
+ * `decompose2`
164
+
165
+ ### Checking results against expected
166
+ Checks a given calculated step of an FDSet during the synthesis algorithm (according to the DBIS lecture) for correctness.
167
+ ```python
168
+ original = fdset.copy()
169
+ fdset.left_reduction()
170
+ original.isCorrectLeftReduction(fdset)
171
+ ```
172
+ For this purpose, the following functions exist:
173
+ * `isCorrectLeftReduction`
174
+ * `isCorrectRightReduction`
175
+ * `isCorrectRemovingEmptyFDs`
176
+ * `isCorrectCombinationOfDependencies`
177
+ * `isCorrectCanonicalCover`
178
+ * `isCorrectCreationOfNewFDS`
179
+
180
+ These functions are called on the FDSet with all steps before already calculated on it.
@@ -0,0 +1,153 @@
1
+ # DBIS Functional Dependencies
2
+
3
+ Functional Dependencies and Normal Forms for Relational Databases
4
+
5
+ [![PyPI Status](https://img.shields.io/pypi/v/dbis-functional-dependencies.svg)](https://pypi.python.org/pypi/dbis-functional-dependencies/)
6
+ [![pypi](https://img.shields.io/pypi/pyversions/dbis-functional-dependencies)](https://pypi.org/project/dbis-functional-dependencies/)
7
+ [![License](https://img.shields.io/pypi/l/dbis-functional-dependencies)](https://www.apache.org/licenses/LICENSE-2.0)
8
+ [![Pipeline Status](https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies/badges/main/pipeline.svg)](https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies/-/packages)
9
+
10
+ This library provides a Python implementation of the [synthesis algorithm](https://de.wikipedia.org/wiki/Synthesealgorithmus) and decomposition algorithm according to the DBIS lecture. For more background and application of functional dependencies and the algorithms, see [Doku-FunctionalDependencies](https://git.rwth-aachen.de/i5/teaching/dbis-jupyter/dbis-ss-2023-test/-/blob/main/doku/Doku-FunctionalDependencies.ipynb).
11
+
12
+ # Features
13
+ - Create sets of Functional dependencies (FDSets).
14
+ - Calculate candidate keys of an FDSet.
15
+ - Calculate attribute closure of an attribute or set of attributes.
16
+ - Test whether an FDSet is in 2NF, 3NF or BCNF.
17
+ - Execute the synthesis algorithm to transform the FDSet into 3NF.
18
+ - Execute the decomposition algorithm to transform the FDSet into BCNF.
19
+ - Generate the closure $F^+$ of an FDSet $F$.
20
+ - Generate true/false questions w.r.t. synthesis and decomposition algorithm.
21
+
22
+ # Installation
23
+ Install via pip:
24
+ ```bash
25
+ pip install dbis-functional-dependencies
26
+ ```
27
+
28
+ # Usage
29
+ ### Creating an FDSet
30
+ Create a new instance of `FunctionalDependencySet`. The set of attributes is passed as parameter.
31
+ ```python
32
+ fdset = FunctionalDependencySet('ABCDE')
33
+ ```
34
+ You can add more attributes later by using the `add_attribute` function.
35
+ ```python
36
+ fdset.add_attribute('F')
37
+ ```
38
+ Add dependencies with the `add_dependency` function ...
39
+ ```python
40
+ fdset.add_dependency("AC", "DE")
41
+ fdset.add_dependency("DEF", "B")
42
+ fdset.add_dependency("B", "D")
43
+ ```
44
+ ... or remove them with the `remove_dependency` function.
45
+ ```python
46
+ fdset.remove_dependency("B", "D")
47
+ ```
48
+
49
+ Printing an FDSet shows the dependencies in a more readable form.
50
+ ```python
51
+ print(f"{fdset}")
52
+ ```
53
+
54
+ ### Attribute closure and candidate keys
55
+ Calculate the attribute closure of one or multiple attributes.
56
+ ```python
57
+ closureA = fdset.get_attr_closure('A')
58
+ closureAC = fdset.get_attr_closure('AC')
59
+ ```
60
+
61
+ Calculate all candidate keys.
62
+ ```python
63
+ ckeys = fdset.find_candidate_keys()
64
+ ```
65
+
66
+ ### Check for normal forms
67
+ Since we only work with schemas (no actual values for the attributes), we assume that a corresponding database is in 1NF.
68
+
69
+ Check whether the FDSet is in 2NF, 3NF or BCNF.
70
+ ```python
71
+ is2NF = fdset.is2NF()
72
+ is3NF = fdset.is3NF()
73
+ isBCNF = fdset.isBCNF()
74
+ ```
75
+
76
+ ### Execute the synthesis algorithm
77
+ Execute the synthesis algorithm on an FDSet to generate a corresponding list of FDSets in 3NF.
78
+ ```python
79
+ fdslist = fdset.synthesize()
80
+ ```
81
+ The algorithm performs the following steps:
82
+
83
+ 0. Find the candidate keys.
84
+ 1. Calculate the canonical cover.
85
+ - left reduction
86
+ - right reduction
87
+ - remove dependencies with empty rhs
88
+ - combine dependencies with same lhs
89
+ 2. Create a new relation for every dependency in the canonical cover.
90
+ 3. Create the optional key scheme if no candidate key is included in the attribute set of one of the relations of step 2.
91
+ 4. Remove subset relations.
92
+
93
+ You receive additional information on the steps of the algorithm by toggling the parameter `verbose`.
94
+ ```python
95
+ fdslist = fdset.synthesize(vebose=True)
96
+ ```
97
+ Alternatively, you can also execute the single steps with the following functions:
98
+ ```python
99
+ fdset_step.canonical_cover()
100
+ fdslist_step = fdset_step.create_new_fdsets()
101
+ fdslist_step_with_key = FunctionalDependencySet.create_optional_key_scheme(self, ckeys, fdslist_step)
102
+ reduced_fdslist_step = FunctionalDependencySet.remove_subset_relations(self, fdslist_step_with_key)
103
+ ```
104
+ The verbose option exists for all steps.
105
+
106
+ ### Execute the decomposition algorithm
107
+ Execute the decomposition algorithm on an FDSet to generate a corresponding decomposition of FDSets in BCNF.
108
+ ```python
109
+ fdslist = fdset.decompose2()
110
+ ```
111
+ Before performing the actual algorithm, the the closure of the FDSet is calculated.
112
+
113
+ ### Closure of an FDSet
114
+ Calculate the closure $F^+$ of an FDSet $F$.
115
+ ```python
116
+ fdset.completeFDsetToClosure()
117
+ ```
118
+ This function just adds dependencies with all subset combinations of the attribute set with their corresponding closures on the rhs of the dependency, so that no implicit dependency is missed by the decomposition algorithm.
119
+
120
+ ### Exercise generator
121
+ Generate true/false statements based on the different steps of the algorithms.
122
+ ```python
123
+ fdslist = fdset.synthesize(genEx=True)
124
+ ```
125
+ The `genEx` option is available for the following functions:
126
+ * `find_candidate_keys`
127
+ * `synthesize`
128
+ * `canonical_cover`
129
+ * `left_reduction`
130
+ * `right_reduction`
131
+ * `remove_empty_fds`
132
+ * `combine_fds`
133
+ * `create_new_fdsets`
134
+ * `create_optional_key_scheme`
135
+ * `remove_subset_relations`
136
+ * `decompose2`
137
+
138
+ ### Checking results against expected
139
+ Checks a given calculated step of an FDSet during the synthesis algorithm (according to the DBIS lecture) for correctness.
140
+ ```python
141
+ original = fdset.copy()
142
+ fdset.left_reduction()
143
+ original.isCorrectLeftReduction(fdset)
144
+ ```
145
+ For this purpose, the following functions exist:
146
+ * `isCorrectLeftReduction`
147
+ * `isCorrectRightReduction`
148
+ * `isCorrectRemovingEmptyFDs`
149
+ * `isCorrectCombinationOfDependencies`
150
+ * `isCorrectCanonicalCover`
151
+ * `isCorrectCreationOfNewFDS`
152
+
153
+ These functions are called on the FDSet with all steps before already calculated on it.
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name="dbis-functional-dependencies"
3
+ version='1.0.1'
4
+ description="RWTH Aachen Computer Science i5/dbis assets for Lecture Datenbanken und Informationssysteme"
5
+
6
+ authors = [
7
+ { name = "DBIS i5 RWTH Aachen", email = "dbis-vl@dbis.rwth-aachen.de" }
8
+ ]
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.13"
15
+ ]
16
+
17
+ dependencies = [
18
+ "graphviz~=0.20",
19
+ "networkx~=2.7",
20
+ "numpy~=1.26",
21
+ "sphinx~=7.2",
22
+ "sphinxcontrib-apidoc~=0.4",
23
+ "functional-dependencies~=1.3",
24
+ "build~=1.0",
25
+ "pylodstorage~=0.4.11"
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ test = [
30
+ "black==23.12.1"
31
+ ]
32
+ build = [
33
+ "twine==6.*",
34
+ "build==1.*"
35
+ ]
36
+
37
+
38
+ [project.urls]
39
+ "Homepage" = "https://git.rwth-aachen.de/i5/teaching/dbis/dbis-functional-dependencies"
40
+
41
+ [options]
42
+ include_package_data = true
43
+ exclude = ["examples"]
44
+
45
+ [build-system]
46
+ requires = ["setuptools>=42"]
47
+ build-backend = "setuptools.build_meta"