YouTube2Text

Intermediate SQL/2 — Transcript

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

Full transcript

  1. 0:00[Music]
  2. 0:16welcome to module 10 of database
  3. 0:19management systems
  4. 0:20we have been discussing about
  5. 0:22intermediate level features in sql
  6. 0:26and this is the second and closing
  7. 0:28module on that
  8. 0:31so ah
  9. 0:32we have in the last module
  10. 0:35ah
  11. 0:37talked about join expressions views and
  12. 0:39ah transaction in a bit
  13. 0:41in this module we will try to ah learn
  14. 0:44sql expressions that are responsible for
  15. 0:48maintaining the integrity
  16. 0:50of the database ah we have talked about
  17. 0:52integrity a little we will now see how
  18. 0:54explicitly integrity can be checked and
  19. 0:56how different kinds of integrity can be
  20. 0:58ensured through sql
  21. 1:00we will
  22. 1:02also ah talk about more data types we
  23. 1:05have seen the basic primitive data types
  24. 1:07and we had
  25. 1:08promised that we will talk more about
  26. 1:10the data types including user defined
  27. 1:12data types here and finally we will talk
  28. 1:15about a very important aspect of
  29. 1:17authorization as to who can do what in a
  30. 1:20database in
  31. 1:22through sql
  32. 1:24so this is the module outline we start
  33. 1:27with the integrity constraints
  34. 1:29integrity constraints ah
  35. 1:31guard against
  36. 1:32accidental damage to the database that
  37. 1:34is there are certain real world facts
  38. 1:37that must be ensured in the database all
  39. 1:39the time
  40. 1:40for example ah
  41. 1:42in in bank accounts we have a minimum
  42. 1:44balance that need to be maintained
  43. 1:47for
  44. 1:48a particular
  45. 1:50customer we might want that the
  46. 1:52customer's phone number must be present
  47. 1:55we may have certain age bar in terms of
  48. 1:59entering
  49. 2:00into certain memberships or certain
  50. 2:02employment and so on all these kinds of
  51. 2:05real
  52. 2:06world constraints need to be represented
  53. 2:10and maintained in the database and that
  54. 2:12is the purpose of the integrity
  55. 2:14constraint
  56. 2:15and
  57. 2:16if we we will first look at the issues
  58. 2:19of integrity constraint for a single
  59. 2:20relation and
  60. 2:23we have seen
  61. 2:25the use of not null and primary key
  62. 2:28ah we will also talk about what is
  63. 2:30unique and we will see how
  64. 2:33actually general constraints can be
  65. 2:35checked in terms of a check clause with
  66. 2:37a predicate p
  67. 2:40so not null we had seen this before we
  68. 2:42can while creating the
  69. 2:44database table create table we can
  70. 2:46specify a field to be not null and then
  71. 2:48in that case null values will not be
  72. 2:50allowed in those fields so there must be
  73. 2:52some value given
  74. 2:55you can say one or more attributes to be
  75. 2:58unique if you specify them to be unique
  76. 3:01that means that in any instance of the
  77. 3:04table in future
  78. 3:07there cannot be two tuples which match
  79. 3:10in all of those attributes so if we say
  80. 3:12a one to a m are unique that means that
  81. 3:15if we have two
  82. 3:16different tuples in the table any time
  83. 3:18in future
  84. 3:19two different
  85. 3:21rows in the table t one and t two then
  86. 3:25across a one a two a m
  87. 3:27they must differ in at least one
  88. 3:30attribute value so uniqueness is a basic
  89. 3:34requirement for ah being a candidate
  90. 3:38key
  91. 3:38ah but they are still permitted to be
  92. 3:41null which in contrast to what is ah
  93. 3:44true for primary key you already know
  94. 3:46that primary key values cannot be null
  95. 3:48but uniqueness allows null values but
  96. 3:52they have to be different
  97. 3:56the check clause
  98. 3:58is
  99. 3:59where you
  100. 4:00say check and then you put a predicate
  101. 4:03so the idea is like this suppose i know
  102. 4:06that
  103. 4:07i have
  104. 4:08specified an attribute called semester
  105. 4:11it is a vercare 6 which means that it
  106. 4:13can have a
  107. 4:14string maximum of length 6 but naturally
  108. 4:17i can write anything there
  109. 4:19i can
  110. 4:20write morning in that
  111. 4:22field i can
  112. 4:24write welcome in that field and so on
  113. 4:26but those are not valid names of
  114. 4:28semesters so i want that
  115. 4:31in my design semester must have
  116. 4:35any of these
  117. 4:37ah values only
  118. 4:38so we say semester in so i have listed
  119. 4:42the values that are allowed in is a set
  120. 4:44membership so it says that the semester
  121. 4:46in so which means that the value of the
  122. 4:48semester is be one of these four
  123. 4:50and this whole thing
  124. 4:51this whole thing now becomes the
  125. 4:53predicate p
  126. 4:55which on which i do a check which means
  127. 4:57that whenever i am creating ah once we
  128. 5:00have created the table when i want to
  129. 5:02insert or update the values in the
  130. 5:05in the table the records in the table
  131. 5:07then e the value of semester has to be
  132. 5:10always within this otherwise the check
  133. 5:12integrity constraint will fail and the
  134. 5:15update or insert will not happen and an
  135. 5:18exception will be raised
  136. 5:20this is the basic idea of check
  137. 5:21constraints
  138. 5:23now let us move on to a
  139. 5:25more involved integrity check which goes
  140. 5:28beyond one table
  141. 5:30so let's suppose that we are talking
  142. 5:32about the instructor table we have the
  143. 5:35instructor table
  144. 5:37and instructor table has a department
  145. 5:41name
  146. 5:43similarly we have a department table
  147. 5:48department table which naturally has a
  148. 5:50department name now we know that this is
  149. 5:53the
  150. 5:54the key
  151. 5:55in the department table and therefore
  152. 5:57here it is a foreign key
  153. 5:59now
  154. 6:00while we are inserting records in the
  155. 6:02instructor table how do we guarantee
  156. 6:05that the record that we insert has a
  157. 6:07corresponding entry in the
  158. 6:11foreign key table that is reference
  159. 6:13table
  160. 6:15so it is when we are
  161. 6:17inserting an in
  162. 6:18a
  163. 6:19faculty in the saying that the faculty
  164. 6:22belongs to biology department there
  165. 6:24needs to be a biology entry in the
  166. 6:27department table as well
  167. 6:29so this is known as referential
  168. 6:31integrity that is once you refer from
  169. 6:34one table to the other
  170. 6:35that reference must also be a valid one
  171. 6:39otherwise your all your computations
  172. 6:41will go wrong
  173. 6:44so
  174. 6:45this is uh for saying it ah formally
  175. 6:48there are two relations and
  176. 6:50one relation as a primary key which is
  177. 6:52used in the other relation as a foreign
  178. 6:54key
  179. 6:55then there is a referential integrity
  180. 6:57that needs to be maintained
  181. 7:00so
  182. 7:01here we are just showing the effect of
  183. 7:03that so we have created a table
  184. 7:05this is the first one is what you have
  185. 7:08seen earlier creating the table course
  186. 7:11and that
  187. 7:12cable course needs the name of the
  188. 7:15department so we are specifying that it
  189. 7:17references the department table
  190. 7:20now if it references the department
  191. 7:22table it must ensure the
  192. 7:25referential integrity so this just says
  193. 7:28that
  194. 7:29this
  195. 7:30refers to the department table but i can
  196. 7:32be more specific to say
  197. 7:35what will happen
  198. 7:36if the integrity gets violated
  199. 7:39for example i have
  200. 7:42created this and the course
  201. 7:45table has an entry which has a
  202. 7:47department name say biology
  203. 7:50naturally biology department should have
  204. 7:53the entry there should be an entry in
  205. 7:56the
  206. 7:57department table
  207. 7:59with this ah department name biology for
  208. 8:02this to be valid now say for some reason
  209. 8:05ah the biology department is
  210. 8:08abolished and that particular record
  211. 8:10from the
  212. 8:12department table is removed naturally
  213. 8:15the course which is referring to
  214. 8:17biology in terms of its department name
  215. 8:20that particular record will become
  216. 8:22invalid
  217. 8:24so we can say that on delete what you
  218. 8:26should be doing
  219. 8:28one most common action that we specify
  220. 8:31in referential integrity is cascade that
  221. 8:35if the
  222. 8:36referred entity is deleted then the
  223. 8:38referring entity should also be deleted
  224. 8:40so if you delete the biology
  225. 8:43entry from the department table then all
  226. 8:46courses which have biology
  227. 8:49through references to department as
  228. 8:51their field value should also get
  229. 8:52deleted similar thing can
  230. 8:56be there on update also for example
  231. 8:59biology department
  232. 9:00say tomorrow changes the name to
  233. 9:02bioscience
  234. 9:04now if i have an
  235. 9:07referential integrity put on the course
  236. 9:10table as on update cascade then as i
  237. 9:13change the bioscience the name to
  238. 9:15bioscience all records in the
  239. 9:19table course which had the department
  240. 9:22name as biology will necessarily get
  241. 9:25updated so this is a way to maintain
  242. 9:29referential integrity cascading is is
  243. 9:32one of the most common way to handle
  244. 9:34this but there could be other ways to
  245. 9:38take action also there could be no
  246. 9:39action that you say ok i do not care let
  247. 9:42that happen in that case some
  248. 9:45because of the violation there could be
  249. 9:47some
  250. 9:48exceptions thrown or you can say that if
  251. 9:51this happens then i will set that field
  252. 9:52to null or i will set that field to some
  253. 9:54default value and so on
  254. 9:57so this is how the referential integrity
  255. 9:58has to be
  256. 10:00handled there could be integrity
  257. 10:02violation during transactions ah also
  258. 10:05this is an example of a
  259. 10:07self referential
  260. 10:09table which of persons which where every
  261. 10:12person's entry needs
  262. 10:14the name of the mother and the father
  263. 10:16which are also entries in this table so
  264. 10:19necessarily if you are entering a
  265. 10:20personal record you need these fields to
  266. 10:23be ah
  267. 10:25populated and that can be populated only
  268. 10:27if those records already exist so there
  269. 10:30is some order in which you have to enter
  270. 10:32the records or
  271. 10:33ah you have to set them as null and then
  272. 10:37update them in future and
  273. 10:39or
  274. 10:40some ways to say that well do not check
  275. 10:42this
  276. 10:44integrity now we will talk about this
  277. 10:46integrity at a later point of time so
  278. 10:48these are the issues that ah necessarily
  279. 10:50will have to be addressed
  280. 10:53ah let us move on and look at the sql
  281. 10:56data types and
  282. 10:58schemas so
  283. 11:00in addition to the data types like care
  284. 11:02where care ah
  285. 11:04int and all that you have an explicit
  286. 11:08date data type which
  287. 11:10ah gives you a
  288. 11:12year month date kind of ah format with a
  289. 11:15four digit year because date is very
  290. 11:17frequently required you have a time
  291. 11:20type ah to give you hour minute second
  292. 11:23time format
  293. 11:24ah
  294. 11:25you have a time stamp which is date and
  295. 11:28time together
  296. 11:29and you have what is known as interval
  297. 11:32where you can
  298. 11:34do a date or time difference between two
  299. 11:37different dates two different time to
  300. 11:39different time stamps and so on so these
  301. 11:42are the common added built in types
  302. 11:44which
  303. 11:45makes it very easy to handle the
  304. 11:48temporal aspects in sql queries
  305. 11:52in addition
  306. 11:54the next that you can do is you can
  307. 11:56create an index so let us
  308. 12:00look at this so this create table
  309. 12:03definition you understand
  310. 12:05well by now
  311. 12:06you can i can do this i can say create
  312. 12:09index
  313. 12:11and give a name for the index
  314. 12:13and specify which field on which
  315. 12:16the index should be created so here we
  316. 12:19are saying that the index should happen
  317. 12:22here
  318. 12:23this is the name of the relation this is
  319. 12:25the name of the attribute name of the
  320. 12:27field
  321. 12:28now this does not change any data
  322. 12:30neither does it change any schema but it
  323. 12:33creates certain
  324. 12:35additional structures so that it becomes
  325. 12:38easier to search
  326. 12:40this particular table using ids so if i
  327. 12:44have a query like this
  328. 12:46ah that i am trying to find out all
  329. 12:49information about a particular student
  330. 12:51then as we have said that by default the
  331. 12:56different entries the rows of a relation
  332. 12:58are unordered so the only way to find
  333. 13:01out this particular row and in fact
  334. 13:03whether it actually exist would be to go
  335. 13:06over all the relations one by one
  336. 13:09but if we index it then it creates some
  337. 13:12kind of a
  338. 13:13ah efficient data structure through
  339. 13:15which it can be
  340. 13:17searched out
  341. 13:18very efficiently very easily with the
  342. 13:20later ah
  343. 13:22module we will talk about indexing ah
  344. 13:24but just to give you the idea that this
  345. 13:27is similar to finding out a value in an
  346. 13:29unordered array if you are thinking of c
  347. 13:32in contrast i can
  348. 13:34we we all know that this can be done but
  349. 13:36takes a whole lot of time it takes order
  350. 13:38and time but
  351. 13:40i could
  352. 13:41keep those numbers in terms of a
  353. 13:45say some binary search tree balance
  354. 13:47binary search tree like red black tree
  355. 13:49or
  356. 13:51two three four tree kind of
  357. 13:53where the search can be conducted in a
  358. 13:55login time or i could keep it in terms
  359. 13:58of some efficient hashing mechanism
  360. 14:01where the search could happen in terms
  361. 14:02of an order one time also so indexing
  362. 14:05has a lot of
  363. 14:06importance and we will talk about that
  364. 14:09more but this is how you create index
  365. 14:12in sql
  366. 14:15you can have user defined types you can
  367. 14:17say create type and ah use ah
  368. 14:20some specific ah
  369. 14:23you know sub types of a type
  370. 14:25ah as and give it a name so its a
  371. 14:27numeric twelve
  372. 14:29so which is a 12 digit
  373. 14:31number with 2 decimal places of
  374. 14:35precision you can call it taller and
  375. 14:37then use that as a type name so type
  376. 14:40name
  377. 14:41doing this helps in two ways it makes
  378. 14:43sure that wherever you actually have to
  379. 14:45conceptually refer to dollars you are
  380. 14:47talking about dollar so its easier to
  381. 14:49understand and you are making sure that
  382. 14:51ah everywhere the same numeric precision
  383. 14:54is used
  384. 14:56you can also
  385. 14:57actually go further and
  386. 14:59create domains
  387. 15:01ah which is very similar to create type
  388. 15:03but domains are
  389. 15:05more powerful in the sense that in a
  390. 15:07domain you can also add
  391. 15:09constraints like not null and you say
  392. 15:12that this is person name so you say that
  393. 15:14this once you have
  394. 15:16said that
  395. 15:17this
  396. 15:18person name is 20 character long and it
  397. 15:21cannot be null then you do not
  398. 15:23specifically have to every time you
  399. 15:26define a field based on this domain type
  400. 15:29you do not have to specifically say that
  401. 15:31it is ah not null you could also create
  402. 15:34specific constraints in terms of the
  403. 15:36check clause and make it easier so now
  404. 15:40if you say degree level you do not have
  405. 15:41to put check clause explicitly in the
  406. 15:43sql query because it is already
  407. 15:46specified in the created domain sql
  408. 15:48supports certain large objects which
  409. 15:52are either called blobs if they are
  410. 15:53binary or called clob if they are
  411. 15:56character objects
  412. 15:57ah the only
  413. 15:58the major difference in terms of the
  414. 16:00large object types are they are not
  415. 16:02stored as a part of the table they are
  416. 16:04stored elsewhere and you actually
  417. 16:06maintain a
  418. 16:07kind of a reference a pointer to that
  419. 16:09large object
  420. 16:11so this is very useful in terms of
  421. 16:13handling photos videos and you know big
  422. 16:15binary files character files also
  423. 16:19let us
  424. 16:20move to authorization
  425. 16:22next
  426. 16:24authorization
  427. 16:25is
  428. 16:26the process by which you restrict
  429. 16:29different users to be able to do
  430. 16:32different kind of operations
  431. 16:34you would recall in the early ah
  432. 16:37modules on database
  433. 16:39overview we
  434. 16:41mentioned that there could be several
  435. 16:43types of users for a database there
  436. 16:45could be
  437. 16:46ah absolutely
  438. 16:48application users who
  439. 16:51necessarily do not feature as a part of
  440. 16:52the database development
  441. 16:54but there could be application
  442. 16:56developers ah expectedly most of you
  443. 16:58would become application developers ah
  444. 17:01there could be intermediate higher level
  445. 17:03of analysts who design databases design
  446. 17:06constraints ah decide on indexes and so
  447. 17:08on and that could be database
  448. 17:10administrators
  449. 17:11and also in terms of different
  450. 17:13application programs and programmers
  451. 17:16there is a need to separate out who can
  452. 17:19access which part of the database for
  453. 17:20example if you look at it at a banking
  454. 17:23system then
  455. 17:24while i am
  456. 17:27my net banking application is accessing
  457. 17:31different information about my account
  458. 17:33one part i need to ensure that i can
  459. 17:35only access my account
  460. 17:37and also what
  461. 17:38the database system needs to ensure
  462. 17:41is that a net banking application should
  463. 17:43in no way be able to access the
  464. 17:47information about the specific employees
  465. 17:49because in the same database information
  466. 17:52about the bank employees will also be
  467. 17:54there
  468. 17:54it should not be possible for
  469. 17:57possible to access the information about
  470. 17:59different ah
  471. 18:01physical information about the branches
  472. 18:03as to where
  473. 18:04ah how many square feet of area that
  474. 18:06branch has and so on so forth
  475. 18:09so we need to put variety of
  476. 18:11restrictions and
  477. 18:12as we will see that
  478. 18:14authorization or this process of
  479. 18:18restricting or allowing
  480. 18:20different
  481. 18:22access and different
  482. 18:23authority to operate
  483. 18:25is decided based on two different
  484. 18:28factors one is
  485. 18:30what you want to do
  486. 18:32and two is who wants to do that so what
  487. 18:34and who so we identify
  488. 18:37ah different
  489. 18:39operations or different operations on
  490. 18:42certain tables
  491. 18:44or operations on certain attributes as
  492. 18:47what needs to be done
  493. 18:50and on the other side we will identify
  494. 18:52who in terms of specific individual
  495. 18:55user ids
  496. 18:56or groups of user ids or roles that
  497. 19:00exist
  498. 19:01so here we will just try to show you how
  499. 19:03we can do that in in sql so the first
  500. 19:07part of the authorization is being able
  501. 19:09to
  502. 19:10ah
  503. 19:11do different things with the database
  504. 19:13that means the instances of the database
  505. 19:15so
  506. 19:16there are authorizations to read
  507. 19:18insert update and delete
  508. 19:20so read is where you can access the data
  509. 19:23but you cannot modify insert is when you
  510. 19:25can add new data but you
  511. 19:28do not with insert
  512. 19:30writes authorization you cannot
  513. 19:32update an existing data you can only
  514. 19:34insert data you can have
  515. 19:36update rights ah where we can change
  516. 19:38make modifications but you may not be
  517. 19:40you are not allowed to delete data and
  518. 19:43you can there could be a delete right
  519. 19:45where ah it allows you to delete data
  520. 19:48and mind you these authorizations are
  521. 19:50um
  522. 19:51not
  523. 19:53these are all independent authorization
  524. 19:55so you may have i mean certain
  525. 19:58authorizations may need certain other
  526. 20:00authorizations
  527. 20:01to be present for example if you are
  528. 20:03updating naturally you will need to read
  529. 20:06but
  530. 20:07it is these are all independent
  531. 20:09authorizations and you may have one or
  532. 20:12more of them to be able to do the
  533. 20:13appropriate actions
  534. 20:16similar set of
  535. 20:18another set of authorizations will exist
  536. 20:20if you want to for those who want to
  537. 20:22modify the database schema naturally ah
  538. 20:25this
  539. 20:25is primarily for the
  540. 20:28applications
  541. 20:30and
  542. 20:31application
  543. 20:32programmers and this primarily would be
  544. 20:36for the analysts
  545. 20:37that you can
  546. 20:39ah
  547. 20:40index the different table you can
  548. 20:43ah
  549. 20:43do
  550. 20:44you can have authorization for resources
  551. 20:47which mean you can create new relations
  552. 20:48create new schemas you can alter schemas
  553. 20:51you can drop schemas and so on so these
  554. 20:53are the different kinds of
  555. 20:54authorizations that are possible
  556. 20:57so let us see how it works the
  557. 20:59authorization is specified in terms of a
  558. 21:02statement called grant
  559. 21:04so you grant an authorization
  560. 21:07to a privilege list
  561. 21:10and on certain relation
  562. 21:15to a
  563. 21:16group of users so grant
  564. 21:20what you are what kind of authorization
  565. 21:22you are granting that is the previous
  566. 21:24list
  567. 21:25on what relation on view you are
  568. 21:27granting that
  569. 21:28is a on condition
  570. 21:30and to whom are you granting those
  571. 21:34so
  572. 21:40user list could be a specific user id or
  573. 21:43you could say public which in this case
  574. 21:45everybody will have that or this could
  575. 21:47be a role which will see what what a
  576. 21:49role is
  577. 21:51granting a privilege on a view does not
  578. 21:53imply granting any privileges on the
  579. 21:55underlying relation please mind this
  580. 21:59this one
  581. 22:00because
  582. 22:01you have seen that a view can be formed
  583. 22:03from multiple different relations so if
  584. 22:06somebody has been granted a
  585. 22:10a particular privilege say read
  586. 22:12privilege on a view
  587. 22:15then it does not mean that the
  588. 22:17corresponding underlying relation say
  589. 22:20you have been granted a
  590. 22:21read
  591. 22:22privilege on faculty relation that we
  592. 22:24faculty view that we did that does not
  593. 22:27mean that the user will automatically
  594. 22:29get a
  595. 22:31read privilege on the underlying
  596. 22:34instructure relation so that has to be
  597. 22:38kept in mind
  598. 22:40the granter of the privilege must
  599. 22:41already hold the privilege that is you
  600. 22:43cannot grant naturally grant will be
  601. 22:45done also by somebody in
  602. 22:47some of the users it may be
  603. 22:49so that user who is granting must also
  604. 22:53have the
  605. 22:54privilege same privilege on the specific
  606. 22:56item so you cannot grant privilege on
  607. 22:58some thing
  608. 23:00ah some relation or view on which you
  609. 23:03yourself do not have that or it has to
  610. 23:05be the database administrator who
  611. 23:07naturally has privilege for everything
  612. 23:11ah the privileges on sql there is a
  613. 23:14select privilege which is uh so you know
  614. 23:17this is a privilege list select
  615. 23:19privilege which basically means read
  616. 23:21access so it is saying select privilege
  617. 23:23as read access on instructor and these
  618. 23:26are the different users so this is how
  619. 23:28typically the
  620. 23:32you can have insert to ability to insert
  621. 23:35tuples
  622. 23:36the upload privilege this should be easy
  623. 23:38to understand now delete privilege so ah
  624. 23:41only thing is read is ah called select
  625. 23:44here so these are the different
  626. 23:45privileges that you have in sql and you
  627. 23:48have one all encompassing privilege
  628. 23:51which is called all privileges so there
  629. 23:53is a short form of allowing all these
  630. 23:55allowable privileges
  631. 23:58certainly if you can grant an
  632. 23:59authorization there needs to be a
  633. 24:02reverse process that is if you want to
  634. 24:04withdraw authorization
  635. 24:06of certain privileges
  636. 24:09on certain items for certain users so
  637. 24:12that is known as a revoked statement so
  638. 24:14you can revoke it the structure looks
  639. 24:17exactly similar to the grant so you
  640. 24:19revoke a privilege list select insert
  641. 24:22this kind of on certain relation and
  642. 24:24view from a set of users so you can say
  643. 24:28that revoke select on branch
  644. 24:30from this so once this is done then e1
  645. 24:34u2 and u3 will not be able to read the
  646. 24:36branch relation of the branch view
  647. 24:40the privileged list may be all to revoke
  648. 24:42all privileges so instead of
  649. 24:46revoking select insert separately you
  650. 24:48can just say all and revoke all of that
  651. 24:51the list of
  652. 24:52revokie can include public which means
  653. 24:56all users lose that privilege
  654. 24:59and
  655. 25:00or
  656. 25:01those who are granted if the same
  657. 25:03privilege is granted twice that is
  658. 25:05possible that
  659. 25:06a user gets a privilege granted to him
  660. 25:09or her
  661. 25:10by two different
  662. 25:13granting authorities
  663. 25:15then the if once is one of them is
  664. 25:19revoked the other will still continue to
  665. 25:21remain so
  666. 25:22every privilege that is granted
  667. 25:25needs to be explicitly revoked that's a
  668. 25:27basic meaning
  669. 25:29so all privileges that depend on the
  670. 25:31privilege being revoked are also revoked
  671. 25:33so some privilege which is dependent on
  672. 25:36some other privilege if
  673. 25:38ah if you if you revoke the update um
  674. 25:42privilege then the select privilege will
  675. 25:44remain
  676. 25:45but if you revoke the select privilege
  677. 25:48then if you also had the update
  678. 25:49privilege that will certainly get
  679. 25:51revoked because if you cannot
  680. 25:54read then naturally you cannot change
  681. 25:59the ah sql also allows you to create
  682. 26:02certain roles roles are kind of like
  683. 26:05virtual users so
  684. 26:06ah we all say that we all play certain
  685. 26:09roles so i have an entity as an
  686. 26:12individual say
  687. 26:13ah i may be a user called ppd
  688. 26:17but i have a role as an instructor
  689. 26:20i have a role
  690. 26:21as a
  691. 26:23say the head of the department i have a
  692. 26:25role
  693. 26:26as a chairman of a committee and so on
  694. 26:29so often times it becomes easier to
  695. 26:34grant
  696. 26:36privileges to different roles you do not
  697. 26:39really care
  698. 26:41immediately about
  699. 26:43who that individual could be who that
  700. 26:45particular user could be
  701. 26:47who
  702. 26:48has that
  703. 26:49privilege whoever
  704. 26:51plays that role gets that privilege
  705. 26:53whoever becomes the director of iit
  706. 26:55kharagpur has the privilege to
  707. 26:59appoint faculty members its of that kind
  708. 27:02it does not specifically so role is of
  709. 27:04that kind of a concept so you create
  710. 27:06role here we are saying that the role is
  711. 27:08ah
  712. 27:10a role instructor is created
  713. 27:12and then you are saying that you grant
  714. 27:14instructor to omit which says that
  715. 27:18amit now plays the role of instructors
  716. 27:20so any privilege that the instructor
  717. 27:23role has amit will enjoy that
  718. 27:27so let us see more of this
  719. 27:29the privileges can be grant to roles
  720. 27:32so earlier we said it could be public it
  721. 27:34could be users
  722. 27:35but now we are saying that it could be
  723. 27:37two roles so here this role was created
  724. 27:41and the privilege is being granted to
  725. 27:43that and since amit plays that role it
  726. 27:45will mean that um with this grant select
  727. 27:48on takes to instructor amit will
  728. 27:50actually get a privilege of select
  729. 27:54on text relation
  730. 27:56that is the kind of
  731. 27:58derived structure that roles give you
  732. 28:00roles can be granted to users as well as
  733. 28:02to other roles so roles are becoming
  734. 28:04like virtual users
  735. 28:06so you can
  736. 28:08create a role teaching assistant
  737. 28:10and
  738. 28:11grant
  739. 28:12teaching assistant to instructor which
  740. 28:14means
  741. 28:15that
  742. 28:16if you do that you are granting this so
  743. 28:19it means that any privilege the teaching
  744. 28:22assistant will have the instructor will
  745. 28:25get those privileges
  746. 28:26because you have
  747. 28:28made
  748. 28:29an instructor
  749. 28:31to also play the role teaching assistant
  750. 28:33mind new instructor itself is a virtual
  751. 28:35entity so if amit is an instructor
  752. 28:38by this
  753. 28:40then amit plays this role and this role
  754. 28:43plays teaching assistant role and this
  755. 28:45teaching assistant role has certain
  756. 28:46privileges so naturally
  757. 28:48through this chain process omit will get
  758. 28:51those privileges
  759. 28:53so in a instructor inherits all
  760. 28:55privileges of teaching assistant
  761. 29:00so this is what exactly what i was
  762. 29:01talking of we can have a chain of roles
  763. 29:04create a role dean new one we have
  764. 29:06created then grant instructed to dean
  765. 29:09grant dean to satoshi so which means
  766. 29:12that
  767. 29:13once you grant dean to instructor so
  768. 29:16anybody who plays the dean's role ah
  769. 29:19will get all privileges of instructor
  770. 29:22here you are saying that shatoshi is
  771. 29:25going to play the
  772. 29:27grand dean role so the satoshi in
  773. 29:31terms of chaining gets all the
  774. 29:33privileges that instructor has
  775. 29:40so once this has been done then you can
  776. 29:43have authorization on views as well so
  777. 29:46you have created a view here
  778. 29:48so this is a this is a view created the
  779. 29:52geo instructor the geology instructor
  780. 29:55and on that view particularly you have
  781. 29:57given
  782. 30:01the privilege to the jio staff
  783. 30:04so
  784. 30:05a geo staff member would be able to
  785. 30:08access this view and
  786. 30:12if
  787. 30:13this query is fired by a jio staff
  788. 30:17member
  789. 30:19which i am assuming is a role then this
  790. 30:23view will get executed and the results
  791. 30:26of all instructors in the department
  792. 30:28geology will be obtained
  793. 30:30but
  794. 30:31what if
  795. 30:34the jio staff does not have permission
  796. 30:36on instructor does not matter that is
  797. 30:39the beauty of the whole thing
  798. 30:41the geo staff may not have permission to
  799. 30:43do select on instructor
  800. 30:45but the jio staff has
  801. 30:48permission to
  802. 30:49select on jio instructor so
  803. 30:51the jio staff will be able to execute
  804. 30:55this view but the jio staff will not be
  805. 30:58able to do a select on
  806. 31:00from the instructor database instructor
  807. 31:03table
  808. 31:12there are several
  809. 31:13other authorization features the
  810. 31:15references privilege to create
  811. 31:18foreign key so we talked about the basic
  812. 31:21read write data manipulation privileges
  813. 31:24ah but there could be other privileges
  814. 31:26like whether you can create a foreign
  815. 31:29key
  816. 31:29whether you can transfer ah of privilege
  817. 31:33so
  818. 31:34whether you can
  819. 31:36give one privilege to the to another so
  820. 31:39they can cascade where they can restrict
  821. 31:41and so on
  822. 31:42so transfer of privileges is also
  823. 31:45privileged i mean actually you have to
  824. 31:47think of this is an authorization so
  825. 31:49actually what
  826. 31:50we can authorize is also a privilege
  827. 31:52that needs to be authorized
  828. 31:54so these are the derived privileges that
  829. 31:57are required
  830. 31:58so in summary ah we have
  831. 32:02learnt about
  832. 32:03sql expressions to deal with the
  833. 32:06integrity constraints
  834. 32:08we are familiarized with more data types
  835. 32:11ah particularly
  836. 32:13ah user defined types and domains
  837. 32:16creation of index
  838. 32:19and we have discussed about the
  839. 32:20authorization in sql each one of them
  840. 32:22particularly authorization has lot more
  841. 32:25details but
  842. 32:27at this intermediate level we just
  843. 32:28wanted to get a basic idea about
  844. 32:31authorization to be able to deal with
  845. 32:33that
  846. 32:34so with this we close our discussion on
  847. 32:37the intermediate level sql features
  848. 32:40in the next module
  849. 32:43that we start next week we will talk
  850. 32:45about some of the advanced sql features

About this transcript

This page contains the full transcript of Intermediate SQL/2 by Data Base Management System - IITKGP, generated from the public captions YouTube serves with the video. The transcript has 4,612 words across 850 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.