Sample Header Ad - 728x90

Database Administrators

Q&A for database professionals who wish to improve their database skills

Latest Questions

2 votes
2 answers
729 views
Is there a best practice for resolving dependencies of SQL objects for build during development?
I have a greenfield project involving a SQL database that is under development. There is no production data involved yet. There is a rather long list of specifications which I expect can be implemented with a collection of SQL tables, views, functions, and procedures. The overview of the inner loop...
I have a greenfield project involving a SQL database that is under development. There is no production data involved yet. There is a rather long list of specifications which I expect can be implemented with a collection of SQL tables, views, functions, and procedures. The overview of the inner loop of the development process is basically the following: 1. drop and recreate the database 2. create the tables, views, etc 3. import test data 4. run tests 5. make changes to code 6. repeat beginning at (1) The development has already involved a number of refactorings. The results of these refactorings are good. However, they usually precipitate a period of [dependency hell](https://en.wikipedia.org/wiki/Dependency_hell#:~:text=Dependency%20hell%20is%20a%20colloquial,versions%20of%20other%20software%20packages.) in step (2) during which I have to manually re-resolve the order of the files defining the objects are executed. That file order is currently hard-coded as a list of file names in a script. Each file has exactly one object defined in it. The process of manually resolving dependencies works, but is labor-intensive. For C and .Net projects in the past I have used [make](https://en.wikipedia.org/wiki/Make_(software)#:~:text=In%20software%20development%2C%20Make%20is,to%20derive%20the%20target%20program.) and [MSBuild](https://en.wikipedia.org/wiki/MSBuild) to manage dependencies, respectively. I can almost imagine how to manage SQL dependencies with those tools, but I haven't seen it done and I'd rather not re-invent the wheel if there is a method that is already proven. A search of stackoverflow for [makefile](https://stackoverflow.com/questions/tagged/makefile+sql) and [MSBuild](https://stackoverflow.com/questions/tagged/msbuild+sql) with SQL didn't produce any results that were obviously on-point. Is there a best practice for resolving dependencies of SQL objects for build during development?
alx9r (449 rep)
Feb 25, 2023, 05:59 PM • Last activity: Apr 5, 2025, 03:47 PM
2 votes
1 answers
1366 views
Finding all possible minimal covers
I have a relation schema R = {A, B, C} and the following functional dependencies: - A → B - A → C - B → A - B → C - C → A - C → B How many different minimal covers can I derive from this relation schema? I have found the following, but I am not really sure if those are all: - A → C - B → C - C → A -...
I have a relation schema R = {A, B, C} and the following functional dependencies: - A → B - A → C - B → A - B → C - C → A - C → B How many different minimal covers can I derive from this relation schema? I have found the following, but I am not really sure if those are all: - A → C - B → C - C → A - C → B Also, I am not sure if there is some rule on how to know if one has found all possible minimal covers. Thanks a lot for any help!
BlackPearl (39 rep)
Oct 10, 2019, 06:54 AM • Last activity: Apr 4, 2025, 04:00 PM
4 votes
1 answers
4169 views
Way to obtain full list of column dependencies for stored procedure?
I've built a stored procedure (which we can call `sproc_deps`) that uses `sys.sql_expression_dependencies` and `sys.dm_sql_referenced_entities`. I want it to list out **all** of the tables and columns used by a stored procedure of the user's choice. This stored procedure will have its name passed as...
I've built a stored procedure (which we can call sproc_deps) that uses sys.sql_expression_dependencies and sys.dm_sql_referenced_entities. I want it to list out **all** of the tables and columns used by a stored procedure of the user's choice. This stored procedure will have its name passed as an argument to sproc_deps. The problem is that I'm getting columns that the stored procedure doesn't actually use when I combine sys.sql_expression_dependencies and sys.dm_sql_referenced_entities. In order to get the information I want, I've JOINed a few other things on as well: - sys.objects(for object IDs, and type_desc) - sys.tables(to match against tables contained in sys.sql_expression_dependencies) - sys.views (because I'm interested in both views and tables) - sys.columns (to pull columns for each table or view involved) Here is the actual JOIN: sys.sql_expression_dependencies AS sed INNER JOIN sys.objects AS o ON sed.referencing_id = o.object_id LEFT OUTER JOIN sys.tables t on sed.referenced_entity_name = t.name LEFT OUTER JOIN sys.views v on sed.referenced_entity_name = v.name LEFT OUTER JOIN sys.columns c on (c.object_id = t.object_id OR c.object_id = v.object_id) INNER JOIN sys.dm_sql_referenced_entities (N'dbo.DummySprocName', 'OBJECT') s ON s.referenced_entity_name = sed.referenced_entity_name Using just sys.sql_expression_dependencies nets a small list of tables that I can't really decipher, and using sys.dm_sql_referenced_entities yields a **partial** list of tables and columns used by the procedure. Is it possible for sproc_deps to return the correct list of tables and columns used by a procedure **using just T-SQL**? If so, how? --- Here is my full code as requested (still working on reproducible example for missing dependencies): CREATE PROCEDURE [dbo].[usp_v9_SprocDocInfo_FullDependency_SingleSproc] @SprocName NVARCHAR(150) = '' AS BEGIN DECLARE @ObjName NVARCHAR(128) = NULL DECLARE @rowCount INT = 0 DECLARE @HasNulls BIT = 0 DECLARE @DepExists BIT = 0 --temp table to hold output --match this against view!!! CREATE TABLE #TempData ( FullName NVARCHAR(300) not null, ShortName NVARCHAR(128) not null, TableName NVARCHAR(128), ObjectName NVARCHAR(128), column_name NVARCHAR(128), [definition] NVARCHAR(MAX), LastUpdated DATETIME, [Type] NVARCHAR(60), [object_id] INT, SprocNo BIGINT ) --temp table to hold pure dependencies CREATE TABLE #Sproc_FullTableCols ( RefEntity NVARCHAR(256), TableName NVARCHAR(256), ColName NVARCHAR(256), TypeDesc NVARCHAR(256) ) --first, grab known dependency data for this particular sproc from the correct view INSERT INTO #TempData SELECT FullName, ShortName, TableName, ObjectName, column_name, [definition], LastUpdated, [Type], [OBJECT_ID], SprocNo FROM v9_Sproc_DocInfo WHERE ShortName = @SprocName --next grab any data not covered in the previous query --this will be tables/views and ALL columns for objects found in sproc INSERT INTO #Sproc_FullTableCols --https://www.sqlrx.com/using-sys-sql_expression_dependencies-as-a-single-source-to-find-referenced-and-referencing-objects/ SELECT DISTINCT OBJECT_NAME(referencing_id) AS referencing_entity_name, CASE WHEN t.name is null then V.name when V.name is null THEN t.name ELSE NULL END, c.name, case when t.name is not null then t.type_desc when v.name is not null then v.type_desc else o.type_desc end AS referencing_desciption FROM sys.sql_expression_dependencies AS sed INNER JOIN sys.objects AS o ON sed.referencing_id = o.object_id LEFT OUTER JOIN sys.tables t on sed.referenced_entity_name = t.name LEFT OUTER JOIN sys.views v on sed.referenced_entity_name = v.name LEFT OUTER JOIN sys.columns c on (c.object_id = t.object_id OR c.object_id = v.object_id) INNER JOIN sys.dm_sql_referenced_entities (N'dbo.' + @SprocName, 'OBJECT') s ON s.referenced_entity_name = sed.referenced_entity_name WHERE referencing_id = OBJECT_ID(N'dbo.' + @SprocName) --clean up DELETE FROM #Sproc_FullTableCols WHERE (TableName IS NULL OR ColName IS NULL)-- OR MinorRef IS NULL) WHILE @HasNulls = 0 BEGIN --pull the first row of junk data from the v9 results SET @ObjName = (SELECT TOP 1 ObjectName FROM #TempData WHERE (TableName IS NULL AND column_name IS NULL)) SET @DepExists = CASE WHEN @ObjName IN (SELECT TableName FROM #TempData) THEN 1 ELSE 0 END --see if pull was successful; if so update flag accordingly IF (@ObjName IS NOT NULL) SET @HasNulls = 1 ELSE BREAK IF @HasNulls = 1 AND @DepExists = 0 BEGIN INSERT INTO #TempData SELECT DISTINCT (N'dbo.' + @SprocName) AS FullName, @SprocName AS ShortName, @ObjName AS TableName, '-' AS ObjectName, z.ColumnName AS column_name, z.Description AS [definition], GETDATE() AS LastUpdated, '*' + (N'' + c.TypeDesc) AS [Type], OBJECT_ID(N'dbo.' + @SprocName) AS [object_id], 0 AS SprocNo FROM z9_BaseTables_Columns z INNER JOIN #Sproc_FullTableCols c ON (z.[Table] = c.TableName collate Latin1_General_CI_AI AND z.ColumnName = c.ColName collate Latin1_General_CI_AI) WHERE z.[Table] = @ObjName collate Latin1_General_CI_AI END --clean out row used for input DELETE TOP (1) FROM #TempData WHERE ObjectName = @ObjName AND TableName IS NULL AND column_name IS NULL SET @HasNulls = 0 SET @ObjName = '' END --finally, print results then discard the temp table SELECT * FROM #TempData order by [Type] asc, FullName asc, ObjectName asc, TableName asc, column_name asc, LastUpdated asc DROP TABLE #TempData DROP TABLE #Sproc_FullTableCols END This will create a procedure that grabs known dependency data for a procedure from a view (v9_Sproc_DocInfo) that uses only sys.sql_expression_dependencies and sys.dm_sql_referenced_entities. Then I pull the full list of columns for any table used by the procedure, filter out anything already contained in v9_Sproc_DocInfo, and combine this data with the view data as output.
Antidiscrete (51 rep)
Oct 10, 2019, 07:59 PM • Last activity: Mar 13, 2025, 12:07 PM
1 votes
1 answers
44 views
How do model different logical views on data
Simplified example of a data modeling problem that I have: I have a domain model with an `image` table, a `camera` table, a `machine` table, a foreign key constraint between image and camera (`taken_by_camera`), and a FK between camera and machine (`installed_into_machine`). image taken_by_camera ca...
Simplified example of a data modeling problem that I have: I have a domain model with an image table, a camera table, a machine table, a foreign key constraint between image and camera (taken_by_camera), and a FK between camera and machine (installed_into_machine). image taken_by_camera camera camera installed_into_machine machine All of this is based on the data, we get from customers. However, in our application we utilize the data almost always in terms of sets of images. So, we also have a set table. Each image belongs to a set and for that we have a belongs_to_set FK on the image table. image belongs_to_set set My problem is that I would like to restrict the sets on containing images of a specific machine only, e.g. set restricted_to_machine machine With just these FKs in place, I have no constraint that ensures that all images that are connected via camera to a specific machine also end up being connected to the same machine via the set. image_1 taken_by_camera camera_1 camera_1 installed_into_machine **machine_1** image_1 belongs_to_set set_1 set_1 restricted_to_machine **machine_2** How can I model something like this (logically but also in postgres). PS: It should be possible to have images taken by different cameras in a set as long as these cameras are installed in the same machine.
Pete (13 rep)
Jul 7, 2024, 10:20 AM • Last activity: Jul 7, 2024, 11:43 AM
0 votes
1 answers
46 views
Are functional depencies with boolean conditions a thing?
Suppose we have a relation R(A, B, C) with the FD A -> B. Let's say that, for two tuples t and u in R, if both t[C] and u[C] satisfy a boolean condition - say less than a constant C - then t[B] = u[B]. Does this constitute a functional dependency? On a more practical sense, how to normalize this rel...
Suppose we have a relation R(A, B, C) with the FD A -> B. Let's say that, for two tuples t and u in R, if both t[C] and u[C] satisfy a boolean condition - say less than a constant C - then t[B] = u[B]. Does this constitute a functional dependency? On a more practical sense, how to normalize this relation and eliminate the clear redundancy in R(A, B, C) and allow for lossless joins?
Antônio Gabriel Zeni Landim (11 rep)
Jul 14, 2023, 03:41 PM • Last activity: Jul 14, 2023, 08:06 PM
0 votes
0 answers
55 views
Functional Dependencies and Armstrong notation fundementals
if AB -> C and B -> A does that mean B -> C? B -> B is trivial and if we do composition with B->A, it becomes (B-> BA), then by transitivity does that mean B->C? but if B -> C is correct, it contradicts with the fact that B needs A to determines C
if AB -> C and B -> A does that mean B -> C? B -> B is trivial and if we do composition with B->A, it becomes (B-> BA), then by transitivity does that mean B->C? but if B -> C is correct, it contradicts with the fact that B needs A to determines C
Jonathan Kho (9 rep)
Apr 4, 2023, 02:27 PM • Last activity: Apr 8, 2023, 09:58 AM
0 votes
1 answers
140 views
Database Dependency Chart?
I have several SQL Server (2008 forward) and Oracle (12c forward) legacy databases running on a server... I know for a fact that various stored procedures point to other databases, like `select * from OtherDB.mySchema.Products`, which makes a database dependent on `OtherDB`... Is there a easy way to...
I have several SQL Server (2008 forward) and Oracle (12c forward) legacy databases running on a server... I know for a fact that various stored procedures point to other databases, like select * from OtherDB.mySchema.Products, which makes a database dependent on OtherDB... Is there a easy way to map this "interdependencies", ideally generating a chart?
Leonardo (237 rep)
Mar 14, 2023, 01:41 PM • Last activity: Mar 14, 2023, 10:11 PM
3 votes
2 answers
2154 views
Why is this relation in 3NF?
I have a relation: R4 = {{T,U,V}, {T → U, U → T, T → V}} I know from looking at the answer key that this relation is in BCNF. I'm going through the process of rigorously determining what normal form the relationship adheres to. It's clear to me why the relationship is in 1NF and 2NF, and if I assume...
I have a relation: R4 = {{T,U,V}, {T → U, U → T, T → V}} I know from looking at the answer key that this relation is in BCNF. I'm going through the process of rigorously determining what normal form the relationship adheres to. It's clear to me why the relationship is in 1NF and 2NF, and if I assume it's in 3NF, BCNF follows easily. However, the definition of 3NF states: >Every non-prime attribute is non-transitively dependent on every candidate key in the table. But, as far as I can tell, both {T} and {U} are candidate keys of the table, and {V} is thus transitively dependent on {U}. There is an alternate definition of 3NF available on wikipedia: >A 3NF definition that is equivalent to Codd's, but expressed differently, was given by Carlo Zaniolo in 1982. This definition states that a table is in 3NF if and only if, for each of its functional dependencies X → A, at least one of the following conditions holds: >* X contains A (that is, X → A is trivial functional dependency) * X is a superkey * Every element of A-X, the set difference between A and X, is a prime attribute (i.e., each column in A-X is contained in some candidate key) And the relation is clearly in 3NF by this definition (all of the functional dependencies are covered by "X is a superkey"). So why the discrepancy? How am I misapplying the definition? Please don't give me shortcuts that give me the answer in a way I don't want, unless you also help me understand why my application of 3NF (as described) is inaccurate.
Wug (133 rep)
Feb 20, 2013, 01:42 AM • Last activity: Jan 12, 2023, 11:19 AM
0 votes
0 answers
87 views
Why is the relation in 3NF?
> A relation is in 3NF (Third Normal Form) if it is in 2NF (Second Normal Form) and all the FDs (functional dependencies) in the relation are in the form X -> Y, where X is a superkey (a set of attributes that uniquely identifies a tuple in the relation) and Y is a non-prime attribute (an attribute...
> A relation is in 3NF (Third Normal Form) if it is in 2NF (Second Normal Form) and all the FDs (functional dependencies) in the relation are in the form X -> Y, where X is a superkey (a set of attributes that uniquely identifies a tuple in the relation) and Y is a non-prime attribute (an attribute that is not a part of the primary key).
SP (Sno, Sname, Pno, Qty)
Functional dependencies:
Sno, Pno -> Qty
Sname, Pno -> Qty
Sno -> Sname
Sname -> Sno
The candidate keys are Sno, Pno and Sname, Pno. So the first 2 are in the form quoted above while the last two aren't. For instance in the case of Sno -> Sname, Sno is not a superkey and Sname is a prime attribute. So why is the relation in 3NF?
zeeshanseikh (101 rep)
Jan 9, 2023, 04:48 AM • Last activity: Jan 9, 2023, 10:32 AM
1 votes
1 answers
668 views
SQL query to get the order of procedures based on their dependent procedures
i have this query to get all sp's and depending(nested) sp's on those sp's. I need to create all these procedures on another database . Any idea how to get them in the correct order. select distinct procs.NAME AS ProcedureName ,OBJDEP.NAME as DEP_ProcedureName_NAME FROM sysdepends INNER JOIN sys.obj...
i have this query to get all sp's and depending(nested) sp's on those sp's. I need to create all these procedures on another database . Any idea how to get them in the correct order. select distinct procs.NAME AS ProcedureName ,OBJDEP.NAME as DEP_ProcedureName_NAME FROM sysdepends INNER JOIN sys.objects OBJ ON sysdepends.ID = OBJ.OBJECT_ID INNER JOIN sys.objects OBJDEP ON sysdepends.DEPID = OBJDEP.OBJECT_ID inner join sys.procedures procs on sysdepends.id = procs.object_id where OBJDEP.type='P' AND OBJ.type='P'
Viz Krishna (109 rep)
Nov 24, 2022, 08:28 AM • Last activity: Nov 25, 2022, 07:04 AM
-1 votes
1 answers
71 views
Why aren't normal forms defined more simply?
I believe that 2nd and 3rd normal form definitions could obviously be specified with less complexity, but they're not. The definition found in textbooks is something like this: **2NF: No partial FD between prime and non-prime attributes.** This means there is no such situation as: ```A -> B -> C```...
I believe that 2nd and 3rd normal form definitions could obviously be specified with less complexity, but they're not. The definition found in textbooks is something like this: **2NF: No partial FD between prime and non-prime attributes.** This means there is no such situation as:
-> B -> C
where
is a key,
its subset, and
a non-prime. As
-> B
always holds for every B, this could be simplified by removing
-> B
to get
-> C
, or: **2NF-new: No FD between a subset of a key and a non-prime.** and, **3NF: No indirect FD between a key and non-prime attributes.** This means there is no such thing as:
-> NP1 -> NP2
. Again, as
-> X
for every X, this could be simplified to get
-> NP2
leading to: **3NF-new: No FD between two non-primes.** However, I have not seen this simplified version anywhere, except > Equivalently, a transitive dependency exists when a nonprime > attribute determines another nonprime attribute. What makes me is more doubtful is the word *typically* in > A nonprime attribute determines another nonprime attribute. Here we > typically have a transitive dependency that violates 3NF. By Elmasri and Navathe. So why not *always*? Are my definitions wrong? If not, why are they not used?
Mehrin (9 rep)
Oct 12, 2022, 07:53 PM • Last activity: Oct 13, 2022, 04:54 AM
4 votes
1 answers
1690 views
Identifying functional dependencies
I'm having trouble understanding the logic in use for identifying functional dependancies. Looking at the sample relation below, I understand fd1 - fd3. But when I look at fd4 and fd5, its logic makes me believe that fd6 and fd7 would also be possible, but it's not according to the book I'm studying...
I'm having trouble understanding the logic in use for identifying functional dependancies. Looking at the sample relation below, I understand fd1 - fd3. But when I look at fd4 and fd5, its logic makes me believe that fd6 and fd7 would also be possible, but it's not according to the book I'm studying. The logic that operates fd4 and fd5 is to me: > We conclude that unique combination of values in in columns A and B such as (a, b) is associated with a single value in column E, which in this example is "q". In other words attributes (A, B) functionally determines attribute E, and this is shown as fd4 in the sample relation. We also conclude that attributes (B, C) functionally determine attribute E using the same reasoning described earlier, and this functional dependancy is shown as fd 5 in the sample relation. So why is fd6 and fd7 not true? ![A sample relation](https://i.sstatic.net/84sV7.png)
JazzMaster (141 rep)
Aug 12, 2014, 01:28 PM • Last activity: Jul 30, 2022, 11:02 AM
2 votes
1 answers
828 views
If A and B are candidate keys, then AB is candidate key or not ?
If R{abc} is a relation, f{ a->b b->a a->c b->c }, then a and b are candidate keys. What about ab ? Is it a candidate key or is it a super key or both ?
If R{abc} is a relation, f{ a->b b->a a->c b->c }, then a and b are candidate keys. What about ab ? Is it a candidate key or is it a super key or both ?
SAIBHARATH S (21 rep)
Jan 28, 2015, 06:20 AM • Last activity: Apr 4, 2022, 08:47 PM
0 votes
1 answers
752 views
Is there a dependency preserving, lossless BCNF decomposition for this relational schema?
R(A,B,C) where {AB -> C , C -> A}. The candidate keys are {A,B} and {C,B}. This is in 3NF but not BCNF because of {C->A} . Now it seems like this can't even be split into a lossless BCNF, let alone a dependency preserving one. Is there some way to prove it? Is there some result that says that if the...
R(A,B,C) where {AB -> C , C -> A}. The candidate keys are {A,B} and {C,B}. This is in 3NF but not BCNF because of {C->A} . Now it seems like this can't even be split into a lossless BCNF, let alone a dependency preserving one. Is there some way to prove it? Is there some result that says that if the result of the 3NF algorithm does not give you a BCNF decomposition, then a further BCNF decomposition is not possible? Edit: I have since figured out that every schema can be split into a lossless BCNF one. It is preserving dependency that is uncertain. Here the lossless decomposition would be R(B,C), R(C,A)
user2277550 (107 rep)
Apr 3, 2022, 02:24 PM • Last activity: Apr 3, 2022, 04:36 PM
1 votes
1 answers
103 views
Is F included in F+?
The definition in my book says: > *The set of all functional dependencies logically implied by F is the closure of F.* My question is, do we include FDs in F in F closure as well ? If I have: - `F = {A→B, B→C}` - a) `F+ = {A→C, A→BC, A→B, B→C}` - b) `F+ = {A→C, A→BC}` Which one would be correct a) o...
The definition in my book says: > *The set of all functional dependencies logically implied by F is the closure of F.* My question is, do we include FDs in F in F closure as well ? If I have: - F = {A→B, B→C} - a) F+ = {A→C, A→BC, A→B, B→C} - b) F+ = {A→C, A→BC} Which one would be correct a) or b) ?
johndoe123 (45 rep)
Apr 13, 2018, 07:01 AM • Last activity: Dec 21, 2021, 09:32 AM
-1 votes
1 answers
409 views
How can I prove / disprove If A ↠ B then AC ↠ B
If A ↠ B then AC ↠ B is it true or false and if so can have example why?
If A ↠ B then AC ↠ B is it true or false and if so can have example why?
omer (1 rep)
Nov 30, 2021, 05:00 PM • Last activity: Dec 1, 2021, 08:32 AM
0 votes
1 answers
17160 views
Converted ERD into Dependency Diagram 1NF, 3NF
![enter image description here][1] [1]: https://i.sstatic.net/yU44g.png Thats the ERD. I'm studying for an upcoming test and having trouble getting my head around converting this ERD into dependency diagrams. This is from a previous exam that the Lecturer told us to study just btw so he said it will...
enter image description here Thats the ERD. I'm studying for an upcoming test and having trouble getting my head around converting this ERD into dependency diagrams. This is from a previous exam that the Lecturer told us to study just btw so he said it will be pretty similar to this. We have to - - Convert the ERD into a dependency diagram. - And then, convert that diagram into a 3NF model, with no transitive or partial dependencies. Any help would be much appreciated as I'm struggling to get my head around it and need to pass this test :/ Thanks in advance!
David Dornlay (1 rep)
Aug 19, 2014, 07:48 AM • Last activity: Jun 19, 2021, 11:24 AM
3 votes
1 answers
1166 views
Questions Concerning the Chase Test
> 2. [5 Marks] Let R(A,B,C,D,E) be decomposed into relations with the following three set of attributes {A,B,C}, {B,C,D}, and {A,C,E}. For each of the following sets of FD's, use the chase test to tell whether the decomposition of R is lossless. For those that are not lossless, give an example of an...
> 2. [5 Marks] Let R(A,B,C,D,E) be decomposed into relations with the following three set of attributes {A,B,C}, {B,C,D}, and {A,C,E}. For each of the following sets of FD's, use the chase test to tell whether the decomposition of R is lossless. For those that are not lossless, give an example of an instance of R that returns more than R when projected onto the decomposed relation and rejoined. > > a. A→D, CD→E and E→D. > > b. A→D, D→E and C→D. For the question above, my work for each of the questions is below the concerns. Here are my main concerns: 1. Does the order in which you use the relations matter? 2. Can you end up with less tuples with the chase test? 3. Is my approach correct? -----------------------Part A below---------------------------------- InitialTableau = T₁ ⋈ T₂ ⋈ T₂
+----+----+----+----+----+
| A  | B  | C  | D₁ | E₁ |
+----+----+----+----+----+
| A₂ | B  | C  | D  | E₂ |
+----+----+----+----+----+
| A  | B₂ | C  | D₂ | E  |
+----+----+----+----+----+
-----------------------ANSWER TO QUESTIONS START NOW----------------------- a) After changing the initial tableau in a way that ensures that the FD's given in the question are satisfied, we get the following tableau.
+----+----+----+----+----+
| A  | B  | C  | D₁ | E  |
+----+----+----+----+----+
| A₂ | B  | C  | D  | E₂ |
+----+----+----+----+----+
| A  | B₂ | C  | D₁ | E  |
+----+----+----+----+----+
- Since we do not have an unsubscribed row, this relation is lossy/not lossless. Example of an instance R (Were going to use the final tableau): R₁(A,B,C)
+----+----+----+
| A  | B  | C  |
+----+----+----+
| A₂ | B  | C  |
+----+----+----+
| A  | B₂ | C  |
+----+----+----+
R₂(B,C,D)
+----+----+----+
| B  | C  | D₁ |
+----+----+----+
| B  | C  | D  |
+----+----+----+
| B₂ | C  | D₁ |
+----+----+----+
R₃(A,C,E)
+----+----+----+
| A  | C  | E₂ |
+----+----+----+
| A₂ | C  | E₂ |
+----+----+----+
| A  | C  | E  |
+----+----+----+
After Joining the above relations, we get:
+----+----+----+----+----+
| A  | B  | C  | D₁ | E  |
+----+----+----+----+----+
| A  | B  | C  | D  | E  |
+----+----+----+----+----+
| A₂ | B  | C  | D₁ | E₂ |
+----+----+----+----+----+
| A₂ | B  | C  | D  | E₂ |
+----+----+----+----+----+
| A  | B₂ | C  | D  | E  |
+----+----+----+----+----+
- **since we have 2 more rows than the original tableau, this decomposition is not lossless.** b) After changing the initial tableau in a way that ensures that the FD's given in the question are satisfied, we get the following tableau.
+----+----+----+----+----+
| A  | B  | C  | D  | E  |
+----+----+----+----+----+
| A₂ | B  | C  | D  | E  |
+----+----+----+----+----+
| A  | B₂ | C  | D  | E  |
+----+----+----+----+----+
- Since we have an unsubscribed row, this decomposition is lossless.
Niroosh Ka (55 rep)
Jul 10, 2018, 04:21 AM • Last activity: May 14, 2021, 10:02 AM
0 votes
1 answers
2540 views
How do I identify functional dependencies and normalize a table based on the attributes?
I'm having trouble identifying the combination of attributes which make up Functional Dependencies(FDs) of a particular table. While I understand how Normalization process works when given the FDs, I'm unable to translate and identify FDs for a given table. I've been tasked to create a database of a...
I'm having trouble identifying the combination of attributes which make up Functional Dependencies(FDs) of a particular table. While I understand how Normalization process works when given the FDs, I'm unable to translate and identify FDs for a given table. I've been tasked to create a database of a company which tracks all expenses of sales/packages etc. Naturally that means storing Customer information for the company to identify all consumers.
CREATE TABLE Customers (
    id        integer primary key,
    address   text not null,
    name      text not null,
    email     text unique not null,
    phone     text unique not null,
    unique(name, address)
);
I've chosen to represent the info for the customer table as such, given that each phone number and email is uniquely tied to the customer. The unique constraint allows for multiple people from the same household address to be present in the table. I want to see if I can normalize this table further, however I am unable to identify the attributes to determine the FDs needed.
Naja (13 rep)
Apr 13, 2021, 07:55 AM • Last activity: Apr 13, 2021, 12:48 PM
-1 votes
1 answers
133 views
Translate text into functional dependency
In an exercise I have the following text which should be translated into a functional dependency: "A module realizes a business case and is developed by an author" My reasoning is that the business case and author exist before the module therefore the author and business case determine the module: a...
In an exercise I have the following text which should be translated into a functional dependency: "A module realizes a business case and is developed by an author" My reasoning is that the business case and author exist before the module therefore the author and business case determine the module: author, business case -> module However my script gives the solution: module -> author, business case Can somebody help why the latter is true and not the former?
Rubus (131 rep)
Jan 10, 2021, 03:43 PM • Last activity: Jan 10, 2021, 07:30 PM
Showing page 1 of 20 total questions