YouTube2Text

Relational Database Design (Contd.) - 2 — Transcript

by Data Base Management System - IITKGP · 5,075 words · 878 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:16welcome to module 18 of database
  3. 0:19management systems we have been
  4. 0:21discussing about
  5. 0:22relational database design this is the
  6. 0:25part three of that
  7. 0:27in the last
  8. 0:28module we discussed about
  9. 0:31the notion of functional dependency and
  10. 0:33decomposition based on that in the
  11. 0:35elementary level and certain bit of its
  12. 0:38theory
  13. 0:39in this
  14. 0:40current module we learnt
  15. 0:42different algorithms that use the
  16. 0:45functional dependencies and can make
  17. 0:48conclusions about the design or make
  18. 0:50changes to the design we will also try
  19. 0:53to understand the characterization for
  20. 0:56lossless
  21. 0:57joint decomposition and the notion of
  22. 1:00deter dependency preservation
  23. 1:03therefore this module will have these
  24. 1:05three ah topics ah algorithms for
  25. 1:07functional dependencies lossless joint
  26. 1:09depend decomposition and dependency
  27. 1:12preservation
  28. 1:13so first we start with the algorithms
  29. 1:15and i quickly reproduce
  30. 1:18where we had ended in the last module in
  31. 1:20terms of computing the closure of a set
  32. 1:23of attributes so if we have a relation
  33. 1:27having these attributes and a set of
  34. 1:29functional dependencies then for a given
  35. 1:32subset of attributes in this case a g we
  36. 1:35can iteratively compute the closure set
  37. 1:38when no further changes can be done
  38. 1:40and
  39. 1:41with using that we can make different
  40. 1:43conclusions for example if our question
  41. 1:46is whether
  42. 1:47a g can be a candidate key
  43. 1:50we would
  44. 1:52first like to check whether it is a
  45. 1:54super key that is whether its closure
  46. 1:56has all the attributes of r
  47. 1:58or
  48. 1:58and we would like to check if we have
  49. 2:00take a subset
  50. 2:02of a g if we take just as attribute a or
  51. 2:05attribute g whether
  52. 2:07the closure of that will actually work
  53. 2:09as a key or not
  54. 2:11so this algorithm of
  55. 2:14attribute closure turns out to be a very
  56. 2:16powerful one where as we have just seen
  57. 2:19it can be used for checking ah super
  58. 2:21keys candidate keys primary non primary
  59. 2:24attributes and so on it can be used for
  60. 2:27checking functional dependencies for
  61. 2:29example let us
  62. 2:31suppose that if we have to check that
  63. 2:33whether if a particular functional
  64. 2:35dependency
  65. 2:36alpha determines beta holds
  66. 2:39ah
  67. 2:40then or or rather in other words whether
  68. 2:43alpha determines beta is in the closure
  69. 2:45of the set of functional dependencies f
  70. 2:48then all that we need to do is to
  71. 2:50compute alpha plus that is a closure of
  72. 2:53the set of attributes on the left hand
  73. 2:55side of the dependency and check if beta
  74. 2:58is a subset of that if beta is a subset
  75. 3:00of that then i know that alpha
  76. 3:02determines beta actually holds
  77. 3:06so ah in in this manner it can also be
  78. 3:10used
  79. 3:11to compute the closure of ah the whole
  80. 3:14set of functional dependencies f so if
  81. 3:17we i mean at least at a ah rudimentary
  82. 3:20level we can think of that if we take
  83. 3:23any subset of
  84. 3:24the set of attributes and find the
  85. 3:28closure and then all attributes that
  86. 3:31belong to that closure set are actually
  87. 3:34functionally dependent and therefore
  88. 3:36those functional dependencies will exist
  89. 3:40now we move forward from
  90. 3:42there and talk about what is known as a
  91. 3:45canonical cover a set of functional
  92. 3:47dependencies
  93. 3:49may have a number of redundant
  94. 3:51dependencies also so we need to
  95. 3:52understand that because there are lot of
  96. 3:54dependencies which can be inferred from
  97. 3:57a certain set of dependencies for
  98. 3:59example if you look into this set you
  99. 4:01will easily understand that
  100. 4:03in this whole set if i actually have
  101. 4:05just this we will be able to by
  102. 4:08transitivity we will be able to conclude
  103. 4:10about a determining c so in that way a c
  104. 4:14a determining c is a redundant ah
  105. 4:17dependency
  106. 4:19so
  107. 4:20here i am just showing you some examples
  108. 4:22so for example say i have a set of
  109. 4:26functional dependencies as this
  110. 4:30as this set
  111. 4:32and i want to know whether
  112. 4:34i can
  113. 4:35replace it by a simpler set here
  114. 4:39where
  115. 4:40this
  116. 4:41particular attribute on the right hand
  117. 4:43side of this dependency may be
  118. 4:45extraneous
  119. 4:47so if i have to do that then what we
  120. 4:49need to perform is we need to show that
  121. 4:53ah
  122. 4:54given the ah set of
  123. 4:57functional dependencies the original set
  124. 5:01whether this can imply this set that is
  125. 5:04from this set of functional dependencies
  126. 5:06whether i can logically conclude the
  127. 5:09simplified set
  128. 5:10so
  129. 5:11using the rules we will need to do that
  130. 5:13i have worked that out here under the
  131. 5:15forward scheme
  132. 5:17and we would also need to establish that
  133. 5:20if i have the simplified set then can i
  134. 5:23go to the
  135. 5:25original set that was given so if the
  136. 5:29simplified set also logically implies
  137. 5:32the original set then we can say that
  138. 5:34these are in a way
  139. 5:36ah equivalent
  140. 5:38and therefore i would like to use the
  141. 5:40simpler set
  142. 5:42so there is a another
  143. 5:43example following here
  144. 5:46where
  145. 5:50i have a
  146. 5:52another set given where
  147. 5:55if you look into this i would like to
  148. 5:57check whether i can get rid of this c on
  149. 5:59the left hand side and as as it stands
  150. 6:03we can actually do that
  151. 6:05and here in this whole process i have
  152. 6:09shown it in terms of using the
  153. 6:11armstrong's axioms how you can prove
  154. 6:13this but what we can
  155. 6:16do to systematize this whole process we
  156. 6:19can again make use of the
  157. 6:23ah
  158. 6:23notion of ah
  159. 6:26closure of attributes and
  160. 6:28ah compute whether to these two sets are
  161. 6:31equivalent whether simplification can be
  162. 6:33done so we will say a cover is canonical
  163. 6:36if it is in a sense minimal
  164. 6:39and still equivalent to the original set
  165. 6:41of dependencies and we will formally
  166. 6:43introduce what is
  167. 6:45minimal before that lets ah just look at
  168. 6:47the same examples again so
  169. 6:51we are trying to show the forward
  170. 6:52direction in the first case
  171. 6:54and the reverse direction in the first
  172. 6:56case but the only difference that i
  173. 6:58wanted to highlight is in terms of
  174. 7:00showing that you do not need to really
  175. 7:03explore on the armstrong's axioms but
  176. 7:05what you can do is you can simply take
  177. 7:07the left hand side attribute and compute
  178. 7:10a closure and see whether the right hand
  179. 7:12side is included that is basically
  180. 7:14testing for whether the given ah
  181. 7:16functional dependency is actually
  182. 7:17implied
  183. 7:18similar things can be done to simplify
  184. 7:20the left hand side also so this is the
  185. 7:23other example that i showed and i am
  186. 7:25just showing you that how you conclude
  187. 7:27this based on the ah closure of
  188. 7:30attributes algorithm
  189. 7:33so now i can formally define ah these
  190. 7:36possible removal so if i can remove an
  191. 7:38attribute as i have shown i can remove
  192. 7:40it from the right hand side or i can
  193. 7:42remove it from the left hand side so if
  194. 7:44an attribute can be removed then it is
  195. 7:46called extraneous
  196. 7:48so if i
  197. 7:50have a a functional dependency
  198. 7:54lets say
  199. 7:55alpha functionally determines beta
  200. 7:58and i have an attribute a which belongs
  201. 8:01to alpha
  202. 8:02then we can check whether it is possible
  203. 8:04to remove
  204. 8:06a from alpha so to test that what we do
  205. 8:09is we form a new set by removing the
  206. 8:12original functional dependency and
  207. 8:14adding the new functional dependency
  208. 8:16where the left hand side does not have
  209. 8:18that a
  210. 8:19and if f logically implies this then
  211. 8:22certainly we can conclude that ah
  212. 8:26a on the left hand side of the
  213. 8:28functional dependency was extraneous
  214. 8:30similar thing can be done for checking
  215. 8:33if there is
  216. 8:34an extraneous attribute on the right
  217. 8:36hand side of a dependency and in this
  218. 8:39case ah naturally what we will need to
  219. 8:41do is we will need to work out
  220. 8:45the simpler set
  221. 8:47and then check whether f is implied by
  222. 8:51that
  223. 8:51because as as you can understand
  224. 8:54that if you are
  225. 8:56if you are making the left hand
  226. 8:58if you are removing an attribute from
  227. 9:00the left hand side then you are making
  228. 9:03your precondition
  229. 9:05softer
  230. 9:06so you need to see whether that is
  231. 9:08implied by the original set and on the
  232. 9:11other hand if you are removing something
  233. 9:13on the right hand side
  234. 9:14then
  235. 9:15you are making your consequence
  236. 9:18sampler so you need to understand
  237. 9:20whether that set implies the original
  238. 9:23set
  239. 9:25so
  240. 9:26if you look into that and obviously the
  241. 9:29other directions of this implication is
  242. 9:32not necessary to be proven because that
  243. 9:34will
  244. 9:35automatically follow because in the
  245. 9:37first case when i am removing an
  246. 9:39attribute extraneous attribute from the
  247. 9:41left hand side of an
  248. 9:43ah of a functional dependency naturally
  249. 9:45the set that i get that will always
  250. 9:47imply the original set because it is
  251. 9:49always possible to add additional
  252. 9:51attributes on the left hand side and so
  253. 9:54on
  254. 9:55so here are some examples worked out so
  255. 9:58here where i show that given us at ac
  256. 10:01and a b determining c ah b is actually
  257. 10:05extraneous because as you can see if i
  258. 10:07remove ah b then i get
  259. 10:09a determining c which is originally
  260. 10:11already there in the set you can
  261. 10:13establish that by computing the ah
  262. 10:16closure of the attribute set
  263. 10:18another example where we are trying to
  264. 10:21see an
  265. 10:22extraneous attribute on the right hand
  266. 10:24side so in this example c on the right
  267. 10:26hand side of the set
  268. 10:28ah a b determining c d is extraneous
  269. 10:31because it can be inferred even after ah
  270. 10:34because a b determining c can be
  271. 10:36inferred even after deleting this ah c
  272. 10:39from the right hand side
  273. 10:41so
  274. 10:42these are using this
  275. 10:44notion we can formalize a test for
  276. 10:47ah whether an attribute is extraneous so
  277. 10:51this is the formal steps of the step are
  278. 10:54given here but i am sure you have
  279. 10:56already understood through the example
  280. 10:59so given this a canonical cover
  281. 11:01ah of a set of functional dependencies f
  282. 11:05it is denoted by fc
  283. 11:07ah will mean that it is a set which is
  284. 11:10equivalent to f which means f will
  285. 11:12logically imply all dependencies in fc
  286. 11:14and fc will logically imply all
  287. 11:16dependencies in f
  288. 11:18no functional dependency in fc will
  289. 11:20contain any extraneous attribute so all
  290. 11:24of them will be required attributes
  291. 11:27and each left hand side of the
  292. 11:29functional dependency in fc must be
  293. 11:31unique
  294. 11:32so its a minimal set of functional
  295. 11:34dependencies ah please
  296. 11:36note on on these two core points a cover
  297. 11:39is canonical if it is a minimal set and
  298. 11:42it is an irreducible set so neither you
  299. 11:44can remove any dependency nor you can
  300. 11:46remove any extraneous attribute from
  301. 11:50this dependency set
  302. 11:55so here is the algorithm so i am not
  303. 11:57going through the steps of the algorithm
  304. 11:59you can go through that and convince
  305. 12:01yourself that it indeed computes the
  306. 12:03canonical cover
  307. 12:05and practice more on that
  308. 12:08so here i have shown an example where we
  309. 12:10want to compute the canonical cover
  310. 12:13here
  311. 12:14so first since all left hand sides have
  312. 12:17to be unique so first
  313. 12:19we
  314. 12:20combine
  315. 12:22two
  316. 12:24these two into in terms of ah a
  317. 12:26determining b c so it becomes a simpler
  318. 12:28set
  319. 12:29so a determining b is removed then
  320. 12:33i
  321. 12:34would ah
  322. 12:38check
  323. 12:40for a being extraneous in a b
  324. 12:42determining c
  325. 12:43and we find that it indeed is extraneous
  326. 12:46so
  327. 12:47ah because b determining c is already
  328. 12:49there you can do the formal test in
  329. 12:51terms of the closure so the set gets
  330. 12:53even simpler i will check if c is
  331. 12:56extraneous in a determining b c
  332. 12:58i find that it indeed is
  333. 13:01and again you can use transitivity to
  334. 13:03get here
  335. 13:04or ah can use the attribute closure and
  336. 13:08finally i get that the set of the
  337. 13:11original set f
  338. 13:13is covered by a canonical set where just
  339. 13:15you have a determining b and b
  340. 13:17determining c
  341. 13:19so this set is logically implied by the
  342. 13:22original set and this set can logically
  343. 13:24imply the original set and we will often
  344. 13:27use the canonical cover for simplicity
  345. 13:30and for ease of application
  346. 13:33naturally ah this is strongly using the
  347. 13:35underlying concept of equivalence of two
  348. 13:38sets of functional dependencies f and g
  349. 13:40they are equivalent if their closures
  350. 13:43are equal or in other words if f covers
  351. 13:46g or and g covers f that is f logically
  352. 13:51implies g and g logically implies f so
  353. 13:53this table shows you a different
  354. 13:55conditions where you can conclude
  355. 13:57whether
  356. 13:58ah f and g are equivalent sets of
  357. 14:01functional dependencies so they will
  358. 14:04have to both covers have to be true for
  359. 14:06the
  360. 14:07sets to be equivalent
  361. 14:10what next what i have done is we have
  362. 14:13put a
  363. 14:15a number of practice problems for ah
  364. 14:18various kind of things that you can do
  365. 14:20with functional dependencies the first
  366. 14:22set of problems find
  367. 14:24ah in first set of problems you have to
  368. 14:26find if a given functional dependency is
  369. 14:28implied from a set of functional
  370. 14:30dependencies
  371. 14:32so there are three problems where three
  372. 14:34function
  373. 14:35sets of functional dependencies are
  374. 14:37given and you are given to check
  375. 14:40one or more functional dependencies if
  376. 14:42it is implied from that set so use
  377. 14:46the attribute closure and the algorithm
  378. 14:48that you have discussed to practice
  379. 14:49these problems and
  380. 14:52become master of that
  381. 14:54you can also check if
  382. 14:57can find candidate key using the
  383. 14:59functional dependencies so sets are
  384. 15:01given your task would be to find the
  385. 15:03candidate keys
  386. 15:06you can also use ah the algorithms to
  387. 15:10find super keys for a given set of
  388. 15:12functional dependencies so do practice
  389. 15:13these problems
  390. 15:15you can find prime and non prime
  391. 15:17attributes using functional dependencies
  392. 15:19ah prime attributes ah
  393. 15:22are attributes that belong to any
  394. 15:24candidate key not necessarily the same
  395. 15:27candidate key all attributes that belong
  396. 15:29to some candidate key you take a set of
  397. 15:32set together and you call them as a
  398. 15:35prime attribute
  399. 15:36and non prime attributes are those that
  400. 15:38do not belong to any candidate key at
  401. 15:41all so here your task is to find the
  402. 15:44prime and non prime attributes using the
  403. 15:47sets of functional dependencies given
  404. 15:50you can check for equivalence for a pair
  405. 15:53of sets of functional dependencies there
  406. 15:55are a couple of problems given on that
  407. 15:58so please ah try them out
  408. 16:01and ah for here for the different sets
  409. 16:05you have to compute the minimal cover or
  410. 16:07the irreducible set
  411. 16:09or canonical cover of the set of
  412. 16:11functional dependencies
  413. 16:13so please practice on this problem so
  414. 16:16that you become comfortable with
  415. 16:18using this algorithms for dealing easily
  416. 16:21with the functional dependencies sets of
  417. 16:24functional dependencies individual
  418. 16:25functional dependencies and so on
  419. 16:27so after ah
  420. 16:29after this week is closed and your
  421. 16:31assignments are also done then we will
  422. 16:34publish the solutions for these practice
  423. 16:36problems as well
  424. 16:38next let me um take up ah
  425. 16:42little characterization of the concept
  426. 16:44that we had introduced earlier in terms
  427. 16:46of the lossless joint decomposition
  428. 16:49so in the lossless joint decomposition
  429. 16:51the problem is ah say that you have a
  430. 16:54relational scheme
  431. 16:56r
  432. 16:57and you are trying to divide that into
  433. 16:59two relational schemes r one and r two
  434. 17:02so both r one and r two are
  435. 17:04ah having a set of ah attributes
  436. 17:07and ah r
  437. 17:09naturally has the set of attributes
  438. 17:11which is a union of the attributes of r
  439. 17:13one and r two
  440. 17:14then
  441. 17:15is it possible that if i
  442. 17:19take a relation project it on the
  443. 17:21attributes of r 1 and on the attributes
  444. 17:24of r 2 the 2 relations that we get if i
  445. 17:27take a natural join of that do i get
  446. 17:29back r
  447. 17:31if i do then i say that i have a
  448. 17:34lossless join
  449. 17:35if i do not then i have lost some
  450. 17:37information due to this projection and
  451. 17:41recomputation of the original ah
  452. 17:43relation based using the natural join
  453. 17:47the requirement this requirement of
  454. 17:50lossless join decomposition
  455. 17:53is determined if
  456. 17:55at least one of the following
  457. 17:57dependencies exist in the closure set of
  458. 18:00f
  459. 18:01which what are the this is saying that
  460. 18:04if i do r one intersection r two that is
  461. 18:07the attributes which are common you will
  462. 18:09recall that when you do natural join it
  463. 18:12is this set of attributes which take
  464. 18:14part because these set of attributes
  465. 18:16will help you compute the join between
  466. 18:19ah
  467. 18:20projection on r1 and the projection on
  468. 18:23r2
  469. 18:24so if this intersection set of
  470. 18:25attributes uniquely determines r 1
  471. 18:29or
  472. 18:30it uniquely determines r 2 that is if
  473. 18:33the intersection set of attributes is a
  474. 18:36super key
  475. 18:37either in r 1 or in r 2 or both
  476. 18:41then we say that the lossle the join
  477. 18:44will be a lossless join
  478. 18:46note that this is a sufficient condition
  479. 18:48that which means that there are there
  480. 18:50could be some instances where this
  481. 18:53property is not satisfied yet the join
  482. 18:55is lossless but we need guarantees for
  483. 18:57our design
  484. 18:58so
  485. 18:59we
  486. 19:00make use of the fact that if one of
  487. 19:03these conditions are satisfied then it
  488. 19:04is a sufficient condition to say that
  489. 19:06the joint will
  490. 19:07mass join will necessarily be lossless
  491. 19:11so here i give you a quick ah example ah
  492. 19:15to show the idea so we have a supplier
  493. 19:18relationship here which has five
  494. 19:21attributes here is an instance of that
  495. 19:24and we know that these are the
  496. 19:26dependencies that that hold ah the
  497. 19:29supplier number determines the supplier
  498. 19:31name and the supplier city and supply
  499. 19:34number and product number together
  500. 19:36determines the quantity and we decompose
  501. 19:38them in this manner we have we put a
  502. 19:41supplier relationship where we have the
  503. 19:44number name city and quantity of
  504. 19:46supplier and then we have a parts
  505. 19:48relation where we just have a product
  506. 19:50name and the quantity and then we so
  507. 19:53this is uh the projected supplier
  508. 19:55relation instance this is a projected
  509. 19:57parts relation instance and then we take
  510. 19:59a natural join to reconstruct so we are
  511. 20:01taking a natural join to reconstruct and
  512. 20:03we get this relationship
  513. 20:05now our desire was that we must get back
  514. 20:08the original relation but if you compare
  515. 20:10you will find that this is not the case
  516. 20:13here we have
  517. 20:15one tuple here and we have another tuple
  518. 20:18here i have specifically highlighted
  519. 20:19them in red
  520. 20:21which were not there in the original
  521. 20:23relation they have come in because ah
  522. 20:26when i did the join
  523. 20:28naturally the join had to be performed
  524. 20:31on
  525. 20:32this common attribute quantity
  526. 20:35and based on that ah value so nick
  527. 20:39five nick ny
  528. 20:42ah
  529. 20:44the five nick
  530. 20:46ny
  531. 20:47ah
  532. 20:49then we have ten five nick n y ten
  533. 20:52ah this entry and we have two entries of
  534. 20:56ten and
  535. 20:57ten here
  536. 20:59so
  537. 21:00the combination of this with this
  538. 21:03where the product number is 20 is
  539. 21:06actually not present in the original
  540. 21:09ah instance of the relation and that is
  541. 21:12what shows up here a similar one exist
  542. 21:15here so we get extra tuples
  543. 21:18and and mind you though though we are
  544. 21:20actually getting extra tuple we say that
  545. 21:22this join is lossy because if you get
  546. 21:25extra tuple then you are losing
  547. 21:27information you are losing correctness
  548. 21:29so being loss is actually losing
  549. 21:30correctness
  550. 21:32so
  551. 21:32ah
  552. 21:34even though
  553. 21:35we have more tuples we will we say that
  554. 21:38this is a lossy joint and you can now go
  555. 21:41back and analyze the common attribute q
  556. 21:43t y
  557. 21:44is not a super key either in this or in
  558. 21:47this so
  559. 21:48r one intersection r two implying
  560. 21:51r one or implying r two is does not hold
  561. 21:56so it does not and in addition it also
  562. 21:59does not preserve this functional
  563. 22:00dependency because these are not no more
  564. 22:03determined
  565. 22:06now let us see is it ah so we we saw a
  566. 22:10case where the join
  567. 22:12the decomposition that we did and then
  568. 22:14the subsequent join that we performed
  569. 22:17did not prove to be a lossless join we
  570. 22:20lost information
  571. 22:22so let us take a take a look as to can
  572. 22:25we ah
  573. 22:27actually do a decomposition which will
  574. 22:30be lossless where we will not lose
  575. 22:31information
  576. 22:41so we take the same example
  577. 22:44the supplier but the decomposition the
  578. 22:47same set of at
  579. 22:48dependencies also but the decomposition
  580. 22:51is different now we have
  581. 22:53name number name and city in one
  582. 22:56ah supplier relation and
  583. 22:58supplier name
  584. 23:00number product number and quantity in
  585. 23:02the other parts relation
  586. 23:05and then we again go back and perform
  587. 23:07the join
  588. 23:08now we find that from the original
  589. 23:11relation this was the original relation
  590. 23:13this is the projected supplier relation
  591. 23:15these are projected parts relation and
  592. 23:18this is the natural join
  593. 23:20of
  594. 23:20these two relations so this is the
  595. 23:23natural join of these two relations and
  596. 23:25we find that they exactly match with the
  597. 23:28original relation so we have not lost
  598. 23:31any information we get it back so we say
  599. 23:34that the join is lossless
  600. 23:36and the reason we could guarantee that
  601. 23:38is because if you look into the set of
  602. 23:41functional dependencies you will find
  603. 23:44that
  604. 23:45s number the supplier number
  605. 23:47is a key in the supplier relationship
  606. 23:52because it functionally determines s
  607. 23:53name as well as s c t so r one
  608. 23:56intersection r two
  609. 23:58functionally determining r one is true
  610. 24:00here and therefore it actually ah gives
  611. 24:04you a lossless join it also preserves
  612. 24:07all the dependencies because if you look
  613. 24:10into these dependencies you can
  614. 24:12you can check for this dependency in
  615. 24:14this relation you can check for this
  616. 24:16dependency also in this relation
  617. 24:18and you can check for this dependency in
  618. 24:20also
  619. 24:21in the parts relation which is something
  620. 24:23which we were not able to do the in the
  621. 24:26last decomposition that we have so
  622. 24:28naturally this is a type of
  623. 24:30decomposition that we will prefer
  624. 24:34so
  625. 24:35here we have
  626. 24:37i have given some more examples which
  627. 24:39you can practice and i show that given a
  628. 24:42very simple schema having three
  629. 24:44attributes and two dependencies one
  630. 24:47decomposition into
  631. 24:49a b and b c is
  632. 24:52lossless joint decomposition whereas the
  633. 24:54other one a b and a c is a loss
  634. 24:56decomposition
  635. 24:59i have
  636. 25:00given a number of practice problems on
  637. 25:02nausea joint so that you can practice
  638. 25:05and become master of
  639. 25:06these kind of algorithms
  640. 25:10finally let me ah
  641. 25:11quickly go over the dependency
  642. 25:13preservation
  643. 25:14concept the dependency preservation is
  644. 25:19if you have a relation which you have
  645. 25:21decomposed
  646. 25:23into n different relations
  647. 25:26so if you decompose a relation into into
  648. 25:28a number of
  649. 25:30relations then naturally
  650. 25:32ah all functional dependencies you
  651. 25:33cannot check on all the relations
  652. 25:36because ah a dependency may involve
  653. 25:39attributes all of which may not be
  654. 25:41present in a particular ah
  655. 25:45decomposed relation that you have
  656. 25:47ah it may be distributed amongst ah
  657. 25:50different so
  658. 25:51when you do this decomposition
  659. 25:53you get for every relation you get a
  660. 25:56new set of a subset of functional
  661. 25:59dependencies so r i the decomposed
  662. 26:01relation
  663. 26:02ah r i the ith relation will have a
  664. 26:07hm
  665. 26:09set of dependencies f i which is a
  666. 26:12subset of the original set f
  667. 26:15and ah involves only the attributes
  668. 26:18which are exist in r i so
  669. 26:21ah the decomposition will be
  670. 26:23said to be dependency preserving if i
  671. 26:25can take the union of
  672. 26:28all these functional dependencies what
  673. 26:30is projected on r 1 on r 2 and r n f 1 f
  674. 26:332 f n if we can take union of
  675. 26:36and if we take f they must be equivalent
  676. 26:39sets so which we we know the
  677. 26:42we we know the requirement so
  678. 26:45equivalence mean that they will their
  679. 26:46covers will have to be equal if it is
  680. 26:49not then
  681. 26:50some there will be at least one
  682. 26:52dependency which you will not be able to
  683. 26:54check in any one of the projected
  684. 26:56relations and to be able to check that
  685. 26:58you will have to compute
  686. 27:00the natural join
  687. 27:02ah and that is as we know is a very
  688. 27:04expensive process and we would not be
  689. 27:06able to do that on a regular basis
  690. 27:12so here i have written down the
  691. 27:15algorithm to test if a decomposition
  692. 27:19ah actually preserve the dependency or
  693. 27:22not so i will not go through the steps i
  694. 27:25will leave that for you to understand
  695. 27:27but what i will do i will just ah show
  696. 27:30you a simple set of worked out example
  697. 27:33and
  698. 27:34reasoned on that
  699. 27:36so i show you two different methods of
  700. 27:39ah doing this so
  701. 27:41here we have a set of attributes given
  702. 27:44the
  703. 27:46dependencies that work in that and a
  704. 27:48particular decomposition
  705. 27:50so given the set of attributes and the
  706. 27:53decomposition
  707. 27:55if we project now if we project the set
  708. 27:58of functional dependencies and these are
  709. 27:59the sets that we get so on r one we have
  710. 28:03two dependencies on r two we have three
  711. 28:05dependence one dependency and or r three
  712. 28:07we have
  713. 28:09one dependency again
  714. 28:10so if we now think about ah the union of
  715. 28:14these and the closure for that then we
  716. 28:16can see that a
  717. 28:19these four dependencies which occur here
  718. 28:22and therefore i have struck them off in
  719. 28:25this set
  720. 28:26these four dependencies can be checked
  721. 28:28directly on the
  722. 28:30projected
  723. 28:31relations
  724. 28:33so that leaves us with three
  725. 28:35dependencies in the original set which
  726. 28:38cannot be checked on any one of r one r
  727. 28:41two or r three for example if you
  728. 28:43consider ah b c determining e
  729. 28:46then ah b exist on r one
  730. 28:50and c also exist on r one but e is not
  731. 28:52there so you cannot check the dependency
  732. 28:54on r one you cannot check that on r two
  733. 28:57because c and e do not exist and you
  734. 28:59cannot check them on r three check it on
  735. 29:01r three because none of them actually
  736. 29:03exist
  737. 29:04so what we will need for the dependency
  738. 29:07preservation to hold is
  739. 29:09the dependencies which are already
  740. 29:12existing the four dependencies that are
  741. 29:14struck off if they collectively
  742. 29:18can logically imply these dependencies
  743. 29:22so that they can be checked then
  744. 29:24we will be able to say that this is
  745. 29:27dependency preserving so what you do is
  746. 29:29something very very simple you ah you
  747. 29:31want to say you want to check whether
  748. 29:34this is preserved so you start with the
  749. 29:36left hand side and compute the closure
  750. 29:38the only difference you compute the
  751. 29:39closure first
  752. 29:41with the set of functional dependencies
  753. 29:43projected on r one that is f one
  754. 29:46the set closure set that you get you
  755. 29:48take that and compute its closure with
  756. 29:51respect to the second set of functional
  757. 29:53dependencies f two
  758. 29:56the closure that you get you take that
  759. 29:57and you
  760. 29:59compute the closure with such respect to
  761. 30:01the third set of functional dependencies
  762. 30:03which is on r three and that is your
  763. 30:06final closure set so this closure set
  764. 30:09includes the right hand side attribute e
  765. 30:12so we can conclude that bc indeed ah
  766. 30:15functionally will determine e and that
  767. 30:18relationship will be preserved because
  768. 30:20we have starting from bc we have seen
  769. 30:23that in every projected relation what
  770. 30:26all implied functional dependencies that
  771. 30:28can be checked which is what the meaning
  772. 30:30of the closer set of attributes are and
  773. 30:33since ah that set eventually has e we
  774. 30:37will know that this
  775. 30:38can be this will be preserved this set
  776. 30:41also has f so the other one will also be
  777. 30:44preserved so this is preserved this is
  778. 30:45preserved to check whether this
  779. 30:48dependency is preserved we need to again
  780. 30:50repeat the process and find whether e f
  781. 30:54ah belongs to the final closure set
  782. 30:56which it does and therefore we conclude
  783. 30:59that this decomposition is dependency
  784. 31:02preserving with the same example i will
  785. 31:05just ah show you a little different way
  786. 31:07of
  787. 31:09doing the same exercise i have not
  788. 31:11written down the
  789. 31:12algorithm for this in long hand but the
  790. 31:14example should
  791. 31:17be quite illustrative so we are what you
  792. 31:20do when you project you check if the if
  793. 31:23some dependency has ah multiple
  794. 31:26attributes on the
  795. 31:28left hand on the right hand side then
  796. 31:30you write them in a separately
  797. 31:33decomposed manner so it implies
  798. 31:36ah determines b c d
  799. 31:38is written in terms of three
  800. 31:40dependencies a implies b b implies c and
  801. 31:42c implies d
  802. 31:44so you make sure that all dependencies
  803. 31:46are written in a form where the right
  804. 31:47hand side has a single attribute
  805. 31:51then you compute what is known as the
  806. 31:54reverse functional dependencies that is
  807. 31:56you take the right hand side and compute
  808. 32:00whether
  809. 32:00the right hand side can imply the left
  810. 32:03hand side
  811. 32:04so
  812. 32:05i will just ah by show you one so in
  813. 32:08case the right hand side here is b
  814. 32:10so you have a b on the right hand side
  815. 32:12so you compute the closure with respect
  816. 32:14to f the original set not not the
  817. 32:16projected set of
  818. 32:18and you get b f
  819. 32:20so you know that
  820. 32:22this
  821. 32:24this inverse this reverse functional
  822. 32:26dependency which is ah
  823. 32:29b
  824. 32:30functionally determines a which is the
  825. 32:32reverse dependency cannot be inferred
  826. 32:36and you do this for each of the right
  827. 32:38hand side single attribute and check if
  828. 32:42ah sum
  829. 32:43um if
  830. 32:44the reverse dependencies can be inferred
  831. 32:46or not
  832. 32:47ah the interesting case occurs here
  833. 32:50where you if you try to do the closure
  834. 32:52of a you actually find that a determines
  835. 32:55bc
  836. 32:56which is a reverse of
  837. 32:58this functional dependency can be
  838. 33:00inferred but you do not consider that as
  839. 33:03a violation because it is you already
  840. 33:06have
  841. 33:07a determining b and a determining c so
  842. 33:10that logically implies that a determines
  843. 33:13b c so it is not
  844. 33:15a new
  845. 33:16violation that is getting imposed so
  846. 33:20with this your test for reverse
  847. 33:22functional dependencies is passed
  848. 33:24and then you finally check for whether
  849. 33:27the three dependencies which are not
  850. 33:29part of the projected set of
  851. 33:30dependencies you take the closure of the
  852. 33:33left hand side
  853. 33:34with respect to in this case the again
  854. 33:37the original set of functional
  855. 33:38dependencies not the projected one and
  856. 33:40check if the right hand side belongs
  857. 33:42there if they do then combined with
  858. 33:44these two strategies you say that the
  859. 33:46set of functional dependencies are
  860. 33:49preserved under this decomposition so ah
  861. 33:53this is the process to follow you can
  862. 33:55follow any one of the two approaches to
  863. 33:58solve
  864. 33:59ah and i have given some practice
  865. 34:02problems on dependency preservation
  866. 34:04which you should practice on
  867. 34:06to summarize we have studied the
  868. 34:08algorithms for properties of functional
  869. 34:11dependencies and we have understood the
  870. 34:13characterization and determination
  871. 34:16algorithm for lossless joint
  872. 34:18decomposition and for dependency
  873. 34:21preservation in a decomposition in the
  874. 34:24coming module we will make use of these
  875. 34:26and discuss about how to improve these
  876. 34:29designs relate of relational schemas
  877. 34:31through the use of different normal
  878. 34:33forms

About this transcript

This page contains the full transcript of Relational Database Design (Contd.) - 2 by Data Base Management System - IITKGP, generated from the public captions YouTube serves with the video. The transcript has 5,075 words across 878 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.