Database System Concepts, Sixth Edition Chapter VIII Exercise 239

Chapter VIII database theory exercises

8.2

Satisfies functional dependency lists shown

A B C
a1 b1 c1
a1 b1 c2
a2 b1 c1
a2 b1 c3

answer:

Trivial dependence 19 kinds, such as all types since β∈α, it α-> β.

Single Attribute: A-> A, B-> B, C-> C;

双属性的:AB->A,AB->B,AB->AB;AC->A,AC->C,AC->AC;BC->B,BC->C,BC->BC

三属性的:ABC->A,ABC->B,ABC->C,ABC->AB,ABC->BC,ABC->AC,ABC->ABC;

The following non-trivial dependence, there are three kinds:

A-> B: Since the A-elements, like elements corresponding to each corresponding element B

C-> B: C for the same elements in both correspond to the same element B

AC-> B: Release from the above two

All elements are the same as B, A and C are attributes of different elements are present, B to B, non-dependent function which is not present

There is the same as in c A different mapping, so A-> C is not satisfied; C-> A The same does not hold.

8.3

How to explain the show with a functional dependency:

  • Entity sets one set of contact between student and instructor exist
  • Many-entity sets set contact between student and instructor exist

answer:

  • primarykey (student) -> primarykey (instructor) and primarykey (instructor) -> primarykey (student) represents one set of contact between the student and entity sets instructor, student to focus represents the same values ​​of students mapped to a tuple instuctor the instructor must have the same primary key value, for the instructor tuple having the same values ​​of teacher student is mapped to the student must have the same primary key.
  • primarykey (student) -> primarykey (instructor) many to one link set represented by the student for the same primary key value must correspond to the same primary key value instructor, one difference is the relationship between student may correspond to the same instructor.

8.9

Given database schema R (a, b, c), and the relation r pattern R, write test function dependent b-> c holds in relation r the SQL query. And write guarantee functional dependencies SQL assertion. The null hypothesis is not present.

A: The test b-> c holds also refers to the same can not be mapped to a different b c:

select b
from r
group by b                --通过b进行分类
having count(distinct c) > 1 --查看相同的b映射到c的种类是否大于1
--如果最终b是空集,则说明该函数依赖成立,否则说明不成立

It is also asserted by the above test results of the determination, if not empty assertion is generated:

create assertion func_b_c check
(
    not exists (select b              --用not exists进行判定
             from r
			 group by b
			 having count(distinct c) > 1)
)
Published 68 original articles · won praise 36 · views 10000 +

Guess you like

Origin blog.csdn.net/dingdingdodo/article/details/102732800