YouTube2Text

Introduction to Relational Model/1 — Transcript

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

Full transcript

  1. 0:00[Music]
  2. 0:19welcome to
  3. 0:21module 4 of database management systems
  4. 0:26in the last two modules ah we have
  5. 0:28introduced the basic notions of ah
  6. 0:31dbmss
  7. 0:34in this module and the next we
  8. 0:37make an introduction to the relational
  9. 0:39model which we said is a major data
  10. 0:42model that we are going to use
  11. 0:46so this is a
  12. 0:48what we did in the last module
  13. 0:51and
  14. 0:52in the current one our objective will be
  15. 0:54to understand
  16. 0:57key concepts of relational model that is
  17. 1:00attributes and their types
  18. 1:03the basic mathematical structure of
  19. 1:06instance schema and what is known as
  20. 1:10keys to familiarize with different types
  21. 1:14of relational query languages
  22. 1:18this is the
  23. 1:19module outline
  24. 1:21that we will follow
  25. 1:23so
  26. 1:25we again
  27. 1:27repeat this example from past
  28. 1:30this is an example of instructors
  29. 1:32in a university a table of instructors
  30. 1:36given by attributes or columns
  31. 1:39id name department name and salary these
  32. 1:42are the four columns the four ids
  33. 1:44and multiple rows which are specific
  34. 1:47rows or we often refer to them as
  35. 1:50tuples
  36. 1:51so you can say that since there are four
  37. 1:54attributes that is
  38. 1:56every row has four columns
  39. 1:58so this is a fourth tuple that we have
  40. 2:01and such a table
  41. 2:03is called a relation
  42. 2:05is as simple as that so this is it
  43. 2:08whenever we talk about a relation
  44. 2:10we have a number of
  45. 2:13fields number of attributes number of
  46. 2:15columns whatever way we say
  47. 2:18of a table
  48. 2:19and that table according to those
  49. 2:22columns it has
  50. 2:24multiple 0 1 or any number of rows
  51. 2:28of values filled in and that is what is
  52. 2:31a relation
  53. 2:33now
  54. 2:34so let us look at attributes more
  55. 2:37specifically
  56. 2:38so
  57. 2:39attributes
  58. 2:41each column is an attribute as we said
  59. 2:43this
  60. 2:44every attribute has a domain
  61. 2:47the domain is a set of possible values
  62. 2:49that attribute can take so if you just
  63. 2:51look into the example
  64. 2:53here so i am trying to define a
  65. 2:57table
  66. 2:58having different students
  67. 3:01so
  68. 3:03there is a roll number for a student
  69. 3:05there is a first name last name the date
  70. 3:07of birth dob
  71. 3:09the passport number the other card
  72. 3:11number the department to which the
  73. 3:13student belongs and so on so let us say
  74. 3:15this one two three four five six seven
  75. 3:17are the different attributes
  76. 3:19now if you look into every attribute
  77. 3:21then
  78. 3:23every attribute has a set of possible
  79. 3:25values of which some value is entered in
  80. 3:28a particular row for example the roll
  81. 3:30number is an alpha numeric string as you
  82. 3:33can see it has ah numerics as well as it
  83. 3:35has letters
  84. 3:37whereas the first name or the last name
  85. 3:39are simple alpha strings in fact we can
  86. 3:41also say that the roll number actually
  87. 3:43is not only alpha numeric it has a fixed
  88. 3:45length it has a length of
  89. 3:47here it says length of nine so you can
  90. 3:49say alpha numeric strength of length
  91. 3:51nine are eligible for
  92. 3:53being values of this domain there could
  93. 3:55be more restrictions but
  94. 3:57that the domain will be certain
  95. 3:59collection of values
  96. 4:01which are possible
  97. 4:02as values of that attribute
  98. 4:05when you talk about dob that certainly
  99. 4:07has to be a date
  100. 4:08so its written in the form of
  101. 4:11d d m m y y y y that is two digit date
  102. 4:15three letter month code and four digit
  103. 4:18year
  104. 4:20the passport number is a string
  105. 4:23a letter followed by seven digits
  106. 4:26the other number is a 12 digit number
  107. 4:28the department is alpha string and so on
  108. 4:30so
  109. 4:31the domain
  110. 4:33is a set corresponding to an attribute
  111. 4:36which define that all possible values
  112. 4:39that attribute can take
  113. 4:42ok now ah
  114. 4:44these attribute values if you look at
  115. 4:47they are
  116. 4:49atomic in nature that is you cannot
  117. 4:51divide them into smaller parts
  118. 4:54so what i mean is say when we are
  119. 4:56talking about date of birth
  120. 5:00the whole date of birth type the date
  121. 5:02type is one atomic value
  122. 5:08for example if you were to code this in
  123. 5:10c what you could do you could
  124. 5:12ah possibly create a structure with
  125. 5:14three fields one is a date one is a
  126. 5:16month one is the year and you will say
  127. 5:18that this composite record composite
  128. 5:20structure is actually my date
  129. 5:23you can do a lois type def you can do if
  130. 5:26you are working in c plus plus you will
  131. 5:28define a class called date which has
  132. 5:31these components and as well as
  133. 5:33operations with them but that kind of
  134. 5:35types are not allowed
  135. 5:37in a relational database
  136. 5:40it has to be an atomic type so a
  137. 5:42relational database will give you a
  138. 5:44atomic type called date
  139. 5:45where all of these are pre-specified and
  140. 5:48has to be taken as one unit
  141. 5:52other atomic types are ah integer
  142. 5:55ah
  143. 5:56like ah we do not have an integer field
  144. 5:59here there are strings there are
  145. 6:01numerical
  146. 6:03values which are kind of floating point
  147. 6:05values and so on
  148. 6:07now some attribute may have a special
  149. 6:12value called the null value
  150. 6:14which is
  151. 6:15ah the member of its domain
  152. 6:18actually every attribute
  153. 6:21ah of any domain
  154. 6:23can have this special value the null
  155. 6:26value is not actually a value it is
  156. 6:28actually an absence of a value so it
  157. 6:31says that this value is not known so if
  158. 6:34you look into the example
  159. 6:38above then you see that for passport we
  160. 6:40have said that the passport is a string
  161. 6:44letter followed by seven digits and it
  162. 6:46is nullable which means that in the
  163. 6:48passport field
  164. 6:50i may have a value may have this null
  165. 6:52value which means that
  166. 6:54it is not that the
  167. 6:56the passport is null
  168. 6:58what it is saying is that this passport
  169. 7:01number
  170. 7:02for this particular student the row
  171. 7:04number 2
  172. 7:05is not known is unknown
  173. 7:08now all fields may
  174. 7:10or may not be nullable for example we
  175. 7:12will not allow dob to be nullable
  176. 7:15data but has to be there will not allow
  177. 7:17roll number to be nullable will not
  178. 7:19allow first name to be narrable but we
  179. 7:21may
  180. 7:22allow last name to be nullable its been
  181. 7:25been a style of let not to use your
  182. 7:28last name many many people just use one
  183. 7:31name so you could allow that it is not
  184. 7:33known its not there
  185. 7:35whereas ah
  186. 7:36department may not be nullable it must
  187. 7:38be there so null is a very critical
  188. 7:40concept and
  189. 7:42what it actually does it ah
  190. 7:44actually ah creates a
  191. 7:48lot of issues ah
  192. 7:49and complications in terms of defining
  193. 7:52many operations so understanding null as
  194. 7:54a value in terms of an attribute is a
  195. 7:57critical requirement for the design
  196. 8:01now
  197. 8:01coming to the schema and instance we
  198. 8:03have ah
  199. 8:05discussed about the basic understanding
  200. 8:07of schema and instance
  201. 8:09so understanding them formally now we
  202. 8:12say that ah
  203. 8:14if we have a schema so its like a table
  204. 8:17having multiple columns say there are n
  205. 8:20columns having
  206. 8:21names a one two a n
  207. 8:24then this a 1 to a n are the attributes
  208. 8:27so
  209. 8:28these are the different attributes that
  210. 8:31it will have so ah i am
  211. 8:34these are the different attributes so if
  212. 8:36i have this then it it basically means
  213. 8:39that i have a table where
  214. 8:41the these are the columns a one a two a
  215. 8:43n like this
  216. 8:46ok so
  217. 8:50then
  218. 8:51a relational schema
  219. 8:53is a collection of these attributes so
  220. 8:55it is a
  221. 8:57collection of
  222. 8:58all these
  223. 8:59attributes
  224. 9:00so we say r is a relational schema which
  225. 9:03has attributes a one to a n
  226. 9:06now every attribute
  227. 9:09a i
  228. 9:11has a
  229. 9:13domain d i
  230. 9:16so for every attribute i have a set of
  231. 9:18values that are possible
  232. 9:20so
  233. 9:21if you
  234. 9:22ah
  235. 9:24if you recall then ah here
  236. 9:28ah we had
  237. 9:30different
  238. 9:31these are the different attributes
  239. 9:33and these are their different domains so
  240. 9:36dob is an attribute and the domain is
  241. 9:38date so any possible date
  242. 9:40other is an attribute and this is the
  243. 9:43domain
  244. 9:44which is
  245. 9:45so
  246. 9:46all
  247. 9:47attributes
  248. 9:48each attribute will need to have certain
  249. 9:51domain and those are marked by the d
  250. 9:54sets
  251. 9:55so we will say that a particular
  252. 9:58relation
  253. 9:59a particular relation r so r is a schema
  254. 10:04schema
  255. 10:05so a particular relation r
  256. 10:07is a subset of
  257. 10:10d one cross d two cross dot dot dot
  258. 10:14d n
  259. 10:16right
  260. 10:18so recall the mathematical notion of
  261. 10:22relation
  262. 10:23which
  263. 10:24say that a relation is basically a
  264. 10:26subset of s at
  265. 10:28so these are the possible values so the
  266. 10:30first attribute can take values from d
  267. 10:32one second attribute can take values
  268. 10:34from d two and so on and the nth
  269. 10:36attribute can take values from d n so
  270. 10:39any specific row any specific record
  271. 10:42is a set of
  272. 10:44values for a one a two a n
  273. 10:47and therefore is a member of
  274. 10:49this cartesian product
  275. 10:51and the relation is a subset of that so
  276. 10:54this is every value is an n tuple
  277. 10:57which is a subset of this a one
  278. 11:00a two
  279. 11:02a n this particular record
  280. 11:04is an element of
  281. 11:07this
  282. 11:09cartesian product set
  283. 11:12and
  284. 11:12are necessarily is
  285. 11:16a
  286. 11:17set of such
  287. 11:20tuples
  288. 11:22thats a mathematical view of the schema
  289. 11:25and the instance so this is the schema
  290. 11:28and this is the
  291. 11:29instance
  292. 11:31corresponding to that schema based on
  293. 11:33the
  294. 11:34different domains of the different
  295. 11:37attributes
  296. 11:38and this is ah the notion that we will
  297. 11:41continue using so
  298. 11:43ah please try to
  299. 11:45follow this carefully
  300. 11:50now whenever we have a an instance we
  301. 11:54mark that as a table and
  302. 11:56every
  303. 11:57such
  304. 11:58table so here you have now understood it
  305. 12:01very well so these are my attributes so
  306. 12:04this is a one this is a two this is a
  307. 12:06three
  308. 12:07this is a four and any one in a
  309. 12:11these are the different values a two a
  310. 12:13three
  311. 12:14a one a two a three a four
  312. 12:17nine eight three four five is a one kim
  313. 12:20is a two and so on
  314. 12:22now naturally this ah it is not ah
  315. 12:25visible from the instance because we are
  316. 12:27taking an instance view we are not being
  317. 12:30able to see what that domain is that
  318. 12:32will be visible if we look at the
  319. 12:34corresponding ddl the definition
  320. 12:37language description of the schema which
  321. 12:40master specified id as a
  322. 12:43numeric
  323. 12:44value the name as a string value the
  324. 12:46department name has another string value
  325. 12:48where a salary has a numeric value and
  326. 12:50so on
  327. 12:52now what is uh important to note here is
  328. 12:55ah
  329. 12:56a relation necessarily is a set as as
  330. 12:59you said is ah is a set which is
  331. 13:03the
  332. 13:04ah as
  333. 13:06the relation r is a set
  334. 13:10this is a set
  335. 13:12which is a subset of
  336. 13:14this set
  337. 13:16so a set we know the elements in a set
  338. 13:19are do not have any ordering they are
  339. 13:21unordered
  340. 13:23so a relation is necessarily unordered
  341. 13:25so it does not really matter
  342. 13:28that in terms of ah this collection of
  343. 13:31rows
  344. 13:32which row is at what position if i
  345. 13:34reorder them the relation does not
  346. 13:36change
  347. 13:37its just that they are a collection of
  348. 13:39these set of rules
  349. 13:40so that lack of ordering is a critical
  350. 13:43information that will have to remember
  351. 13:45in mind
  352. 13:48next concept is key
  353. 13:50so
  354. 13:52r as we have seen is a relational schema
  355. 13:56which is
  356. 13:57a collection of
  357. 13:59which is a collection of attributes a
  358. 14:01one a two
  359. 14:03a n
  360. 14:04now
  361. 14:06k
  362. 14:07let k be a subset of r so it is one or
  363. 14:10more attributes
  364. 14:12it has to be a non empty subset
  365. 14:16now
  366. 14:18we will say that k is a super key of r
  367. 14:21if
  368. 14:23if we consider the values of different
  369. 14:25tuples
  370. 14:27in the attributes of k
  371. 14:31and we find that
  372. 14:33there cannot be two tuples which
  373. 14:36are different
  374. 14:40but match
  375. 14:42on these attributes
  376. 14:44which mean
  377. 14:45that
  378. 14:46the values of the attributes
  379. 14:50of k
  380. 14:52uniquely identify each row
  381. 14:56of the
  382. 14:57relation
  383. 14:59then we will say that
  384. 15:01k
  385. 15:02is a
  386. 15:04k is a
  387. 15:05super key
  388. 15:07of r
  389. 15:10so
  390. 15:11the instructor table that you have seen
  391. 15:13id is a super key similarly
  392. 15:17so k can be taken as a singleton set of
  393. 15:20attribute id
  394. 15:22or k can be thought of as
  395. 15:26the set comprising id and name both of
  396. 15:28them are super keys of instructor
  397. 15:31now
  398. 15:34we say super key k is a candidate key
  399. 15:39if k is minimal
  400. 15:41so the idea is like this that
  401. 15:43this is
  402. 15:46a key super key this is also a super key
  403. 15:50but certainly this is
  404. 15:53a subset of this this is smaller than
  405. 15:54this
  406. 15:56so we will say this is a candidate key
  407. 15:58but this is
  408. 16:00not a candidate key
  409. 16:02because this does not
  410. 16:03satisfy the minimality condition
  411. 16:13there could be multiple candidate key
  412. 16:16in a relation
  413. 16:18if there are multiple candidates key
  414. 16:21then
  415. 16:22we select one
  416. 16:24to be the primary key
  417. 16:26now obviously there is a question of
  418. 16:27which one we select but any one can be
  419. 16:29selected as a primary key
  420. 16:32which is the key of the relation
  421. 16:36and we will see that in some cases ah
  422. 16:39there is concept of surrogate keys
  423. 16:43so if i have a relation where there is
  424. 16:45no attribute
  425. 16:47which can whose value can uniquely
  426. 16:50identify each and every row of the table
  427. 16:55then i might
  428. 16:56synthetically generate
  429. 16:58a value for example like a serial number
  430. 17:01i can generate a serial number and say
  431. 17:04that this is my value
  432. 17:07so
  433. 17:08that serial number
  434. 17:10or that computer generated
  435. 17:14field value
  436. 17:15has no business implication
  437. 17:19because the real world did not have this
  438. 17:21value
  439. 17:22its not like a other card number or like
  440. 17:24a passport number but its a value which
  441. 17:26is
  442. 17:27purely generated to identify every row
  443. 17:30uniquely
  444. 17:32so such
  445. 17:33keys are known as surrogate keys or
  446. 17:36synthetic keys
  447. 17:39now let us look at
  448. 17:40some examples
  449. 17:43this is again the same
  450. 17:44student database i just shown a while
  451. 17:47ago
  452. 17:48the same set of
  453. 17:50columns but i have added few more rows
  454. 17:54now if we look at what could be a super
  455. 17:56key
  456. 17:57there are several candidates but i have
  457. 17:59just written a few
  458. 18:01ah roll number is certainly a key
  459. 18:03because
  460. 18:05i am assuming that the university
  461. 18:07assigns role numbers to uniquely
  462. 18:09identify every student
  463. 18:11so there cannot be two rows in this
  464. 18:14table which match in the
  465. 18:16value of the roll number and does not
  466. 18:18match in the values of the other fields
  467. 18:21so roll number can uniquely identify
  468. 18:24if it can then any
  469. 18:27set of attributes which contain roll
  470. 18:29number will also be a super key so roll
  471. 18:31number and date of birth
  472. 18:33together is a super key that can also
  473. 18:34uniquely identify every row trivial
  474. 18:39what are the candidate keys
  475. 18:41now there are
  476. 18:42of course there could be several other
  477. 18:44super keys that has to be kept in mind
  478. 18:46the candidate keys are roll number is a
  479. 18:48candidate key
  480. 18:50the first name last name together we can
  481. 18:52say is a candidate key so we are saying
  482. 18:54that not only the first name but if we
  483. 18:56take this pair
  484. 18:57you remember the key the set
  485. 19:00of attributes forming a super key is it
  486. 19:03is a set it is not an individual field
  487. 19:05so i can say the first name last name
  488. 19:06together forms a key
  489. 19:09well this does make some assumption
  490. 19:12because if i say the first name last
  491. 19:14name together forms a key that means
  492. 19:16that there cannot be two records in this
  493. 19:19student table
  494. 19:20where the first name and last name match
  495. 19:23but the records are different
  496. 19:25so which mean
  497. 19:26that
  498. 19:27no two students having the same first
  499. 19:30name and last name
  500. 19:31can be enrolled in the university this
  501. 19:33is a restrictive assumption right but i
  502. 19:35am just making that assumption to
  503. 19:37illustrate
  504. 19:40the different possibilities
  505. 19:43then what is the other possibility
  506. 19:45passport number everybody has a unique
  507. 19:46passport number so passport number would
  508. 19:49also be a key could be a candidate key
  509. 19:53other number everybody has a unique
  510. 19:55other number so that can be a key and so
  511. 19:58on
  512. 19:59so these are called the candidate keys
  513. 20:02now of course we can observe that
  514. 20:05given the data it is clear
  515. 20:07and it was also mentioned when the
  516. 20:09schema was designed this passport number
  517. 20:12cannot be a key
  518. 20:13why can it not be a key can 2 students
  519. 20:16have different
  520. 20:18same passport number of course not
  521. 20:20every student has a unique passport
  522. 20:22number
  523. 20:23but it is possible that some student
  524. 20:26does not have a passport
  525. 20:27so if some student does not have a
  526. 20:29passport then
  527. 20:30the passport number field of that
  528. 20:32student
  529. 20:33is a null
  530. 20:35the passport number is a nullable field
  531. 20:37if the passport number is null then it
  532. 20:39is possible that multiple students
  533. 20:42may not have passports so as we can see
  534. 20:44here
  535. 20:45this student
  536. 20:46jatin chopra does not have a passport
  537. 20:50so
  538. 20:51similarly deepti that does not have a
  539. 20:53passport either
  540. 20:54so certainly if this were to be the key
  541. 20:57then for all
  542. 21:00records for which passport number is nil
  543. 21:03this value would not be able to
  544. 21:05distinguish them in terms of the rows of
  545. 21:07the
  546. 21:08table
  547. 21:10so
  548. 21:11we have
  549. 21:12to say that passport number cannot be a
  550. 21:15key or in other words we can say that no
  551. 21:18key can be a nullable field
  552. 21:20no key attribute
  553. 21:23or a participant to a key attribute
  554. 21:26could be a nullable field right so this
  555. 21:29is one observation government so that
  556. 21:30clearly also implies that
  557. 21:33if we
  558. 21:34say that other number is a valid
  559. 21:36candidate key that will mean that for
  560. 21:38admission to that
  561. 21:40university having other number would be
  562. 21:42mandatory if somebody does not have
  563. 21:43another number
  564. 21:45that will have to be null
  565. 21:46which is not allowed
  566. 21:50ok so lets
  567. 21:51move on
  568. 21:54so one of these candidate keys have to
  569. 21:58be made the primary keys let us say we
  570. 22:00make roll number the primary key
  571. 22:03and since we make roll number the
  572. 22:04primary key in the schema
  573. 22:07we underline the roll number attribute
  574. 22:09this would be a common way to show that
  575. 22:12roll number is a primary key
  576. 22:16so the others
  577. 22:18that are not taken as a primary key are
  578. 22:21called the secondary or alternate key so
  579. 22:23first name last name pair could be an
  580. 22:27alternate key other number could be an
  581. 22:30alternate key and so on
  582. 22:33a key is said to be simple if it
  583. 22:35consists of a single attribute
  584. 22:38so roll number is a simple key other
  585. 22:40number is a simple key if it were taken
  586. 22:42to be primary
  587. 22:44but first name last name pair if we take
  588. 22:46that to be a primary that will not be
  589. 22:48considered a symbol simple key because
  590. 22:50it has more than one attribute
  591. 22:54naturally the other if you have a sample
  592. 22:56key they have other side is a
  593. 22:59composite key a composite key is one
  594. 23:01which has more than one field
  595. 23:03such that
  596. 23:05none of those fields individually can
  597. 23:07act as a key
  598. 23:11but together
  599. 23:13they can act as a key so first name
  600. 23:15itself cannot be a key last name itself
  601. 23:17cannot be a key but together they can be
  602. 23:19a key of course under the assumption
  603. 23:21that
  604. 23:22those two students with the same first
  605. 23:24name last name are given admission
  606. 23:26so these are the different types of keys
  607. 23:28that can happen
  608. 23:30let us have some more
  609. 23:32views with the keys
  610. 23:34we extend the schema and besides the
  611. 23:37student i introduce two more schema
  612. 23:39one is called the courses
  613. 23:42which
  614. 23:43is
  615. 23:44given by course number course name
  616. 23:46credits
  617. 23:47ltp ltp is
  618. 23:49number of hours of lectures tutorials
  619. 23:51and practicals
  620. 23:52and the department so these are the
  621. 23:54different fields and
  622. 23:56from the
  623. 23:57convention already stated you can figure
  624. 24:00out that course number is the
  625. 24:02key primary key of this relation
  626. 24:06i use another schema which is enrollment
  627. 24:08which describes
  628. 24:10which student is attending which course
  629. 24:13so it has a role number and the course
  630. 24:15number
  631. 24:16so roll number of the student attending
  632. 24:18the particular course number
  633. 24:20and it also has the instructor id as to
  634. 24:22who is teaching that course
  635. 24:26given this as you can see that
  636. 24:29in
  637. 24:31in the enrollment relationship
  638. 24:33i have this pair roll number and course
  639. 24:36number
  640. 24:38which will certainly be the key for
  641. 24:40enrollment
  642. 24:42because if i have two rows in enrollment
  643. 24:45how they will be distinguished
  644. 24:47they cannot be distinguished by roll
  645. 24:48number
  646. 24:50because a particular student may take
  647. 24:52multiple courses
  648. 24:53so there will be multiple records having
  649. 24:55the same role number but different
  650. 24:56course number
  651. 24:59the course number by itself cannot be
  652. 25:00the key
  653. 25:01because every course will have multiple
  654. 25:04students so there will be multiple rows
  655. 25:06having the same course number but all
  656. 25:07different role numbers
  657. 25:09but if we take this together roll number
  658. 25:11and course number together then that
  659. 25:13forms a key
  660. 25:15now such a key
  661. 25:18such a key having roll number
  662. 25:21the roll number itself is a key of
  663. 25:24another relation
  664. 25:25the course number itself is a key of
  665. 25:28another relation
  666. 25:31so
  667. 25:32when we take
  668. 25:33the keys of other relations to form the
  669. 25:37key of a relation
  670. 25:39then we say that these are foreign keys
  671. 25:42so roll number and course number are
  672. 25:44foreign keys in student and course
  673. 25:47and
  674. 25:49since from enrollment the student and
  675. 25:52courses are being referenced are being
  676. 25:54referred so we say enrollment is a
  677. 25:57referencing relation
  678. 25:59and
  679. 26:00students and courses are the referenced
  680. 26:03relation
  681. 26:04and we will often like to also mention
  682. 26:08as to what is a foreign key of a
  683. 26:10relational schema
  684. 26:12because that will help us understand
  685. 26:15how the different schemas are
  686. 26:18interrelated
  687. 26:20and we will see that this will come out
  688. 26:22directly from the notion of entities and
  689. 26:26relationships of an er model of a er
  690. 26:29diagram
  691. 26:37a key is called to be said to be
  692. 26:39compound if it consists of more than one
  693. 26:41attribute to uniquely identify an entity
  694. 26:45occurrence so each attribute which makes
  695. 26:47up the key is a simple key in its own
  696. 26:49right
  697. 26:50mind you there is a subtle it sounds
  698. 26:53very similar
  699. 26:54we talked about composite key earlier we
  700. 26:57talked we are talking about compound key
  701. 26:59here
  702. 27:00the subtlety of the differences in a
  703. 27:01composite key every component attribute
  704. 27:04is not a simple key by itself
  705. 27:07but
  706. 27:08and the components come from the same
  707. 27:11table in a compound key the
  708. 27:14components are
  709. 27:16simple key by their in their own right
  710. 27:19in some other table
  711. 27:21and are put together as a compound key
  712. 27:23in the given table so
  713. 27:25the roll number course number in the
  714. 27:27enrollment table is a compound key
  715. 27:33so with this
  716. 27:34i would
  717. 27:36request you to spend some time with this
  718. 27:39relatively elaborated schema
  719. 27:42compared to what you have done already
  720. 27:44of the university database so every
  721. 27:48every rectangular box shows a relational
  722. 27:51schema
  723. 27:52on top
  724. 27:53of each
  725. 27:55in blue
  726. 27:56is written the name of that relation
  727. 27:58relational schema
  728. 28:00so it has a
  729. 28:02relational schema like
  730. 28:03courses
  731. 28:05the students
  732. 28:07the instructors
  733. 28:09the departments
  734. 28:11the prerequisites
  735. 28:14the time slots
  736. 28:16the classrooms and so on
  737. 28:19the sections
  738. 28:22and the relationships between them for
  739. 28:25example the relationship
  740. 28:27is takes is a relationship
  741. 28:32which relates students with
  742. 28:34different sections
  743. 28:36sections with courses
  744. 28:39teaches is another relationship which
  745. 28:41relates to instructors with sections so
  746. 28:45it is showing you directly as to
  747. 28:48how
  748. 28:49the
  749. 28:50keys of this what are the attributes
  750. 28:53what are the key attributes primary key
  751. 28:55attributes
  752. 28:56and also what are the foreign keys that
  753. 28:59we have in this for example in takes
  754. 29:02this
  755. 29:03is a foreign key which is featured here
  756. 29:07course id section id semester year are
  757. 29:11the foreign key part of the takes that
  758. 29:14exist here so please ah study
  759. 29:18the schema we will keep on regularly
  760. 29:20referring to the schema in future as
  761. 29:22well
  762. 29:23ah so this is what
  763. 29:25we have here
  764. 29:28now we move on to the relational query
  765. 29:30language we briefly talk about the
  766. 29:32relational query language now we will
  767. 29:35have to in this the key thing that we
  768. 29:37need to understand is ah the relational
  769. 29:41query language is
  770. 29:44somewhat different from the programming
  771. 29:46languages that you have studied so far
  772. 29:48which are procedural in nature
  773. 29:50in contrast the relational query
  774. 29:52language is non-procedure or declarative
  775. 29:55in nature
  776. 29:56a procedure programming language
  777. 29:58requires that the programmer tell the
  778. 30:00computer
  779. 30:01how to
  780. 30:03get the output
  781. 30:04given the input a pro program is about
  782. 30:07finding output for a given input
  783. 30:10and you write a procedure the sequence
  784. 30:12of steps that need to be done
  785. 30:14so that given the input you can compute
  786. 30:16the output so you say how
  787. 30:19the that computation has to happen and
  788. 30:21the programmer must know that algorithm
  789. 30:25in contrast in declarative programming
  790. 30:28you say what you want you do not say how
  791. 30:31that needs to be computed how that will
  792. 30:33be computed you may not even know that
  793. 30:36you may not even know a single algorithm
  794. 30:38to compute the output but you specify
  795. 30:40what output you need
  796. 30:42so this distinction between how and what
  797. 30:45of programming differentiates procedural
  798. 30:47and declarative programming so all that
  799. 30:50you have studied so far in terms of c c
  800. 30:52plus plus java python and all that are
  801. 30:55procedural programming where you
  802. 30:57necessarily have to specify how you will
  803. 31:00have necessarily have to specify what
  804. 31:02the algorithm is but in declarative you
  805. 31:05just say what you need
  806. 31:07so just a simple you know ah
  807. 31:10pathological example to understand this
  808. 31:12difference suppose we were interested in
  809. 31:14computing the square root of a number n
  810. 31:16assuming n is a positive number
  811. 31:18the procedural step could be something
  812. 31:20like this is an algorithm that you guess
  813. 31:22a an x naught which is a square root
  814. 31:25which is close to the root of n i mean
  815. 31:27ah some guess you make
  816. 31:29and then you repeatedly refine this
  817. 31:32estimate
  818. 31:33by
  819. 31:34taking the arithmetic mean of the
  820. 31:37estimate
  821. 31:38and the quotient of the
  822. 31:40division of n by this estimate so you
  823. 31:42take a arithmetic mean
  824. 31:44and find the new estimate
  825. 31:47and repeat the steps
  826. 31:49till
  827. 31:50you i mean as long as ah
  828. 31:53the difference between the two
  829. 31:54consecutive estimates is more than a
  830. 31:56certain value delta
  831. 31:58is a procedural one you are giving an
  832. 32:00algorithm so given n following this
  833. 32:01algorithm we will find the square root
  834. 32:04declaratively you can just say that ah
  835. 32:07what is the result i want i want a
  836. 32:09result m such that m square
  837. 32:11equals
  838. 32:12n so you are again
  839. 32:15asking for the same
  840. 32:16you are expecting the same output but
  841. 32:18the way you are saying is not an
  842. 32:20algorithm
  843. 32:21you are rather specifying a predicate
  844. 32:23which must be true in your output you
  845. 32:26are saying that the predicate is m
  846. 32:27square must be n so whatever m is
  847. 32:31that square of it must equal n so this
  848. 32:33style is known as declarative whereas
  849. 32:36the earlier style is known as procedural
  850. 32:38all query languages relational query
  851. 32:41languages are declarative in nature um
  852. 32:44we have talked about the pure languages
  853. 32:47ah are
  854. 32:48they are all equivalent we mentioned
  855. 32:50that earlier also and also again to
  856. 32:53remember that
  857. 32:54none of them are actually turing
  858. 32:57equivalent that means that not all
  859. 32:59algorithms can be expressed in
  860. 33:02them or specifically relational algebra
  861. 33:04which
  862. 33:05we will look at in more depth
  863. 33:08and
  864. 33:09the relational algebra will consist of
  865. 33:11six basic operations which we will
  866. 33:13discuss in the next module
  867. 33:16so to sum up we have introduced the
  868. 33:18notion of ah
  869. 33:20attributes and their types we have taken
  870. 33:22an overview of the mathematical
  871. 33:24structure of the relational model schema
  872. 33:27and instance we would say mathematically
  873. 33:29they are relations
  874. 33:31mathematically them in a mapping
  875. 33:33and we have introduced the very
  876. 33:36important concept of keys
  877. 33:39and in that
  878. 33:40very specifically what is a primary key
  879. 33:43as well as what is a foreign key
  880. 33:46in the next module we will discuss about
  881. 33:47the different operations of relational
  882. 33:50model relational algebra

About this transcript

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