YouTube2Text

Relational Database Design (Contd.)-1 — Transcript

by Data Base Management System - IITKGP · 4,407 words · 817 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:15welcome to the
  3. 0:17module 17 of database management systems
  4. 0:21ah from the last module we are
  5. 0:23discussing relational database design so
  6. 0:25this is second in the series of ah five
  7. 0:28modules which will discuss this
  8. 0:32we have already seen ah
  9. 0:36basic features of good relational design
  10. 0:38we have studied about first normal form
  11. 0:40atomic domains and got introduced to
  12. 0:42functional dependencies so
  13. 0:44we will develop further on that
  14. 0:46to see how decompositions into good
  15. 0:48design can be done by making use of the
  16. 0:51notion of functional dependencies and
  17. 0:53we will more formally introduce the
  18. 0:56theory of functional dependencies
  19. 0:58so that is all that we discuss in this
  20. 1:01so decomposition using functional
  21. 1:03dependencies is the first thing that we
  22. 1:05look at and the first normal form of
  23. 1:08relations which
  24. 1:10was studied we look at is voice code
  25. 1:12normal form so normal forms are ah kind
  26. 1:15of set of properties which is satisfied
  27. 1:19by a relational schema and if they are
  28. 1:21satisfied then we have certain
  29. 1:23guarantees in terms of what can or
  30. 1:26cannot happen in that relational schema
  31. 1:29design
  32. 1:30so voice code is a
  33. 1:32simplest kind of beyond 1nf is a
  34. 1:36simplest kind of normal form and a
  35. 1:38relational schema is said to be in voice
  36. 1:40code normal form if with respect to a
  37. 1:43set of functional dependencies
  38. 1:46all functional dependencies in the
  39. 1:48closure so in respect of f we compute f
  40. 1:51plus which is a closure
  41. 1:54and if i have a dependency
  42. 1:57alpha determines beta
  43. 1:59then naturally
  44. 2:01alpha will have to be a subset of r beta
  45. 2:03will have to be a subset of r but what
  46. 2:05is important is every functional
  47. 2:07dependency in the closure set must
  48. 2:09either be trivial
  49. 2:11that is right hand side is a
  50. 2:13super set of the
  51. 2:15right hand side is a subset of the left
  52. 2:17hand side
  53. 2:19or
  54. 2:20the
  55. 2:21left hand side
  56. 2:23set alpha must be super key
  57. 2:26so only those kind of ah functional
  58. 2:28dependencies are possible no other
  59. 2:30functional dependencies are possible if
  60. 2:32that is satisfied by the relational
  61. 2:34schema are then it is said to be in the
  62. 2:37voice code normal form
  63. 2:39so
  64. 2:40you can if we look at
  65. 2:43ins department
  66. 2:45schema of the combined relations we saw
  67. 2:47last time
  68. 2:48then we will know that ah certainly this
  69. 2:50is not in voice code normal form because
  70. 2:53ah this functional dependency holds
  71. 2:56in this schema
  72. 2:58where it is neither a
  73. 3:02a trivial dependency and nor department
  74. 3:05name is a super key
  75. 3:07so this is not in bcnf
  76. 3:11so if a relational scheme is not in bcnf
  77. 3:14then the question naturally is can i
  78. 3:16make it into bcnf so then that process
  79. 3:18is a process of decomposition so what
  80. 3:21you do you
  81. 3:22divide the set of attributes into two or
  82. 3:25more at
  83. 3:26sets of attributes so here ah let us say
  84. 3:30that
  85. 3:31we have a relational schema which has a
  86. 3:33non trivial dependency alpha determines
  87. 3:36beta where alpha is not a super key so
  88. 3:39with respect to this functional
  89. 3:41dependency the relational schema is not
  90. 3:43in bcnf then we can decompose r by
  91. 3:48two
  92. 3:48sets one is alpha union beta take the
  93. 3:51union of these two attribute sets
  94. 3:54and
  95. 3:55remove
  96. 3:57beta minus alpha from r take the
  97. 4:00difference of beta minus alpha and
  98. 4:03remove that from r
  99. 4:05the resulting
  100. 4:06pair of relations relational schemas
  101. 4:09will be in voice code normal form with
  102. 4:12respect to this particular functional
  103. 4:14dependency
  104. 4:16so
  105. 4:17let us
  106. 4:19see an example so if alpha is department
  107. 4:21name
  108. 4:22beta is a pair of attribute building and
  109. 4:24budget we have department name
  110. 4:26functionally determines building budget
  111. 4:28so alpha determines beta and we have
  112. 4:30already seen that
  113. 4:32it does not ah hold
  114. 4:34ah it is not satisfied by the ins
  115. 4:37department so you replace it by taking
  116. 4:40alpha union beta so alpha union beta is
  117. 4:43this
  118. 4:44ah set of relational ah
  119. 4:46this relational schema
  120. 4:48and you do r minus ah beta
  121. 4:51ah r minus
  122. 4:53difference of beta minus alpha beta
  123. 4:55minus alpha naturally if this is beta
  124. 4:57and alpha then beta minus ah alpha
  125. 5:00is
  126. 5:01necessarily building budget
  127. 5:04because
  128. 5:05the department does not occur in beta so
  129. 5:07this set is building budget and if i
  130. 5:09remove it from r which means that
  131. 5:12id name salary and department name are
  132. 5:15retained but building and budget gets
  133. 5:17removed
  134. 5:18so i get another
  135. 5:20relational schema which has these four
  136. 5:22names and it holds the
  137. 5:26ah functional dependency id determining
  138. 5:28so now if i look into this schema r one
  139. 5:32and this schema r two
  140. 5:34there are different dependencies that
  141. 5:36hold on r one
  142. 5:38and with respect to that dependency r
  143. 5:40one is in bcnf because department name
  144. 5:42is the super key is a key primary key
  145. 5:46and with respect to this dependency r
  146. 5:49two is in bcnf because id is the key
  147. 5:53so i can see that the original combined
  148. 5:56relational schema was not in bcnf with
  149. 5:59respect to this functional dependency
  150. 6:01but
  151. 6:02when i do this decomposition i get two
  152. 6:05schemas which are each in
  153. 6:08pc and f normal form so this is the
  154. 6:10basic process and we will see ah
  155. 6:13depending on the normal form and
  156. 6:14different notions of functional
  157. 6:16dependencies we will see how these
  158. 6:19conversions can be done but this is a
  159. 6:21basic approach of converting a schema
  160. 6:24into a normal form
  161. 6:26now
  162. 6:28ah
  163. 6:29the question is if
  164. 6:31the constraints including the functional
  165. 6:33dependencies
  166. 6:34if we look at then functional
  167. 6:36dependencies will have to be checked on
  168. 6:37different instance
  169. 6:39now in general it is difficult to check
  170. 6:42a functional dependency alpha
  171. 6:44determining beta
  172. 6:46if the attributes alpha
  173. 6:49and
  174. 6:50the attributes of beta or the attributes
  175. 6:52of beta are distributed between multiple
  176. 6:54relations because naturally how do i
  177. 6:56check if they are true if how do i check
  178. 6:59that two tuples which match on alpha is
  179. 7:01indeed matching on beta unless i perform
  180. 7:04a costly join operation
  181. 7:06so there is ah
  182. 7:08[Music]
  183. 7:10the objective is to be able to come to
  184. 7:13designs where
  185. 7:15it is sufficient to test only those
  186. 7:17dependencies on individual relations
  187. 7:20of the decomposition
  188. 7:22and with that i must be able to ensure
  189. 7:26that all functional dependencies hold
  190. 7:28so its a very interesting situation so
  191. 7:31we are saying that we will decompose get
  192. 7:33into a number of relational schema
  193. 7:36every schema will have a number of
  194. 7:38dependencies functional dependencies
  195. 7:40so and those functional dependencies if
  196. 7:44they
  197. 7:45involve only the attributes of that
  198. 7:48relational schema they can be tested
  199. 7:50very easily
  200. 7:51and if these functional dependencies
  201. 7:53together mean ensure
  202. 7:56that all functional dependencies hold
  203. 7:58that is
  204. 7:59if the closure of this set of functional
  205. 8:01dependencies is same as the
  206. 8:04closure of the earlier set the original
  207. 8:06set
  208. 8:07then we say that the decomposition that
  209. 8:10we have achieved is dependency
  210. 8:13preserving
  211. 8:15because
  212. 8:16ah i can actually effectively compute
  213. 8:20this is dependency preserving because i
  214. 8:23can effectively compute whether every
  215. 8:26dependency
  216. 8:27is
  217. 8:28satisfied
  218. 8:30by checking on every individual relation
  219. 8:34but the unfortunate part of the reality
  220. 8:37is that it is not always possible
  221. 8:40to achieve a voice code normal form
  222. 8:43decomposition
  223. 8:45which also preserves the dependencies
  224. 8:48so
  225. 8:49if there are in some cases will be able
  226. 8:51to do like the example we saw
  227. 8:53ah just now ah the instructor and
  228. 8:55department
  229. 8:57but
  230. 8:57it is not always possible so we usually
  231. 9:01need another weaker form
  232. 9:03normal form which is known as a third
  233. 9:06normal form
  234. 9:07and
  235. 9:08we will subsequently look into those
  236. 9:11a third normal form
  237. 9:14is again a relational schema is there
  238. 9:17and
  239. 9:18for all
  240. 9:21attribute for all dependencies that
  241. 9:23belong to the closure of the functional
  242. 9:25dependencies this following conditions
  243. 9:28must hold
  244. 9:30either alpha determines beta is trivial
  245. 9:32which is a condition which b c n f at
  246. 9:35or alpha is a super key of r which is
  247. 9:38also a condition that be c n f hat
  248. 9:40or
  249. 9:42each attribute in beta minus alpha
  250. 9:46that is right hand side difference the
  251. 9:48left hand side is contained in a
  252. 9:50candidate key for r
  253. 9:53its not very obvious as to why we need
  254. 9:56that that will unfold slowly this is the
  255. 9:58condition we did not have in bcnf
  256. 10:01so naturally you can see that based on
  257. 10:03the first two condition you can always
  258. 10:05say
  259. 10:06that if a relational schema is in bcnf
  260. 10:09it necessarily is in three n f but not
  261. 10:12the review
  262. 10:13there could be some schema which is in
  263. 10:15three n f because of the third condition
  264. 10:18where there exist a functional
  265. 10:19dependency so that beta minus alpha
  266. 10:22is contained in a candidate key for r
  267. 10:25but it is not in the bcnf form
  268. 10:28and
  269. 10:30also you can you can
  270. 10:32ah
  271. 10:34note that the attributes of
  272. 10:37ah
  273. 10:38that are contained in beta minus alpha
  274. 10:41must be in some candidate key not
  275. 10:43necessarily in the same candidate key if
  276. 10:46they exist in some candidate key then
  277. 10:48itself the
  278. 10:49ah three nf condition will get satisfied
  279. 10:53so if a relation is in bcnf it is in
  280. 10:55three nf we have already seen that
  281. 10:59so third condition minimally relaxes
  282. 11:01bcnf to ensure
  283. 11:03that we have a dependency preservation
  284. 11:06we will see this more later so i am just
  285. 11:07introducing the concept of a relaxed
  286. 11:11normal form here
  287. 11:13so what is the goal of this
  288. 11:14normalization
  289. 11:16is if ah to
  290. 11:18summarize let r be a relational scheme f
  291. 11:21is a set of functional dependencies
  292. 11:23we need to decide whether the relational
  293. 11:26scheme r
  294. 11:27is in a good form
  295. 11:30which means that
  296. 11:32it is it should not have unnecessary
  297. 11:35redundancy it should be possible to
  298. 11:39acquire information by doing lossless
  299. 11:42join
  300. 11:43so
  301. 11:44in case it is not in good form we can
  302. 11:47convert it by decomposition into n
  303. 11:50relational schema such that each schema
  304. 11:52is in good form
  305. 11:54the decomposition has a lossless join so
  306. 11:56that i can get back the original
  307. 11:58relation from this
  308. 12:00and preferably the decomposition should
  309. 12:03preserve
  310. 12:04the dependencies
  311. 12:05so that is what we will target
  312. 12:08henceforth so when we do that let us
  313. 12:11quickly evaluate as to ah we have seen b
  314. 12:14c n f so how good really ah b c n f is
  315. 12:19ah
  316. 12:21so
  317. 12:22if i have something in bcnf i am should
  318. 12:24i really be very happy always
  319. 12:27so let us look at a relational schema
  320. 12:29this is
  321. 12:30an
  322. 12:31information relating the id of a person
  323. 12:34the name of the child and the phone
  324. 12:36number
  325. 12:37and
  326. 12:39naturally the person the instructor may
  327. 12:41have more than one phone and may have
  328. 12:43multiple children so this is a possible
  329. 12:46instance
  330. 12:47as you can see though
  331. 12:48all of these belong to the same
  332. 12:50instructor he has naturally you can see
  333. 12:52that two children and there are ah this
  334. 12:55is here this is here so
  335. 12:58ah this is here this is here so there
  336. 13:00are
  337. 13:00two different phone numbers so naturally
  338. 13:02you have four possible combinations that
  339. 13:04you need to look at
  340. 13:07so
  341. 13:10now there is no non trivial functional
  342. 13:12dependency in this relation
  343. 13:15so since there is no non trivial
  344. 13:17functional dependency this relation
  345. 13:18naturally is in bc enough
  346. 13:20because that is the existence of non
  347. 13:23trivial dependencies what makes a schema
  348. 13:27not
  349. 13:28conform to the bcnf form so there is no
  350. 13:30such
  351. 13:32so this is in bcnf form
  352. 13:35and
  353. 13:36now if you look at
  354. 13:38and
  355. 13:39but what did we see the key thing that
  356. 13:41we saw if we just go back the key thing
  357. 13:44that we saw that is
  358. 13:45ample
  359. 13:46redundancy of data the same data is
  360. 13:48entered multiple times so the
  361. 13:51consequence of that could be insertion
  362. 13:53anomaly if we want to add a phone number
  363. 13:56to the same
  364. 13:57instructor then we need to add two tuple
  365. 14:01because the instructor also has two
  366. 14:04children if the instructor three
  367. 14:06children will need to add three
  368. 14:08and unless this is maintained always
  369. 14:10then will have difficulty so the
  370. 14:12redundancy consequences anomaly that we
  371. 14:15are getting into
  372. 14:17so it could be better to decompose this
  373. 14:20to say that i i make this orthogonal i
  374. 14:23keep the child information with the id
  375. 14:26and i keep the phone number information
  376. 14:28the id separately so if i
  377. 14:31do that then i can decompose it in this
  378. 14:33manner and if i decompose that this i
  379. 14:36have just shown that if you are dividing
  380. 14:39that table in two parts so naturally
  381. 14:41these are not required
  382. 14:43ah
  383. 14:45neither are these required so these are
  384. 14:47the entries that i get and you can
  385. 14:50convince yourself that you can actually
  386. 14:52do a lossless joint to get back the
  387. 14:53information so bcnf not not necessarily
  388. 14:57give you good designs and
  389. 14:59we will see later on that there are
  390. 15:01other normal forms which can be used to
  391. 15:03improve on the bcnf
  392. 15:07now
  393. 15:09let us for for formally getting into how
  394. 15:12do we
  395. 15:13convert decomposer relation into third
  396. 15:15normal form and how do we assess that we
  397. 15:17need to understand more of the
  398. 15:19functional dependencies
  399. 15:21so we will consider now a little bit of
  400. 15:24formal theory on them and then develop
  401. 15:26algorithms that can generate lossless
  402. 15:29joint decomposition into bcnf and 3nf
  403. 15:33and we will
  404. 15:35also create algorithm to test
  405. 15:37if
  406. 15:38decomposition preserves the dependency
  407. 15:42so
  408. 15:43just quickly to recap we have already
  409. 15:45introduced a closer set of a functional
  410. 15:47dependencies it is all dependencies that
  411. 15:49are logically implied by it now the
  412. 15:51question certainly is how do i given a
  413. 15:53set how do i
  414. 15:55compute this closure set
  415. 15:58so to do this we
  416. 16:00make use of
  417. 16:02three rules
  418. 16:03known by armstrong's axiom named after
  419. 16:06the person who first observed them
  420. 16:08so the first rule is reflexivity which
  421. 16:11says that
  422. 16:12if beta is a subset of alpha
  423. 16:15then alpha determines beta always alpha
  424. 16:18functionally determines beta
  425. 16:21so this is basically reflexivity you can
  426. 16:23see is a different way of saying
  427. 16:26ah specifying about trivial dependencies
  428. 16:29next comes the important thing
  429. 16:31augmentation which says that if alpha
  430. 16:33determines beta then
  431. 16:35gamma alpha where gamma is some set of
  432. 16:38attributes in r then gamma alpha will
  433. 16:40functionally determine gamma beta
  434. 16:43which is very easy to see because alpha
  435. 16:45determines beta means two tuples who
  436. 16:48match on alpha will necessarily match on
  437. 16:49beta
  438. 16:51now if that happens then whatever is
  439. 16:52gamma if two triples match on gamma and
  440. 16:55alpha
  441. 16:56then certainly they will match on gamma
  442. 16:57and beta
  443. 16:59because alpha determines beta tells me
  444. 17:01that they will match on beta and gamma
  445. 17:02is the same set of attributes so
  446. 17:04augmentation also is easy
  447. 17:07then we have transitivity which we
  448. 17:09earlier saw also if alpha determines
  449. 17:11beta and beta determines gamma then
  450. 17:13obviously alpha determines gamma so
  451. 17:15these are the foundational rules
  452. 17:17observed
  453. 17:18which can be made use to compute the
  454. 17:21closure of the set of functional
  455. 17:23dependencies
  456. 17:24now these rules as i say this is more
  457. 17:27for
  458. 17:28you know
  459. 17:29understanding the theory better is these
  460. 17:31rules are sound as well as complete
  461. 17:34soundness mean that
  462. 17:36if i use this rules repeatedly in a set
  463. 17:39of dependencies then it generates
  464. 17:42functional dependencies all of which
  465. 17:44actually hold so it will never generate
  466. 17:46a functional dependency which is not
  467. 17:48correct which will not hold
  468. 17:50and the second it is complete
  469. 17:52which means that if i keep on using
  470. 17:55these
  471. 17:56rules then all functional dependencies
  472. 17:59that can at all hold will eventually get
  473. 18:02generated so that is a very strong
  474. 18:04result and that is what leads to
  475. 18:06ah the
  476. 18:08say the following example
  477. 18:10so where we are trying to compute the
  478. 18:13functional
  479. 18:14the closure of the function set of
  480. 18:16functional dependencies here so there
  481. 18:18are 6 attributes in the set
  482. 18:20there are 6 different
  483. 18:22functional dependencies
  484. 18:24and
  485. 18:26we
  486. 18:27identify some members of the closure for
  487. 18:29example ah we can see that ah a
  488. 18:32functionally determines b and b
  489. 18:34functionally determines h so
  490. 18:36transitivity clearly
  491. 18:39show that a will function determine h
  492. 18:42very clear so
  493. 18:43in the closure that must be there
  494. 18:45similarly ah i we can see that ah
  495. 18:51a functionally determines c
  496. 18:54now if we augment it
  497. 18:57with g
  498. 18:59if we augment it with g that is put g on
  499. 19:01both sides then
  500. 19:02a g functionally determine c g
  501. 19:05and we know that ah c g functionally
  502. 19:08determines i
  503. 19:09so if we combine these two
  504. 19:12by transitivity then we can get a new
  505. 19:15functional dependency which says a z
  506. 19:18function determines i
  507. 19:20so in this manner you can do the next
  508. 19:23one also and you can try to infer
  509. 19:25several other functional dependencies
  510. 19:27that can be inferred by different
  511. 19:31applications of the armstrong's axioms
  512. 19:33the three rules in any multiple
  513. 19:35different ways
  514. 19:38so to get the closure what we need to do
  515. 19:40is now very simple
  516. 19:42is certainly we will have a repetitive
  517. 19:45algorithm to get the closure
  518. 19:47the first
  519. 19:48the algorithm will start with
  520. 19:50the set of functional dependencies that
  521. 19:53we have
  522. 19:54so the closure must include the given
  523. 19:56set of functional dependencies so f plus
  524. 19:58must have f so let us start with
  525. 20:00initial value of f plus as f
  526. 20:03then for every functional dependency is
  527. 20:05f plus this is what we keep on repeating
  528. 20:07look at the outer loop
  529. 20:08every functional dependency that we have
  530. 20:10f plus now we will apply reflexivity and
  531. 20:13augmentation
  532. 20:15and add the resulting functional
  533. 20:17dependency in f plus
  534. 20:19it is possible that the same functional
  535. 20:21dependency gets
  536. 20:22generated and added multiple times does
  537. 20:24not matter if plus is a set it will
  538. 20:27naturally eliminate duplicates
  539. 20:30then for each pair of functional
  540. 20:32dependencies because
  541. 20:34reflexivity and augmentation applies to
  542. 20:37one functional dependency only but
  543. 20:39transitivity applies to two functional
  544. 20:41dependencies so for every pair of
  545. 20:43functional dependencies we check whether
  546. 20:45they can be combined by transitivity if
  547. 20:47they do
  548. 20:48then the transitive closure of that the
  549. 20:50transitive ah
  550. 20:53functional dependency that arise out of
  551. 20:55that is also added to f plus
  552. 20:58and mind you the more and more
  553. 21:00functional dependencies you add
  554. 21:02there are more and more opportunities to
  555. 21:04apply the armstrong's axiom rules and
  556. 21:07newer newer functional dependencies will
  557. 21:09continue to get added but eventually you
  558. 21:12reach a point where f plus does not
  559. 21:15change any further
  560. 21:16and when we when
  561. 21:18that is achieved we know that the
  562. 21:20functional
  563. 21:22the closure of the functional
  564. 21:23dependencies have been obtained and that
  565. 21:25is our final set
  566. 21:33we can also observe that ah based on the
  567. 21:37rules of ah armstrong the armstrong's
  568. 21:40axioms we can also generate lot of
  569. 21:43derived rules some of those are shown
  570. 21:46here
  571. 21:47for example if
  572. 21:48a determines if alpha determines beta if
  573. 21:51alpha determines beta holds
  574. 21:53and if alpha determines gamma that also
  575. 21:56holds then alpha determines beta and
  576. 21:58gamma together this is called the union
  577. 22:00set so if there are two functional
  578. 22:02dependencies which are the same
  579. 22:04left hand side
  580. 22:06set of attributes
  581. 22:08then we can take the union of their
  582. 22:10right hand side attributes and that
  583. 22:12functional dependency will hold
  584. 22:14obviously its trivial to prove this
  585. 22:18if alpha determines beta gamma then
  586. 22:21alpha determines beta holds and alpha
  587. 22:24determines gamma holes this is called
  588. 22:26decomposition so kind of the other side
  589. 22:29of the union which also is trivial
  590. 22:30because alpha data means beta gamma says
  591. 22:32if two tuples match on alpha they match
  592. 22:34on beta as well as gamma attributes so
  593. 22:38obviously you take the first part you
  594. 22:39get alpha determines beta you take the
  595. 22:41second part of the observation you get
  596. 22:43alpha determines gamma so that is a
  597. 22:45composition rule
  598. 22:47the third is interesting its called the
  599. 22:49pseudo transitivity which says that
  600. 22:51alpha determines beta
  601. 22:55if that holds and gamma beta determines
  602. 22:58delta if that holds then alpha gamma
  603. 23:00will determine delta which is not
  604. 23:03difficult to ah
  605. 23:04to
  606. 23:05get because if this holds then i can
  607. 23:09augment gamma on both sides i get beta
  608. 23:13gamma
  609. 23:14and
  610. 23:15then i have given
  611. 23:17ah
  612. 23:18beta gamma determines delta so if i
  613. 23:21combine these two
  614. 23:23in terms of transitivity i get
  615. 23:27alpha gamma determining delta so this is
  616. 23:29called pseudo transitivity because here
  617. 23:32you are adding another attribute in the
  618. 23:34transitivity so often times it becomes
  619. 23:36easier to make use of these additional
  620. 23:39rules to quickly get to the closer set
  621. 23:44so
  622. 23:45given a set of attributes we also
  623. 23:47compute
  624. 23:49the closure of a set of attributes
  625. 23:51this is the second
  626. 23:52concept we have
  627. 23:54seen how to given the set of functional
  628. 23:56dependencies how to compute the closure
  629. 23:58of the functional dependencies
  630. 24:01now we are given a set of attributes and
  631. 24:04we want to define the closure
  632. 24:06of the set of function of this set of
  633. 24:08attributes under the set of functional
  634. 24:11dependencies
  635. 24:13and as
  636. 24:14the closure of functional dependencies f
  637. 24:17is denoted by f plus
  638. 24:20the closure of a set of attributes alpha
  639. 24:22under f
  640. 24:24is denoted by alpha plus
  641. 24:27so
  642. 24:28this
  643. 24:29set of
  644. 24:31closure attributes of alpha
  645. 24:34is a set of attributes
  646. 24:36that are functionally determined by
  647. 24:38alpha under f
  648. 24:41so all set of attributes
  649. 24:44that are functionally determined by
  650. 24:47alpha under the set of functional
  651. 24:49dependencies
  652. 24:51is member of alpha plus
  653. 24:55so the following sample
  654. 24:57algorithm can compute the closure
  655. 25:00naturally initially let us say the
  656. 25:02result is the final closure set so
  657. 25:05initially we can say that result can be
  658. 25:07initialized with alpha because certainly
  659. 25:09the whole of alpha would necessarily
  660. 25:12belong to alpha plus by the
  661. 25:14reflexivity condition
  662. 25:17then for each functional dependency
  663. 25:21beta determining gamma
  664. 25:23we check if beta is a subset of the
  665. 25:26result
  666. 25:27if beta is a subset of the current
  667. 25:30set of attributes that form result
  668. 25:32which mean that
  669. 25:35alpha
  670. 25:36functionally determines beta
  671. 25:39it will have to because
  672. 25:40result is the set of all attributes that
  673. 25:43alpha functionality determines
  674. 25:45so if beta is a subset of the result
  675. 25:48then necessarily alpha functionally
  676. 25:49determines beta alpha functional
  677. 25:51determines beta is
  678. 25:53is a consequence of this
  679. 25:56and we know that this is there beta
  680. 25:58functional determines gamma
  681. 26:00so combined by transitivity so i know
  682. 26:03alpha functionality determines gamma
  683. 26:05if function alpha functionally
  684. 26:06determines gamma then it must get into
  685. 26:08the result and this is exactly what
  686. 26:10the statement is saying that take result
  687. 26:12and
  688. 26:13add alpha ah add gamma the set of
  689. 26:16attributes gamma to the result
  690. 26:18and how long should you do that
  691. 26:20naturally you will do that as long as
  692. 26:24over a full iteration of
  693. 26:27functional dependencies in f if there is
  694. 26:30no change to the result then you know
  695. 26:31that all future iterations will have no
  696. 26:33change so you reach a fixed point and
  697. 26:35you declare that the closure of the set
  698. 26:38of attributes have been obtained
  699. 26:41now this this closure information is is
  700. 26:44very
  701. 26:45interesting and we just show
  702. 26:47a
  703. 26:48an example
  704. 26:50here based on the same set of attributes
  705. 26:52and same set of functional dependencies
  706. 26:54so we are trying to find the closure of
  707. 26:56the set of attributes a g so a g plus
  708. 26:59initially it will be a g
  709. 27:01now
  710. 27:02ah since a functionally determines c so
  711. 27:06given that
  712. 27:08i can say that
  713. 27:10c will get included in this set
  714. 27:13in the same iteration if i look at a
  715. 27:15function determines b
  716. 27:17so b will get included this set
  717. 27:20so after this ah
  718. 27:23first
  719. 27:24iterative loop
  720. 27:26i will have the result as a b c g
  721. 27:29if a b c g is there and i am looking at
  722. 27:32the next iteration then c g functionally
  723. 27:35determines h so h comes into the set
  724. 27:40because c g is is a subset of that
  725. 27:43the i comes into the set
  726. 27:45because c g functionally term inside
  727. 27:49and at this point it ah eventually ends
  728. 27:52in this case
  729. 27:53in this particular example
  730. 27:56you you can see that all attributes have
  731. 27:59got included so you can see that it
  732. 28:01immediately gives you an another
  733. 28:03information as a byproduct of the
  734. 28:05closure
  735. 28:06that
  736. 28:06closure of a g is all attributes which
  737. 28:09mean that a g is a
  738. 28:10key
  739. 28:12it has to be a key because a g
  740. 28:13functional determines all attributes now
  741. 28:15so what is the meaning of a g plus being
  742. 28:18this so if the meaning of this is a g
  743. 28:20functionally determines the set of
  744. 28:22attribute a b c g h i
  745. 28:25right
  746. 28:27so we will see that this closure set
  747. 28:32has a lot of
  748. 28:34valuable information in this so
  749. 28:37we can say that a g is a candidate key
  750. 28:39and
  751. 28:40because this of this
  752. 28:43and we can also check whether a g is a
  753. 28:45super key or not all that we need to do
  754. 28:47is drop
  755. 28:48some member from a g we drop g
  756. 28:51and check whether a function determines
  757. 28:53r which means we check whether
  758. 28:56a plus is equal to r or not
  759. 28:59we check we drop
  760. 29:01a from a g
  761. 29:03and check whether g function determines
  762. 29:05r which means g plus has to be equal to
  763. 29:08r and by that we can easily determine
  764. 29:11whether the
  765. 29:12ah set of attributes is a key or not
  766. 29:16so there are several ways the
  767. 29:18attribute closure can be used as we have
  768. 29:21just seen
  769. 29:22it helps you determine whether something
  770. 29:24is a super key we can check for ah
  771. 29:28testing functional dependencies because
  772. 29:31if we have to check whether a functional
  773. 29:32dependency alpha determines beta hold
  774. 29:35all that will have to do is to compute
  775. 29:38the closure of the set of attributes
  776. 29:41alpha that is alpha plus and check
  777. 29:43whether beta is a subset of that if it
  778. 29:44is then certainly it holds if it is not
  779. 29:47then it does not hold
  780. 29:50so it is simple and useful test that can
  781. 29:53be made use of
  782. 29:54so it can also be used in computing the
  783. 29:58closure of f
  784. 29:59that the for example for every
  785. 30:01subset
  786. 30:02gamma of r if we find gamma plus that is
  787. 30:06a closure of the set of attributes of
  788. 30:08gamma
  789. 30:09and for then for each
  790. 30:12subset of gamma plus we know that there
  791. 30:14is a functional dependency gamma
  792. 30:17determining s which is just is a same
  793. 30:20statement being made in in you know in
  794. 30:22different forms and
  795. 30:24the closure of attributes is a very nice
  796. 30:26concept which
  797. 30:28help you play around with this multiple
  798. 30:30ways and we will see subsequently many
  799. 30:32of the algorithms for normalization how
  800. 30:34they make effective use of this closure
  801. 30:37set the
  802. 30:39notion of both closure of
  803. 30:42functional dependencies and in very
  804. 30:44practical implementation algorithms the
  805. 30:46closure of
  806. 30:48attributes
  807. 30:49so to summarize this module we have
  808. 30:51discussed
  809. 30:53issues further issues in the good design
  810. 30:55in the context of functional
  811. 30:57dependencies and
  812. 30:58in the process we have also extended the
  813. 31:01theory of functional dependencies and
  814. 31:03will continue with this in the next
  815. 31:05module to give get more insight into the
  816. 31:09algorithms that actually work with the
  817. 31:11functional dependencies

About this transcript

This page contains the full transcript of Relational Database Design (Contd.)-1 by Data Base Management System - IITKGP, generated from the public captions YouTube serves with the video. The transcript has 4,407 words across 817 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.