Home > Mobile >  Return table if functional dependency is implied to table
Return table if functional dependency is implied to table

Time:11-28

Let R be a (non-empty) relation with attributes a, b and c.

Write a SQL query returning a table containing the single value ’True’ iff the functional dependency

a, b → c is implied by the table (otherwise the query answer should be empty).

Any help would be appreciated, thanks.

If functional dependency (a,b) -> (c) is implied ie. -

a   b   c
--  --  --
20  15  10
20  15  10

Query should output something like this:

value
-----
True

CodePudding user response:

You can do:

select 'true' as value where not exists
  (select null from t group by a, b having count(distinct c) > 1)

See running example at db<>fiddle.

  •  Tags:  
  • sql
  • Related