YouTube2Text

Relational Database Design/1 — Transcript

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

Full transcript

  1. 0:00[Music]
  2. 0:15welcome to
  3. 0:16module 16 of database management systems
  4. 0:21till ah the last module which closed
  5. 0:24with
  6. 0:25the third week
  7. 0:27ah specifically in the third week we
  8. 0:30talked about
  9. 0:31certain advanced features of sql
  10. 0:34and
  11. 0:35the formal query language
  12. 0:39ah in terms of relational and algebra
  13. 0:42and calculi
  14. 0:43then we talked in at depth in terms of
  15. 0:47the entity relationship model
  16. 0:49the first basic conceptual level
  17. 0:52representation of the real world that we
  18. 0:55can do in terms of designing a system
  19. 0:58now our next task would be to
  20. 1:01take it to a more proper complete
  21. 1:05relational database design
  22. 1:07and
  23. 1:08this will have a lot of
  24. 1:11theory at different levels that we need
  25. 1:14to understand will slowly develop that
  26. 1:16and this discussion will span
  27. 1:18five modules
  28. 1:20that is ah will take the whole week to
  29. 1:23complete
  30. 1:25so the objective of the current module
  31. 1:28the first of the relational design
  32. 1:31module is to identify features of good
  33. 1:33relational design
  34. 1:35ah having done the year model we
  35. 1:38have here we do the year model we have
  36. 1:40the entity sets relationships we convert
  37. 1:42them to schema we have seen how to do
  38. 1:44that and immediately we have some design
  39. 1:47but the question is is it a good design
  40. 1:49so we will discuss about what are the
  41. 1:51features of a good design and then we
  42. 1:54will introduce the formal definition of
  43. 1:57what is first normal form and we will
  44. 2:00introduce a very critical concept of
  45. 2:03relational database design the
  46. 2:05functional dependencies
  47. 2:07these are the
  48. 2:08ah module outline for that
  49. 2:10so to start with the features of good
  50. 2:13relational design let us take an example
  51. 2:15suppose
  52. 2:16ah we have seen
  53. 2:18the instructor relation
  54. 2:20ah instructor entity set as a relation
  55. 2:22you have seen the department relation
  56. 2:24now let us consider that if these two
  57. 2:27were not two separate relations if they
  58. 2:29were
  59. 2:30all kept in a common relation that is
  60. 2:32all the attributes are kept in the
  61. 2:33common relation so earlier if you recall
  62. 2:37that your instructor relation was this
  63. 2:39and your department relation was this
  64. 2:41much so if we keep everything together
  65. 2:44of course ah
  66. 2:45we are calling it in depth but
  67. 2:47please keep in mind this is not the same
  68. 2:50in step that we discussed in terms of
  69. 2:52the er model this is just putting these
  70. 2:54two together
  71. 2:56now the question is if you look into
  72. 2:57this data carefully for example if you
  73. 2:59look into ah this particular row if you
  74. 3:02look into this particular row and if you
  75. 3:05look into this particular row
  76. 3:07these are rows of instructors who all
  77. 3:10belong to computer science
  78. 3:14now earlier
  79. 3:16we were representing the information of
  80. 3:18instructor only in this part
  81. 3:21so we just knew that it is computer
  82. 3:23science and we represent the information
  83. 3:26of department in this part
  84. 3:29so given a department name say computer
  85. 3:31science we knew where does it
  86. 3:34ah
  87. 3:35where is it located the building and
  88. 3:37what budget it has
  89. 3:38now when we are combined we will see
  90. 3:40that naturally since computer science is
  91. 3:43located in the taylor building we know
  92. 3:45and it has a budget of say hundred
  93. 3:47thousand so all of these records will
  94. 3:49have
  95. 3:50this information repeated
  96. 3:52so this is not a very good situation
  97. 3:55this is not a good situation because
  98. 3:57this
  99. 3:59kind of situation is typically in in
  100. 4:02database
  101. 4:03is known as redundancy that is you have
  102. 4:06the same data in multiple places
  103. 4:10so what is the consequence of redundancy
  104. 4:12for example there could be ah different
  105. 4:15kinds of anomaly when you have
  106. 4:17redundancy what is an anomaly and
  107. 4:20anomaly is
  108. 4:22the possibility of certain data getting
  109. 4:25inconsistent for example lets say
  110. 4:27computer science department moves from
  111. 4:29taylor building to painter building
  112. 4:32now what will have to happen if it moves
  113. 4:34to painter building then i will need to
  114. 4:36remove this make it a painter
  115. 4:38make this value painter
  116. 4:40i have to also do this make this painter
  117. 4:44i have to also do this make this painter
  118. 4:48so
  119. 4:49if i have
  120. 4:50a change
  121. 4:52then i will have to make the change at
  122. 4:54multiple entries think about the earlier
  123. 4:57situation where we i just had these
  124. 4:59three
  125. 5:01in my department relation then naturally
  126. 5:04computer science had only one row and
  127. 5:06therefore ah
  128. 5:08this change this update could be done at
  129. 5:12only one place so it is not only that it
  130. 5:14while doing this in case of this
  131. 5:17redundancy i have to do this multiple
  132. 5:19times it also has the
  133. 5:21difficulty that if i forget to update
  134. 5:24any one of them or more of them then i
  135. 5:26have inconsistent data
  136. 5:28similarly if i if i want to
  137. 5:31insert a new value
  138. 5:32i will have to
  139. 5:34do that for all this redundant
  140. 5:36information if i have to delete
  141. 5:39say ah
  142. 5:40for some reason let us say the
  143. 5:42university decides to wind up the
  144. 5:44physics department then i have to delete
  145. 5:47all this
  146. 5:48rows which have physics as an entry and
  147. 5:51the consequence of that is the
  148. 5:53department is deleted but as a
  149. 5:55consequence of that i will delete the
  150. 5:56whole
  151. 5:57row and therefore i will not only remove
  152. 6:00the department but i will also remove
  153. 6:03the corresponding instructor who was
  154. 6:05enrolled for that department
  155. 6:07so
  156. 6:08this kind of
  157. 6:11redundancy can lead to
  158. 6:14different kinds of anomalies in a
  159. 6:16database design
  160. 6:18on the other hand if you look at ok well
  161. 6:20why am i complicating ah the whole
  162. 6:22situation we already had a good design
  163. 6:25ah in terms of where these animals were
  164. 6:27not there department was separate
  165. 6:29instructor was separate
  166. 6:31in that case the
  167. 6:35situation is that to answer some of the
  168. 6:37queries i may have to do a very
  169. 6:40expensive join operation for example if
  170. 6:42i want to know
  171. 6:43if ah
  172. 6:45einstein wants to know what is the
  173. 6:47budget of
  174. 6:49his department that cannot be found out
  175. 6:52from the earlier instructor database
  176. 6:54instructor relation which had only these
  177. 6:56fields
  178. 6:58so i have to pick up
  179. 7:00einstein from here do a join based on
  180. 7:03the department name
  181. 7:05depth name with the department
  182. 7:07ah table
  183. 7:09department relation and then only i will
  184. 7:11be able to find out that einstein
  185. 7:13belongs to physics physics has a
  186. 7:16budget of seventy thousand so einstein's
  187. 7:19department has a budget seventy thousand
  188. 7:22so there is a trade-off between how much
  189. 7:24data information you make redundant
  190. 7:28and lead to different anomalous
  191. 7:31situations and or how much data you
  192. 7:33optimize in the representation but
  193. 7:38get into the possible situation of
  194. 7:40having a higher cost in terms of
  195. 7:42answering your queries
  196. 7:44so this is ah one of the core design
  197. 7:47issues that we will start with
  198. 7:49so
  199. 7:51ah let us look into some more of these
  200. 7:54examples
  201. 7:55lets say we look into another ah combine
  202. 7:58combination of schema suppose
  203. 8:00section is a relation which have
  204. 8:03the sections of a course which give the
  205. 8:05section id semester year
  206. 8:08and say section class is another
  207. 8:11relation which tell me for a section id
  208. 8:13what is the building and room number
  209. 8:15where it is
  210. 8:17located so if we have this
  211. 8:20kind of
  212. 8:22relations combined
  213. 8:24into a common relation
  214. 8:27then i have all of these
  215. 8:30coming from the section
  216. 8:32and
  217. 8:33this and these coming from the section
  218. 8:36class
  219. 8:37but we can see that there is no
  220. 8:40repetition or
  221. 8:41ah redundant information in this case so
  222. 8:44it is not that that combining schemas is
  223. 8:48necessarily always bad in terms of
  224. 8:50repetition or in terms of redundancy so
  225. 8:53different situations will have to be
  226. 8:54assessed
  227. 8:56so
  228. 8:59if we want to look at the other side
  229. 9:00that if we if we just
  230. 9:03as i said that if we make the schema
  231. 9:05smaller so that we avoid redundancy
  232. 9:09and then what we see that well um
  233. 9:13from the combined
  234. 9:14ins depth
  235. 9:17relationship that we saw so if let me
  236. 9:20just ah
  237. 9:21show you once more so this is if we look
  238. 9:23at the ins depth
  239. 9:25then
  240. 9:26in this
  241. 9:27we can
  242. 9:29we know that
  243. 9:31from the earlier
  244. 9:33information about the department
  245. 9:34relationship that
  246. 9:36department name
  247. 9:38is a
  248. 9:39key is a primary key
  249. 9:41of
  250. 9:42the relation which has department
  251. 9:46name building and budget
  252. 9:49what is the consequence of being a
  253. 9:50primary key if it is a primary key then
  254. 9:53no two records can match on the
  255. 9:55department name
  256. 9:59and be different in terms of the
  257. 10:01building and the budget if two records
  258. 10:03are there which have the same department
  259. 10:05name they must have they must be
  260. 10:06identical so they are distinguishable
  261. 10:08completely by that
  262. 10:10so let us see what is the consequence of
  263. 10:12this
  264. 10:13and
  265. 10:14so we are saying that we write it as a
  266. 10:16rule that if there is a schema
  267. 10:18department name building budget then
  268. 10:20department name would be a candidate key
  269. 10:23and we
  270. 10:24write this observation that if
  271. 10:28two records match on the department name
  272. 10:30they must match on the building and
  273. 10:32budget
  274. 10:33and very loosely will come to the formal
  275. 10:35definition very loosely we call this the
  276. 10:38functional dependency we say that the
  277. 10:41building and budget is functionally
  278. 10:43dependent on the department name
  279. 10:45and that is a situation
  280. 10:47that is a situation where
  281. 10:50we can
  282. 10:52split
  283. 10:53this inch depth
  284. 10:55and
  285. 10:56create a smaller
  286. 10:58relationship because department name is
  287. 11:01not a candidate key
  288. 11:03in the ins depth department it does not
  289. 11:07decide the
  290. 11:09records of instep uniquely
  291. 11:11so
  292. 11:12it is ah since it does not so it when
  293. 11:16the values of this
  294. 11:18key
  295. 11:20this
  296. 11:21attribute department name is
  297. 11:24duplicated or triplicated the values of
  298. 11:27the building and budget are repeated and
  299. 11:30we have the redundancy
  300. 11:32so
  301. 11:33this is a situation very common
  302. 11:34situation which is indicative of the
  303. 11:37fact that we needed decomposition into
  304. 11:41smaller
  305. 11:43but ah at the same time
  306. 11:45we can also observe i mean let us take a
  307. 11:47different different example if we are
  308. 11:49thinking that decomposition is the
  309. 11:51panacea of
  310. 11:52ah solving this kind of redundancy and
  311. 11:56related problems then let us
  312. 11:59try to see a different relationship
  313. 12:01employ
  314. 12:02which has id name street city salary and
  315. 12:05we want to make it smaller
  316. 12:08and and want to make two relations
  317. 12:12id and name and name cities
  318. 12:15street salary so if we do that
  319. 12:19then how do we get the
  320. 12:22say salary for a particular id
  321. 12:25will naturally have to join these two
  322. 12:28naturally join these two ah these two
  323. 12:31relations
  324. 12:32in terms of the common attribute name we
  325. 12:34have seen that in the query
  326. 12:36now the question is when i do this join
  327. 12:38do i get back the
  328. 12:40original information or i gave i lose
  329. 12:42some information look at an example so
  330. 12:45here is an example of the combined
  331. 12:48instance
  332. 12:50and i have two different ids but
  333. 12:53incidentally
  334. 12:54the names are same
  335. 12:56incident the names of these two distinct
  336. 12:59employees are same
  337. 13:00so when i decompose i get this
  338. 13:05relation which shows idn name i get this
  339. 13:08relation which against the name shows
  340. 13:10this
  341. 13:11but when i try to join them by natural
  342. 13:13join
  343. 13:14i not only get the combination of
  344. 13:17this with this which is what i need
  345. 13:20but i also get this combination
  346. 13:23so if i say
  347. 13:24this is
  348. 13:26what i get
  349. 13:28as well in terms of natural join this is
  350. 13:30what i get
  351. 13:32as well in terms of the natural join
  352. 13:34which are really not there
  353. 13:37in the original relation so you can see
  354. 13:38that
  355. 13:39in the natural join i get four
  356. 13:42records i get four rows whereas in the
  357. 13:44original one i had only two rows so i
  358. 13:47get some entries which are actually
  359. 13:50erroneous
  360. 13:52these are not there in the database
  361. 13:54so this is when this happens we say that
  362. 13:56we have loss of information and such
  363. 13:59joints are said to be
  364. 14:01lossy joints so while we decompose we
  365. 14:04need to make sure that our joints are
  366. 14:06lossless in nature otherwise that is not
  367. 14:09a good design
  368. 14:11so you can
  369. 14:13see this is again a hypothetical example
  370. 14:16which shows three
  371. 14:18attributes a relation having three
  372. 14:21attributes you have decomposed it did
  373. 14:22two relations
  374. 14:24having two attributes each and we have
  375. 14:26shown an instance and in this case it
  376. 14:28shows that the
  377. 14:30when i take the joint
  378. 14:32when i take the joint the original
  379. 14:35information
  380. 14:36i am sorry wait
  381. 14:40when i take the joint
  382. 14:42the original information is completely
  383. 14:44retrieved i get back the same table and
  384. 14:47when that happens i say that the join is
  385. 14:50lossless
  386. 14:51so what we need to
  387. 14:53understand is
  388. 14:55ah on one side there is a need to
  389. 14:59decompose relations into smaller
  390. 15:01relations to reduce redundancy
  391. 15:04and while we do that we will also have
  392. 15:06to
  393. 15:08keep this in mind that the smaller ah
  394. 15:11relations have must be composable
  395. 15:14through certain natural join procedure
  396. 15:17to the original relation and i must get
  397. 15:20back that original relation otherwise i
  398. 15:22have a lossy joint which is not
  399. 15:23acceptable and also the decomposition
  400. 15:26will have the costs of
  401. 15:29ah doing natural join every time i want
  402. 15:31to answer those queries
  403. 15:36ah
  404. 15:37the next that we look at is
  405. 15:41the way the relationships are
  406. 15:43categorized as first normal form
  407. 15:46ah we consider that
  408. 15:48the domains of attributes
  409. 15:52are atomic if they are indivisible
  410. 15:55so
  411. 15:56anything that is a number string and so
  412. 15:58on is considered to be atomic
  413. 16:01and we say a relational schema is in its
  414. 16:03first normal form
  415. 16:05if the domains of all attributes are
  416. 16:07atomic
  417. 16:08and all attributes are single value
  418. 16:11there is no multivalued attribute if
  419. 16:13these conditions satisfy then we will
  420. 16:15say that every rel that relational
  421. 16:17schema is in its first normal form
  422. 16:20so we will we will slowly understand the
  423. 16:22the the purpose of ah defining such
  424. 16:25normal forms but let us initially
  425. 16:27understand the definition
  426. 16:29so
  427. 16:29we have ah
  428. 16:31if we have
  429. 16:33attributes which are composite in nature
  430. 16:35naturally my relationship my relational
  431. 16:38schema is not in first normal form if we
  432. 16:40have attributes which are ah multiple
  433. 16:43valued it is not so
  434. 16:45so ah if we say that
  435. 16:49we have possible values are like this
  436. 16:52then if we just treat them as strings
  437. 16:54then the corresponding relational schema
  438. 16:56is
  439. 16:57in first normal form but if we say that
  440. 17:00from the string
  441. 17:01we can extract the first two characters
  442. 17:03which is cs which tells me what is the
  443. 17:05department the next four characters
  444. 17:07gives me a number the serial number ah
  445. 17:10of the of the particular student in the
  446. 17:12role
  447. 17:14then i am not actually using an atomic
  448. 17:18domain ah because my domain needs to be
  449. 17:20interpreted separately than just being a
  450. 17:23value so these are not parts of what can
  451. 17:26be a first normal form
  452. 17:28so i have given some examples of ah what
  453. 17:32is not and what is first normal form so
  454. 17:34this is an example where at the
  455. 17:36telephone number
  456. 17:37ah field exist and there can be multiple
  457. 17:39telephone numbers so this is not in
  458. 17:41first normal form because the telephone
  459. 17:44number itself is composite because it
  460. 17:46has different components and also you
  461. 17:48can have multiple telephone numbers so
  462. 17:50this is this relation is not in the
  463. 17:53first normal form
  464. 17:54ah what you can do you can
  465. 17:57separate out these phone numbers into
  466. 17:59two different attributes telephone
  467. 18:00number one and two
  468. 18:02even ah then um
  469. 18:05it is not exactly in first normal form
  470. 18:08because ah
  471. 18:09you do not know in which order they
  472. 18:11should be handled you if you have to
  473. 18:13search for a telephone number then you
  474. 18:15have to search multiple attributes which
  475. 18:16are conceptually same and then it then
  476. 18:19the question is why only two attributes
  477. 18:21cannot anybody have three phone numbers
  478. 18:23seven phone numbers and so on so this is
  479. 18:25really not a good option
  480. 18:28so
  481. 18:29the other way could be that for every
  482. 18:31telephone number you introduce a
  483. 18:33separate row once you do that you
  484. 18:35already know you have redundancy and you
  485. 18:37have possibilities of varied kinds of
  486. 18:39anomalies that could happen
  487. 18:41so one way it could be achieved is we
  488. 18:44follow the principle that we had seen in
  489. 18:47the er modeling that
  490. 18:50this multivalued dependency can be
  491. 18:53represented in terms of a separate
  492. 18:55relation where against the customer id
  493. 18:58we just keep the telephone numbers we
  494. 18:59can keep multiple of them
  495. 19:01and we take that out from the customer
  496. 19:04name so a one to many relationship
  497. 19:07between the parent and the child ah
  498. 19:09between the customer name and telephone
  499. 19:12number every customer may have more than
  500. 19:14one ah telephone number is possible and
  501. 19:17that makes it a one n f ah relation one
  502. 19:21ah first normal form relation and we
  503. 19:24will later on see that it also is ah two
  504. 19:27n f and three n f but that is a future
  505. 19:29story
  506. 19:31now finally we ah come to
  507. 19:33the core of
  508. 19:35what
  509. 19:36the mathematical formulation
  510. 19:39which dictates much of the database
  511. 19:42relational database design
  512. 19:44is known as functional dependencies i
  513. 19:46just talked about a little bit of that
  514. 19:48while talking about department name
  515. 19:51building and budget now i
  516. 19:54to decide whether a particular relation
  517. 19:56is good
  518. 19:58or rather a particular relational scheme
  519. 20:00is good
  520. 20:02we need to check against certain
  521. 20:05measures
  522. 20:06and
  523. 20:07if it is not good we need to decompose
  524. 20:09it into a set of relations such that
  525. 20:12these conditions satisfy that every each
  526. 20:15one of these
  527. 20:16ah r one r two r and so i mean
  528. 20:19if you have
  529. 20:20ah you know got rusted then its
  530. 20:23basically r i is a set of attributes
  531. 20:26because its a relational schema the
  532. 20:28relational schema is a set of attributes
  533. 20:30so
  534. 20:31ah and naturally r will be the union of
  535. 20:35all of these r i the total set of
  536. 20:37attributes so
  537. 20:38instead of keeping all the information
  538. 20:40into one relation in one table we are
  539. 20:43basically decomposing it into n
  540. 20:45different
  541. 20:46schemas
  542. 20:47and
  543. 20:48so what we need to guarantee is each one
  544. 20:50of these relation r one r two r n is in
  545. 20:53good form
  546. 20:54and
  547. 20:55how do i get back the original relation
  548. 20:58original relation that was represented
  549. 21:00by all the attributes in r is to take a
  550. 21:02lossless join is to take a join and that
  551. 21:05this decomposition must give me a
  552. 21:07lossless join
  553. 21:09so
  554. 21:10to ensure that we make use of
  555. 21:13two key ideas more foundationally
  556. 21:16functional dependencies and then multi
  557. 21:18valued dependencies
  558. 21:20a functional dependency is a constraint
  559. 21:22on the
  560. 21:23set of legal relation so
  561. 21:26ah mind you it is a constraint on the
  562. 21:29schema
  563. 21:30and once it that constraint is is
  564. 21:32defined
  565. 21:33it ah must hold for all relations that
  566. 21:37the schema satisfy
  567. 21:39so
  568. 21:41here we need that the
  569. 21:42value of certain set of attributes
  570. 21:44uniquely determine the value of another
  571. 21:47set of attributes
  572. 21:48so i know the value of
  573. 21:50three attributes i should be able to
  574. 21:52say that values of the other four
  575. 21:55attributes would be fixed
  576. 21:58so
  577. 21:59you can you have already seen this
  578. 22:01notion in terms of ah key or super key
  579. 22:05ah you have seen that
  580. 22:07similar type of concept exist where we
  581. 22:10said
  582. 22:10a
  583. 22:11key is a set of attributes so that if
  584. 22:14the values of two rows are identical
  585. 22:17over these set of attributes then
  586. 22:19the
  587. 22:20two tuples the two rows must be totally
  588. 22:23identical so key is something which ah
  589. 22:26does a similar thing as a functional
  590. 22:28dependency but is more specific
  591. 22:31functional dependence is a
  592. 22:32generalization
  593. 22:34so let us formally define that let r be
  594. 22:37a relational schema which means that it
  595. 22:39is a set of attributes and let us say
  596. 22:41alpha and beta are two subsets of r
  597. 22:45then we say write this and note this
  598. 22:48notation
  599. 22:50alpha is a set of attributes
  600. 22:53beta is another set of attributes both
  601. 22:55are subset of the same r
  602. 22:57and we say alpha functionally determines
  603. 23:00beta
  604. 23:01that is if i know
  605. 23:03the
  606. 23:04value of a tuple
  607. 23:07over the attributes of alpha
  608. 23:10then the values
  609. 23:11of that tuple over the attributes of
  610. 23:14beta would be fixed
  611. 23:16or in other words i say that if i have
  612. 23:19two tuples t one and t2
  613. 23:22and their
  614. 23:24values over the set of alpha attributes
  615. 23:27are same
  616. 23:28then necessarily
  617. 23:30the values over the set of beta
  618. 23:32attributes must be same
  619. 23:34and mind you this is this is something
  620. 23:36which is a design constraint
  621. 23:38this is it is not just an incidental
  622. 23:41property it is not just the fact that a
  623. 23:44particular instance of a schema
  624. 23:47satisfies this but when you say this is
  625. 23:50a functional dependency we need all
  626. 23:52possible
  627. 23:53past present and future instances of the
  628. 23:56schema must satisfy this
  629. 23:59so
  630. 24:03consider this if you if you take a
  631. 24:06relation
  632. 24:08a schema with an instance as given here
  633. 24:10between two attributes a and b
  634. 24:12then we can say at least given this
  635. 24:15instance not we still do not know what
  636. 24:17happens in the whole schema for all
  637. 24:20instances but on this instance we can
  638. 24:22say that a functionality determines b
  639. 24:24does not hold because between the first
  640. 24:27and the second record the value of a is
  641. 24:29same one but the value of b are
  642. 24:31different four and five
  643. 24:32but we can certainly say that on this
  644. 24:35instant at least b functionally
  645. 24:37determines a holes
  646. 24:39because
  647. 24:40whenever the value
  648. 24:42if we take any two tuples the value over
  649. 24:45b does not at all match if that does not
  650. 24:48match then naturally there is no
  651. 24:49question of what happens to the
  652. 24:51value of the tuple over the set of
  653. 24:54attributes a so we will say that b
  654. 24:57functional determining a
  655. 24:59holds in this instance
  656. 25:02so given this definition of functional
  657. 25:04dependency now we can have a formal
  658. 25:06definition of what is a super key a
  659. 25:09super key is naturally a
  660. 25:12subset of attributes which functionally
  661. 25:14determines the whole set
  662. 25:17and a candidate key is a super key which
  663. 25:20is minimal so which means that
  664. 25:23a
  665. 25:23k is a candidate key if the two
  666. 25:26conditions have to satisfy this
  667. 25:27condition say that it is a super key
  668. 25:29that it functionally determines all the
  669. 25:30attributes
  670. 25:31and
  671. 25:32the other condition says minimality that
  672. 25:35there is no subset alpha of k
  673. 25:38such that alpha functionally determines
  674. 25:40r if there exists a subset alpha of k
  675. 25:43the proper subset alpha of k
  676. 25:45so that alpha functionally determines r
  677. 25:47then k would not be a candidate key
  678. 25:50we will have to check for alpha so these
  679. 25:53two what we had stated earlier in
  680. 25:55qualitative terms are now mathematically
  681. 25:58established
  682. 25:59so we can say that the different
  683. 26:01functional dependencies for example in
  684. 26:04the instep
  685. 26:06combined relationship relation if we
  686. 26:08look at then we know that department
  687. 26:10name functionally determines building
  688. 26:13id
  689. 26:14functionally determines building but
  690. 26:19so these are functional dependencies
  691. 26:20that must hold but certainly you would
  692. 26:22not expect ah department name to
  693. 26:24functionally determine saturday that
  694. 26:26would be too much right so
  695. 26:28ah functional dependencies are facts
  696. 26:31about the real world that we try to
  697. 26:34understand from the real world and then
  698. 26:36represent in terms of ah the functional
  699. 26:39dependency formulation in the database
  700. 26:43so
  701. 26:46we can use functional dependencies to
  702. 26:48test relations if they are
  703. 26:50valid under the set of functional
  704. 26:52dependencies so there could be multiple
  705. 26:54functional dependencies in the set
  706. 26:56and if a relation
  707. 27:00we are using small r here just to remind
  708. 27:02you that a relation means that a
  709. 27:04particular instance
  710. 27:05is legal under a set of functional
  711. 27:07dependencies we will say that r
  712. 27:09satisfies that
  713. 27:12and
  714. 27:13if we specify if we have that
  715. 27:17it holds
  716. 27:19f
  717. 27:20will be satisfied by all possible
  718. 27:23instances of a relational schema capital
  719. 27:26r then you say f holds on r
  720. 27:29so a relation satisfies a functional
  721. 27:31set of functional dependencies and a
  722. 27:36relational schema for a relational
  723. 27:38schema the functional depend set of
  724. 27:40functional dependencies holds on that
  725. 27:41schema which means that for all possible
  726. 27:44past present and future
  727. 27:46instances relations that
  728. 27:49the relations will satisfy the
  729. 27:51functional dependencies
  730. 27:58so we have ah
  731. 28:00for example id we know id functionally
  732. 28:03determines name that if the id is
  733. 28:05distinct then the name has to be
  734. 28:07distinct
  735. 28:08but
  736. 28:08we may find that instance where name
  737. 28:10functionally determines id so we can say
  738. 28:13that it names functionality determines
  739. 28:16id is satisfied by a particular instance
  740. 28:18where it so happens that there is no two
  741. 28:22ah rows where the name is identical
  742. 28:25but
  743. 28:27we cannot
  744. 28:28may not be able to infer that
  745. 28:30as the this dependency holding on the
  746. 28:33relational scheme as a whole because
  747. 28:36tomorrow we can get another entry
  748. 28:38so that ah the two rows might match on
  749. 28:42the name but could still be distinct
  750. 28:44entries not matching on i d
  751. 28:46so that is how this will ah have to be
  752. 28:48looked at
  753. 28:49ah in specificity we say that a
  754. 28:52functional dependency is trivial if the
  755. 28:55left hand side
  756. 28:57is a super set of the right hand side so
  757. 29:01if i have a bigger set of attributes on
  758. 29:03the left hand side id and name then
  759. 29:06obviously id and name will functionally
  760. 29:07determine id
  761. 29:09idn name will functionally determine
  762. 29:11name
  763. 29:12name will functionally determine name so
  764. 29:14if you just think about because in a
  765. 29:16functional dependency the left hand side
  766. 29:18attributes the tuples have to match on
  767. 29:20the left hand side attribute and if they
  768. 29:22do then they must match on the right
  769. 29:24hand side attribute so if the right hand
  770. 29:25side set of attributes is a subset of
  771. 29:28the left hand side then obviously the
  772. 29:30functional dependency will be vacuously
  773. 29:32true and these are called trivial
  774. 29:33dependencies
  775. 29:35so in the next couple of slides i have
  776. 29:37shown a few examples of functional
  777. 29:39dependencies of different different
  778. 29:41tables here student id functionally
  779. 29:44determines semesters which mean that we
  780. 29:46are trying to model
  781. 29:47that a student
  782. 29:50cannot be at the same time in two
  783. 29:52semesters
  784. 29:53ah then student id and lecture together
  785. 29:56functionally determines who is the ta
  786. 29:57and so on and you can see for this ah
  787. 30:00particular relation student id and
  788. 30:02lecture pair also happens to be the
  789. 30:04candidate key
  790. 30:06ah these are another example so these
  791. 30:09are just go through them try to convince
  792. 30:11yourself that these functional
  793. 30:13dependencies
  794. 30:14are
  795. 30:15ah very genuinely real world situations
  796. 30:17that can be modeled in this way
  797. 30:20given a set of functional dependencies
  798. 30:22we can actually compute a closure for
  799. 30:25example if a functionally determines b
  800. 30:28and b functionally determines c
  801. 30:30then we can infer that a functionally
  802. 30:32determined because if two tuples match
  803. 30:34on a
  804. 30:35a determines b says that they match on b
  805. 30:38now if
  806. 30:39b functionally determine c also holds
  807. 30:42then if they match on b they match on c
  808. 30:44so if they match on a then necessarily
  809. 30:47they may have to match on c
  810. 30:49so this is called the logical
  811. 30:51implication of a
  812. 30:53set of functional dependencies and
  813. 30:56we will see more of this
  814. 30:58later but
  815. 30:59if we take all functional dependencies
  816. 31:03of a given set f that are logically
  817. 31:06implied from this set f we say that is a
  818. 31:09closure set
  819. 31:10and we represent that by f plus
  820. 31:14so f plus necessary is a super set of f
  821. 31:17so here in that above example this is
  822. 31:20the f and this is a f plus
  823. 31:23so will continue more on the theory of
  824. 31:25functional dependencies but
  825. 31:27let us conclude this module by
  826. 31:28summarizing that we have identified the
  827. 31:31features of good relational designs
  828. 31:34trade-off between decomposition and
  829. 31:38lossless
  830. 31:39join properties that we need we are
  831. 31:41familiarized with the first normal form
  832. 31:43and atomic domains and we have
  833. 31:45introduced the notion of functional
  834. 31:47dependencies on which we will build up
  835. 31:49more and try to get
  836. 31:52zero in on very concrete strategies for
  837. 31:55good designs

About this transcript

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