Dbms Quantum

You might also like

Download as pdf
Download as pdf
You are on page 1of 97
= QUANTUM Series Se * Topic-wise coverage of entire syllabus in Question-Answer form. + Short Questions (2 Marks) Scanned with CamScanner = CONTENTS KCS-501 : DATABASE MANAGEMENT SYSTEM UNIT-1 : INTRODUCTION (1-1 A to 1-33 A) Overview, Database System vs File System, Database System Concept and Architecture, Data Model Schema and Instances, Data Independence and Database Language and Interfaces, Data Definitions Language, DML, Overall Database Structure. Data Modeling Using the Entity Relationship Model: ER Model Concepts, Notation for ER Diagram, Mapping Constraints, Keys, Concepts of Super Key, Candidate Key, Primary Key, Generalization, Aggregation, Reduction of an ER Diagrams to Tables, Extended ER Model, Relationship of Higher Degree. UNIT-2 : RELATIONAL DATA MODEL (2-1A to 2-43 A) Relational Data Model Concepts, Integrity Constraints, Entity Integrity, Referential Integrity, Keys Constraints, Domain Constraints, Relational Algebra, Relational Calculus, Tuple and Domain Calculus. Introduction ‘on SQL: Characteristics of SQL, Advantage of SQL. SQI Data Type and Literals. Types of SQL Commands. SQL Operators and Their Procedure. Tables, Views and Indexes. Queries and Sub Queries. Aggregate Functions. Insert, Update and Delete Operations, Joins, Unions, Intersection, Minus, Cursors, Triggers, Procedures in SQL/PL SQL. UNIT-3 : DATA BASE DESIGN & NORMALIZATION (3-1 A to 3-19 A) Functional dependencies, normal forms, first, second, 8 third normal forms, BCNF, inclusion dependence, loss less join decompositions, normalization using FD, MVD, and JDs, alternative approaches to database design. UNIT-4: TRANSACTION PROCESSING CONCEPT (4-1 Ato 4-34 A) Transaction System, Testing of Serializability, Serializability of Schedules, Conflict & View Serializable Schedule, Recoverability, Recovery from Transaction Failures, Log Based Recovery, Checkpoints, Deadlock Handling. Distributed Database: Distributed Data Storage, Concurrency Control, Directory System. UNIT-5: CONCURRENCY CONTROL TECHNIQUES (5-1 Ato 5-27 A) Concurrency Control, Locking Techniques for Concurrency Control, , Time Stamping Protocols for Concurrency Control, Validation : Based Protocol, Multiple Granularity, Multi Version Schemes, Recovery with Concurrent Transaction, Case Study of Oracle. SHORT QUESTIONS (SQ-1 A to SQ-18 A) SOLVED PAPERS (2015-16 TO 2019-20) (SP-1 A to SP-15 A) Scanned with CamScanner Introduction veew, Dabs arth rare va file Soe . ime See Coe 4 sehema and 1-08 te 1210, vr epee teme Rertacn Data Detintion Parte: Panes 5 ee cy Henle Sel et Cones eaten BE ie Bagram: Spine Contes aan ep tees EASA § [euiee Enended ER el, " ane IA CSTTSems) L2ACSITSem5) Introduction Overvis, Database System ex File Syste, Database Syster Concept ond Architecture, Long Answer Type and Medium Answer Type Questions ‘QoeTT | What is database management eystem (DBMS) 7 What are the tasks performed by users in DBMS ? Taswer 1. Database management system (DBMS) i a sftware which i use to ‘manage the databuse For example MySQU, Oral, are commercial “database whichis usedin diferent appientons, 2 DBMS provides anintertceto perform various operations ike database eatin, storing data. updating data, cresting a table inthe databoce a le provides protection and security tothe database. tn cae of multiple erst also maintains data consisteney. DBMS allows users the following tasks + 1 Datadetintion:t is usd for creation, modification, and remoralof Astabase beets that define the organisation odatain the daahocs 2 Data updation tis used fr the the actual data ithe database Data retrieval: 1 is used ‘which ea be wed by applica 4 User administration Is wed fr rgistering and meitorag wen, ‘aaintining data integrity. enforcing data tocurty deco sek foncortency contre. monitoring performance asd Teceterieg information orruptedby unexpected fare [RAST T] Wont are the advantages and disadvantages of DBMS? ‘exertion, modifestion, nd deletion retrieve th dita from the database ns forvarows parpescs. Scanned with CamScanner anager SO ACEI, pis te autre er C8 Mag ig tip wer = ymin dette, socestemte ol mae a antapmt NC MLHN u SR Te Ae atten eh eat Tee om filter ay Racha: Mpa ta etree cata free Tigre dierent et eae Stain werfae inin program interac, rivera IS gare Tt 0c igh ped oy rare and sole trun DBMS software, a af ike and large memory t cea ae ne Bees or eeats a complet Toenerinnecottare patataeaptom eens atonal compen gg Data in most of pase is damaged due to electric failure op er stmt Pe sense tn ceeat types of tabave wsers- users? Describe ene ae meen i ee Pree No pone Ee Theyre the developers whointerat with the database by eat ea writen integrase inva " oI tenet de tocrmiet penis eae er s 2 nce deeper oho wre ne pervert » Ferm ett ame ‘like SQL. Tenant enti engin arn a ‘study SQL and DBMS to apply the concepts in requir Ioteadtion A. Speciallzrd users: ‘These are ls snphistieted wer, but they write peal database spiaton programs, 1h They are the developers who develop the complex progeams seording the requlerent 4. Standalone users ‘These users wll ave standalone datas fr thei pe 1b. These kinds of database wl have predefined databa : which wll ave menus aed graphs interfaces ‘hes ae the users who we the existing application to interact withthe database. orexample, online library system ticket booking ayers, ATs BeeTAT] Who are data administrators? What are the functions of database administrator ? Discus on the role of database administrator ‘aasweesl] Database administrators are the pertonnel's who has contol over dat and programs ued for accessing the data Punctionsrole of database administrator (DBA): 1. Schema definition: ‘Original database chemi defined by DBA. etapa by witg ase felon wich ap traelte comple toast flea that ar ferancely ‘are in the data detionary. 2 Storage structure and access method definition: | Thecreatin of appropriate storage structure and acces oethod, ‘This is accomplished by writing a ct of defiitions, which are translated by the data rage and defitiolaguage opr. Schema and physical organisation and modification ‘% Modiation ofthe database sehemnor the desertion phy storage organization, ‘Thee changes ar accomplished by writing ase of ein odo ‘motfeation tothe appropriate internal apstes tables, » Scanned with CamScanner i = Se ae vastraint apecifieation | DBA cya. a re faindictonary och a8 Fsnacooaergye™ dy GA] ne tron? itr autrection. Be ecsnwente rere ee tg i priate! [ieceatter] Fig LAL The tree levels dat etre 1 Physi eel ete et rt of entrctinsd dertoe kanal ed Denna ees thomgle lew vl dete sree inate 2 agate 1 celinelwte et hghrve of retin dt deren SErLinee sede uae seh en ooo 5 Terman tan res the entire data ‘satan civ aml soars 2 Went Ueto lefts it ere aie tes & Thevew inten eis impif ee nteraet “with the system: =e Tesyem may eid many views fr these ast LEACH Sem) Iniracton Na] Physieallevel | Conceptual” Logical level Tiss theme eel Jtevet" of date otdate teraction I ction interaction with [Ante system Itructore ef whe! [details of physical |intereste mn hides Jomptesity of Hutabace lin the difference between database management ‘system (DIM) and filesystem, to write the! of data that hides the detail L Lj | Scanned with CamScanner eG Datatuse Management Syste ERA(CMTSem : a Inraduction provide anions ike ‘The never side inp query processing aa he DIMS, lense apliention establishes “Tocommunictew Se [pee cena "fue be ose Sa] tenet [ei carci | iano et a mee niente nt etna te stem, cence | te ua ig |e hs my robes ie = ‘Socom tn or nme informe Cheat ding comer a re the types, arene DBMS design depends upon its architecture, The base client 1 The DOM octare i wed to deal witha large mambor of POs, web serve archon rervers another components that ae connected sith networks 2 DBMS architecture depends databace toget their equest done ‘Types of DEMS architecture i Tier architecture : 4 nthin architecture, the databases dell 2 Anychangos done are directly done onthe database itself It does ‘bot provide a handy tol for end users. ‘The 1Tier architecture is used for development of the loc poticlien, where programmers can directly communicate with the database for the quick response. AL. 2.Tier architecture: 1 The2-Tier architecture same asbasic client-server. 2 Inthe twotce architecture, applications on the client end Alivectly communicate withthe database atthe server side DBC, IDBC ae used: 2. The utr interfces and application programs are rus °® cliente, eae spon how users are connected tothe “Fle 182i archives fil, 2 Tier architecture : Thod-Ter architecture contin ante layer between the clon ne server: nts arctetre cet eanoot ety comamunieate “with the server. = . ‘The appieaton on the cliestend nteracta with an application ‘rei arher communtiies es End wer has noida ab he existence ofthe dab the application server. The database ; 188 ni saat other user beyond the application. _ aia ‘he Tie architectures ued incase of large web application. Database] " —T—_ | server Application server [Aveliation cet Clete — User Scanned with CamScanner 19a Cony, Sen, “) ind Instances, Data Independence ata Model Scher and Interfaces, Data Definition ‘putt, Overall Database Structure nat aredata models? Briley explain deren yy, on Data model soc bow the lopcal structure ofthe database eestor oe e fare processed and stored inside the system. ‘Type of data models 1. Batty relationship model aa ecatty relationship ER) model consists of a collection tae Rese elicdenttiesand of relationships among thes eating 1h. Ente are represented by means of their properties, eet oxi con Genes) Goad) i ty ‘Fig! 1.9.1. The BR model. 2 Rena nt ‘4 Terelatona mode represents data and relationships among by acallection of ables, each of which has @ numberof cles ith unique names 10A(C81T-Sem) Introduction ‘b_Relational data models used fr data storage and processing. This made isimple anit has al the properties and capabilities eqired to procns data with torage eines. A Micrnrchical model Tnbierochial model data elements are linked as an inverted tree rut root atthe top with ranches formed below) 1b. Below thesingl ot data element are subordinate elements each ttwhich in turn aw ite own subordinate elements and soon, he tree can grow to multpllevel Data clement ha parent eid relationship asin a tre. 4 Network model: 4 Thismodelis the estensionofhierarehieal data model ‘bh Inthismodalthereasta parent child elatonshp but ahi data ‘lement ean have more than one parent element or no parent at a 5 Object-oriented model a Objectoriented models were introduced to overcome the ‘shortcomings of conventional models lke relations, hierarchical And netvork made 'b Anobject oriented database icolectionofobeets whose behaviour, ‘tate, and relationships are defined in accordance with bject- ‘rented concepts euch as oiets, clase ete) ‘Quo TAO7] Describe data schema and instances. iw 1. The destription of «databace is led he database schema, which specited during database design and ie not expected to thange een 2 Mestfthe data modes have certain convention fr diplaying schema ‘as diagram whieh is called as schema diagram. * 3. Aschema diagram displays ony some aspect ofa schema, such asthe name of reord types an data tems ed some types of onstrate For example Schema diagram for stdeatinf database Student ame, Student nomber, Clas, Branch) Course Course name, Course number, Deparzent) Tastance 1. The dat in tho database atx partelar moment is called a database state or snapshot. Its also called the current set of cccurrentet instances inthe databace, Scanned with CamScanner 1A Conn, scema construct has its om gary cha ea anatase sate te eacan bo constrated 9 correspond ng, 4 Moy datas te er insert or lee areca gp ety eee eon tact ae a item in asin, dependence with te types. ‘pain at eww] eee esc nt ibe ‘Ton atdatanependenes: 1 Pht a the ability to modify int "ead iy erg Phase angi tbe conceal cher, 1. Tmateat te py eves ecasonly emai ne whee rertarmance Tectrtatheiennunityof the conceptual schema to ehange in poe ta Independence are reorgaaleatna cme of pia data inde 4 Ream ogame acer patho ifhng dense cal data independence: annie al datsnependence the ait onl the mead © TGhoma without having to change the external schemas Sines pera : 1k ttvtes tothe immunity ofthe external mde to change cco mde. Beals of lpia data independence are ates cote i] Deserite the classification of database language. Wit {ype of language ie SQL? on, ideus the following terme () DDL Command (ti) DSALcome== AA (CTT Sem 5) Introdetion 1 of database languages Definition Language (DDL + 4 DDL iraet of SQL commands used to databace stroturesbut not data, 1 Thesare ied by the DRA toaimited ‘orappliation developer. rate, mdi and dete extent, adatabase designer, Create, drop, alter, truncate are commonly wed DDL command, 2 Data Manipulation Language (DML) + 4 ADMLis language that enabos users to aceetor manipulates data as crazed by the appropeate date motel 1b There are two types of DMs Procedural DMLs:t requires a user to specify what data sare needed and how ogo those date, Declarative DMs (Non-procedural DML :I& requires 4 oer to speeify wha at how to et those data re needed without spelying Insert. update delete, query are commonly used DML commands, 3 Data Control Language (DCL) + a SQL. statement that contol acento data Commit rolfnek command are wed in DCL, 4 Data Query Language (DQL) & ‘View Definition Language (VDL): 1 DLinuedto pei wer views ad thir mapping occ defines the sbset of ecord avilable to asses of urs, ‘Revatevia tables andthe view oppearsto wert one leek 4. Tespeciten er intrtces SQLis DML language ‘Qe TART] Explain at database languages in detall with example Scanned with CamScanner nen aan te) _—STE Sent Intron ee 2 Forms-based interfaces ml HA, Ua ‘Arms based interfce payor to each wer ro 29.13.0611 ae ‘Database laneuaee ae 1b. Users can fill out all of the form entries to insert new data, or they : fant ny eran anche te Soa eee rene : p-HUNCATE,CONMENT, GRANT, rsteing dt ete aimee xn ALTER DADE THUNC "© a. eae uerinterteces GU Saco 4 AGUL apically displays a acera to the wen digrammatie form |% The user thencan specify a query by manipulating the diagram. In ‘many cases, CU ule both menus and forme 4. Natural language interfaces : | Anatural language intrface has its own schema, which sila to the database coneepual schema, at well as dictionary of Important words, The natural language interac refers to the words in ts achema, L aswel aot ete standard words inisticloae totes, erent & Hoe ntepetatin esc. he trace pert high: Creates view for dept 5 empl level query corresponding to the natural language request and ; Se. sums ft the DBMS for prcowig thence odo Syeitine mane dn de stared th the wer techie renea Eo Spirs deren Speech inpat and out eee The spec nati deteced wg rary of preindword “Seaton soduied ost up he pasar a pple oe sium 4, Facoutput.asimiar comers fom ator amine ees WTRE] erlaa DEMS interfaces, What are the various . Rest — Interfaces forthe DBA: 4 Mest data stm ota prveged commands that can be il tied ony byte DAY a interfaces :Adatbneonagement pte (DBMS) intrae 1 The isle commands fr cresting acount, eting eters Ser baie shich allo artealty to pot gene to a abo tamales, rating seeont sutbortaton aap eee ‘Tica ery page ele thdreorpaiing the storage strates ne ‘Various DBMS interface are: ‘GST ] riety deserbe the overall structure of DEMS. 1 Menurbased interfaces for web clients or browsing: o & Regine er ith keeles) Draw the eerste ot DMS and epi a ompoeate in that lead the user through the formulation ofa request. ca 1b Palldown menus ae avery popular technique in Web based set (RETO aie area] oN « ageing itera se asd__Atbv yem i prttned int motae tha del wih exch he through the contents ofa database in an exploratory ‘Teonsilitis ofthe everllsytem. The factional emiponte le ee ne * ‘system canbe broadly divided nto two components Scanned with CamScanner alleaton of space on dk storage ta ropeesen infreation stoned File manager It mange fe the data stractore are offer manoger sro ile for fetching data from disk idling what data tench ain ina ertieal part of the database “ntabacs ta handle data sees that ae tin memery ‘query Processor (QP) +The Query Processor (Gheey Opinion ia responsible for taking every statement sont to SGQuSSEIE ad igure ‘thr to atthe rqunstd dat pertinent tegen operating, The QP components ‘ADDL interpreter It interprets DDI. statements and ecorda the Aefsition i dat tionary DML compiler: t tarlates DML statements in query langage {oto an evaluation plan onssting flow lve intrtsna ta the ‘query evaluntion engine understand ‘Query optimization: It picks the lowest cost evaluation plan from among the alternatives Query evaluation engine : It executes lowlevel instructions svoeratedby the DML compiler. ee ‘Storage Manager (SM) : A storage manager is a program module se tee tee iene niet rece Emery mame: Key i ab cele ) manager Teenaures that the database rests Seer ce et ce =n & FRE ren mierrmann ncaa on ‘What are the notations of ER diagram? 7 nent relationship model (ER mode asap eroprsetig he cation ‘dhe latina ere tein noes aes Scanned with CamScanner Databace Management System LITA(CSIT Sem.) Elementwnotation of ER modeViagram : i Entity: a Anenttyisa 1b Anentty canbe abatrat €._ Anentity nan object that exists and is distingishabl from ether lect Entity set real word object that en be easily identifiable llection of similar typeof entities. ites with atrbute sharing sitar a Batity ets 1h Anentty set may contain ent wales. Attribute: a Analtribate gives the characteristics ofthe enti Teint called an datalement, dat eld fel data temo an eementary ter, Relationship: “A relationship is the association between entities fe entity bh telatioahip in represented by diamond with straight lines tontrting eee, ToeFAT | What do you understand by attributes and domain? Explai in various types of ateibuten used in conceptval data model, al Atteibutest Nurutes are propertion which ae used to represen the entities 2. All attributes have values For example, a student entity may have ‘ave, las ange ne ateribues, 4. Thereexsteadomainotrangetaluesthat canbe ascent atribtes 44 Forezanple,asudent a name cannot be a numeric valor. I has tobe ubete- Astudents age eanst be negative ete. Domain 1. Adumainis an atribute constraint which determines the typeof data ‘alues hat are poet fr that attribute 2. Attribute domaine ea be very large of very short. ‘Types of attributes used in conceptual data model: 1 ‘Simple ateibute Simple attnbutes are stoic values, which cannot ‘edivided further Por example, student's phone number isan atom value oft digits. IBA(CSMT-Sem5) raacasta 2 Componite attribute : Composite attributes are made of more than ertoplesttrbute For example, a students complete name raay have frt_rame and lastname Derived attribute: Derived attributes are the atrittes that do nat test nthe physical database, but ther values are derived from oth Sienbutes present in the database, For example, average salary io & dtpartsent shou ot be saved directly inthe database, ratendit ean tederived Single-value attribute Single-valu attributes contain single valur Forexample, Socal Securty Nomber & Maltivalue attribute: Multivalue aftributes may contain more than tre raluer. For example, a person can have more than ene PODS umber, email address, et HST] Wat purpose oh Ht Angra? Constr an Et Aingram rs University system which shold ich nto sitet periment ures wth seen {ecard in hich ure ich profs ar euhing wel ‘Shee enaon pron whlch ceertne Seputctsers Taewer | Purpose of the ER diagram : 2 1 ingame to tepeeet the overall pal trate of the 2 ER digrams emphasis onthe schema of the database and ot on the Instances because the aber of the database is changed rarely. 18 is useful to communicate the lgial structure of database to end serves aa documentation tn [ite the database designer in understanding he information a contained in the database, eee ER diagram: Scanned with CamScanner Databore Management Sites. AICSTTSem 5) FEETIR | Draw an ER dngram for small marketing company database, axsuming your own data require’ ‘the following entities (a) courses, including number, ttle, ‘pllabus and prerequisites; () course offerings, including course 1-20A(CSTTSem-5) umber, year. semester Eiansrootmy (el students, inelading rs ‘tnd (a) instructors, includ Separtmentandiitle Giuigrades awarded to students in each course they are enrolled formunt be appropriately modeled. Construct an ER diagram for the registrars office: Document all that you make jout the mapping constraints. Tarwer {a this ER dlagram, the main entity set are student, course course offering tedinstroctor The entity set course offering ia weak entity set dependent fn curse, The assumptions made are: fa Aclass meets only atone particular place and time. This ER diagram ‘anaot model clace meeting a different places a diferent times 1b. There ie a0 guarantee thatthe databace des not have two classes reeting atthe sume place and time. ame | ame aS Scanned with CamScanner Datatase Management Srstem) L 2 paenin the database must follow the constraints ‘Types of mapping constraint are: 1. Mapping cardinalitis ‘Mapping constraints act 83 1-21 A(CSTT Sem.) followed by contents of database specifies the number of carnaities or ardinaity aio) 3 caters edviaa relationship Cities which another entity can be assoc Sapping carinaities are used in describing binary relationship Maprinbough they contribat to the description of relationship Reta invalve more than two entity sts For binary relationship set R between entity sets A and B, the Eeping ceeinality must be on of te fellowing PP One to one : An entity in A is associated with at most one Sis in and an entity i B is asocited with at most one snutyina. Hk One tomany An entity in is asocated with any number sfenttes ia. Anentity in bowevercante associated with tt mest on ent in. {WL Many to one: An ent ini anociated with a ot oe ‘atity ind end n entity in B, however, cane asoited with Sry mumber entities ind 1-22 A(CSITSemS) fe Figs1213, Je Many oman :Anentty tanith an nan cotesnB nda nity in sated with ay Setiierind. eT ‘2 Participation constraints 1 tls the participation of. ono att at. “There are two types of participations : * {Partial participation 4 Totalparicipation [RST] isco the candidate hey, primary key, per ey, ey and aerate key. Scanned with CamScanner {at opton 123A C81T Sem) jane Management System BBACCSIT Sem) on ‘beplan he primary key, super key foreign key and eandidate hey ample. e (RRTUROTEIE: Mack To] Define key. Explain various types of Keys Taw] 1 Key isa attribute or staf attributes that is used to identity dat cenlty et, tion of rows in table, 2 Keyis defined for unique identification o Consider the fellowing example ofan Employee table EnployceEmployeeID,FullName, SSN, DeptID) Various typer of keys are 1. Primary hey: ‘Primary key uniquely Hlenties each recordin a table and must ‘vere the same for records, Here In Employee table we can ‘hace either EnployeelD oF SSN columns asa primary key, 1 Primary key acandidtehéy that ised for unique identifestion cfenttes within the table €Prinary key eannot be nul, 4 Anytable asa unique primary key, with a et of one oF mare attribute whose ‘combined value uniquely identifies the entity in the entity set. ‘bh Forexample: Herein employee table EmploycelD, FullName) or (EnployeeID,FullName, DeptD)is a super key. A Candidate key: 42 Acandiate key isacolumn, or st of column, inthe table that en ‘uniquely idestty any database record without referring to a8 ther dst. ‘Candidate key are individual columns ina tabe that qualifies fr ‘uniqueness ofall the rows. Herein Employee table EmployeeID sand SSN are candidate heys. © Minimal espe keysare called candidate keys 124A (CSIT Sem) 4 Composite key 4. Acomposite key is combination of two or more columns in a table that can be ed to uniquely identify each row inthe table 1 Teisused when weconnot identify a record using single atteibutes €Aprimary key that i made by the combination of more than one ‘Xinbate ie Known as acomponte hey 5 Alternate key: ‘© Thealternate key ofany table are those candidate keys which aro not currently selected asthe prsary Key. 'b Exactly one of those candidate keys ie chosen as the primary key and the remainders, ifany ae then called alternate keys. ‘© An alternate key is function of all candidate keys rninus the Primary bry Here in Employee table if EmployeetD i primary key then SSN ‘would be the alternate ke. Foreign key: ‘8 Foreign key represents the relationship between tables ensures the referential intogty rule 1A foreign key is derived fom the primary key ofthe name or some other table, © Foreign key isthe combination of one or more columns a table {paren table arefeencen primary Key ln another able eld table 4A oreign key valu canbe let nul For example: Consider another table Project (ProjectName, TimeDuration, EmployeelD) ‘& Here, the ‘Employec1D" in the ‘Project’ table paints to the ‘EmpioyeelD’ in Employee’ tabe ‘The EmploycelD’ inthe ‘Employee table the primary key. ‘The ‘Employee inthe Project’ table ina foreign key. [REST] wat do youmenn by she tothe relation? Papal the Aiterences between nape ey, candidate key and primary key, Rey: Refer Q. 1.22, Page 1-224, Unit-t. Scanned with CamScanner Database Management System Difference between super ke 125A CHIT Sem.5) candidate key and primary key: 1-26 A(CSIT-Sem5) pare SNa]__SuperKey | Candidate key Primary key Ta [Soper bey on [cana bey 0 [Serna eset [mini etfounet || Resbotenn ena [es | |e tots | Suse | Jaerinates ino |__| retatioa. TE [AM super Keys [Allendiateeys are [Rhett [super keys but not | cutee keys_| primary kes. ean be nal Primary key is a primis et of aterbutes that uniquely identifies rows ina relation. Primary key i= @ subset of candidate key and super ey, Teannot be nll ‘Nomber ofeandidate eysislesthan euper keys T | Ferenample in| Ferexample.in ‘Number of primary keys sles than candidate keys Forexample, in Fe Ee cara | he 122 pinay [eres aya yi tRagrtin) Srp, [epson eee oe tags, ose Sat [ ete. ants Gar CAR edad Make Pe 1 Ansty om rk {QuetaE] Hplain generalization, pecialization and aggregation. ‘Generalization is a process a which two lower level entities combine te form higher level entity. 1b Teisbottom op approach. © Generalization isused to emphasize the similarities among lower level cntty sets and to hide the diferences. fi > . Pig. 1344, Specialization: ‘Specialization it a process of breaking higher level entity ite lower 1b Wistep-down approach, © Itisoppesiveto generalization foresee 3) | i [Enpieres] Aggregation = 0 Regain an tration though wich ltionthpare re _ashigher level entities, aa famed med For stamp 1." Ta elatoship works on eating ety ets emplaye, branch and job) act as a higher-level entity set. oem 2 Wecan thenerestesbinaryrstinahip Manage between worsen And manager foresaw manage what aka Scanned with CamScanner LAT ACHTT Sem) Database Management Stern AAICHIT Sem 6) letretucton Tee TaET] Fxplain the reduction of EA achema ta tables. Kon > {weeh) on er ow to reduce an ER model into table? a 1 IER rnd. databaue are represented sing the diferent notations ot Aiagrame, and these wsttions ean be reduced to mellem of ables fe] 2 Tate dita ctery enor eaontipt can crt in tabular form gat: Reagan winerettem! Consider following ER diagram : T Tingnwaliratio,|Inepecalization,an | Aggregation is an Raseeealeato. (Chast higher level | abstraction through | BERET aooe | Si tbeoken dow | which relationships | [ESNSXESisa [itt two oF more | artreatedashigher [Se cect] enim [Aa | [Eke ie cee | nasa | eer ateti : i 12sec |Sacnai [Hae : cenit [ae [nacre a Ls Sr sin 5 2 participates in| spother relationship ONY Fl ‘| ibbpein redoing [Te increases the size | Tt also increases the theachema ste. [of schema, size of schema, ‘| iisapliedtogroup |Itcanbe applied toa | Tes applied to group Jotentiten | single entity, of relationshipe. 0° () Scanned with CamScanner A(CHIT 0m 4) atase Manag eatingrome fnto talon ire: bsnl column for the tabl I. koa? Course ID. Lecturer 1 te ee ah. 1 cere an colonia Usa tle fore ay, snest Name ad Student 1D frm thy Fad 1 Rice ty et sacchari rg| | "a =e tela tr asetaatt et a “All the ‘atributen repronented in the oval shape and und = a ante iagram nreconidred a1 key attribute which wet ang Stl oie Tameka, |_| ane Inthe given Edina, 8 Re, Pane ei uctarkey attribute of the Student, Course, Subject | | sa Lectarerentit. he multivalued utteibute fe reprenented by a aeparate table | [RaeTRET] Discuss extended ER (EER) model. on Steen Pa eats mepecsdonirereieeieeere cae ing bth the column, we creates I fame Student ID snd Hobby composite key 5 Composite attetbutes are merged into same table ax different ‘columns: a Inthe given BR diagram, student address isa composite attribute, Meontains City, Pi, Doe No, Street, and State, Inthe Student table these atteibutes can menge as an individual) g, column, i Derived attributes are not considered in the table: | ‘4 Inthe Student table, Age is the derived attribute \* 1, Heanbecalulated a any point of time by calculating the differen) hetween curreat date and Date of Birth (DoB). j 6 j | [ | | ‘The EER model includes all the concept of the original BR model together with the fllowing additional concepts: Specialization : Refer Q. 1.24, Page 1-268, Unit 1B Generalization : Refer. 1.24, Page -26A, Unit-1 © Aggregation : Refer Q. 1.24, Page 1-264, Unit ‘The super clase/subclass entity types (or super type subtype,entities) is one of the most important modelling constructs that i included in the EER model. ‘This feature enables us to model a general entity and then subivide into several specialized entity types (subclasses or subtypes) EERGdiagrams are used to capture business rules such as constraints in the super tspe/subtype relations. Thus, a super class is an entity type that includes distinct subelases that require tobe represented in ‘data model. ‘Asubelass isan entity type that has adistine role and is alsoa member ‘ofa super class. Scanned with CamScanner Database Management System, ISACCHIT Sem) ig. 1.261, aca aperclondeblas relationship ‘WeeTsT | What ie United Modeling Language 7 Explain different types of UML. Taner 1 Unie Modeling Language (UML isa standardized modeling language coablingevehiperstosped, visulize, construct and document artifocts| fa sofware stem. fL makes thee artifacts zalable, secure and robust in execution, LUML is an important aspect involved in object-oriented software development 44 Tt uses graphic notation to ereate visual models of software systems. ‘Types of UML: 1. Activity diagram 8 tisppeneray used to describe the fw of different activities and ‘These ean be both sequential and in paral Theyre theses el cenmmed dred on ete tndtherlstonstipbtwreninditees neg 2 Usecasedlagram 110 analyze tho syatem's high-Level - 2g gS erence acme Introduction 1-a2A(CSIT Ser 1h These requirements are expressed through different ase cases Interaction overview diagrar The interaction overview diagram isan activity diagram made of ferent interaction diagrams 4. Timing diagram. "Tuning UML diograma are used to represent the relations ofobjects irhen the enter of attention rete on time Eachindividval parejpant is represented through alifline, which {nvessentalyaline forming step since the individual participant {rannts from one stage to another ‘The main components of timing UML diagram are i Lifeline State timeline Hi Durationconstraint iv, ‘Time constraint vy. Destruction occurrence & Sequence UML diagram: ‘a Sequence diagrams describe the sequence of messages and interaction tht happen between actors and object. bb dctors or objects an be active only when needed or when another object wants to communicate with them. «. Allcommunieation s represented ina chronological manner. & Class diagram : ‘Class diagrams contain lates, alongside with ther atribtes(also referred to as data fields) and heir behaviours also referredtoas ‘member functions. More specifically, eachelasshasthree fields: theless name a the top, the elas attributes right below the name, the class operations! behaviours atthe bottom. . ‘Thorelation between diferent classes represented by aconnecting ling), makeup aelas diagram ‘VERY IMPORTANT QUESTIONS [Following questions are very important. These questions ‘may be asked in your SESSIONALS as well as UNIVERSITY EXAMINATION, Q.1, What is database management system ? ‘Ang, RoferQ. 11. Scanned with CamScanner Data Management SY a a0 as a ae ams as. ae at. as ane as. a alain the ser he simple eer 12 What is data abst action. Relar 18, he overalt structure of DEMS. hed De eter eter 13. eseribe the varioustypesof attributes ed in conceptual data model. Refer Q. 117 Whats ey’ Refer. Explain extended ER model 60 2 Relational Data Model te and Language CONTENTS Relational Date Model Concept, Integrity Constraints, Entity Integrity, Referential Integeity, eye Constraint, Domain Constraints Relational Algebt a encrnnssinnnscnsn BA to 3-10A 210A to 2-120 Relatioval Caleutus, Tuple ‘and Domain Caleulos 212A to 213A + Tatraduction oa SQL: Characteristics of SQL, ‘Advantage of SQL + SQL Date Type and Litera Types of SQL Command SQL Operators and their Procedure ‘Tables, Views and Indexes. Queries and Sub Querie + Aggregate Povetions, Insert, ‘Upsinte and Delete Operations eins, Union nena Taterseetions, Minus Garaors, Tigre, Procedures in SQU# DAA(CSIT Sem) Scanned with CamScanner BBA(CSTTSemS) Relational Data Model & La corr Se | PART : | tional Data Mal Cn Itty Constraints, Baa Inari, Refrenal Iris ' "Ginn Daan Constraint 2BAUCSTT Sem) Table 21.3: Depositor tale re | x | 43 [oa "Questions Answers Lang Answer Type and Medium Answer Type Questions — ae ie relational model? Explain with example, “Shariah dee seanterondcenstreyowutaiaa Istheprinary deta fr commercial data proceso oplcton Theresia mel sscltonoftalestoreprsent beth dat an thereatioshe monte data 4 Ech tablohae multiple columne and ech column haa unique ne Foresample 1. Thotabice represent asinple elton! database. 2 The Table 21.1 shows detail of bank customers, Table 21.2 shows ‘counts and Table2.13 showswhich accounts belong tevhisheustomer Table3.1.1:Custmer table [Testa [ename | ety C0] ay] Be ci | km | Sunt cits | Ak | Kottna Cio | Aca | Gata Table 22; Asante AM 1080 a 200 x3 3000 M 0 1 ‘TheTable 211, ce, customer tae sw the customer itentified by ist 1018 mased Ajay and ives in Deh 4. The Table 21.2.4, acount, shows that account A has balanee of 2 1000. 5. TheTablo2 L8.Le, depositor table showstha account mam (ac) {Act belongs to the cust whose cust id is C101 and account number in 102and likewise. (fee. nol Abalone tothe cust hive cst ‘Tee Explain constraints and its types, ‘Answer 1. Aconstrint isa ule that i wed for optimization purposes, (Consteuints forests tothe data or typeof data that ante inserted! ‘pdatedeleted froma table, A Thewtholepurpms of wnsteaints isto rmintin the data integrity daring anupdatldeletfincet into tae, ‘Types of constraints: 1. NOTNULL: 4 NOT NULL constraint makes sure that column dacs not hold NULL value 4 When wedo ot provide value or aprticuar slum while inserting arecordinta stable, taker NULL value by deal By specifying NULL constraint, we make sre that particular calumncannet have NULL valer wque values. | Macolumo hasaunique constraint, it means tht partie elumn cannot have duplicate valuesina table | DEFAULT: i TheDEFAULT constraint provides a default valvetoacolumn when there iso value provided while inserting a record into table. 4 CHECK: This constraint is used for specifying range ofvales fora particular column of table, Scanned with CamScanner AAICHTT Sem) ings macau items hy he value fling the specif as have th ro ied an ‘When thi constraint wi mon eae vvovaluce an cannat contain nul tthe beast hace ia Peer +e i e-reference between tables, 1h Tey act asa ers eere « nace acetal Bac eof data bed on it data He ptvalues of any other data type. i Thecolumn doe ot ace WeeES ] Esplin integrity constraints. Taweer | ety cstraints provde away of ensuring that change made tg © [Bitte by athoiaed ners donot result ina ons of date conten 2 fom fintegty oats with ER models they declarations :cersin trates form candidate ky forthe seyret 1 fermota ratonship spying crdinalitie 1, omany and soya 4. Anintegty constraint canbe any arbitrary pedis applied to he anal 4. nti contrints re wed to ensure accuracy nd co data eit ata BEEBAR] ott th otowing contrat: Entity integrity constraint iL Referential integrity constraint ‘ik Domain constraint 4 Eaty integrity constraint: TBs ttesthat note of primary key will ental > Database Management System PSA(CITTSem5) {a relation has anol value in the primary key attribute, then ‘uniqueness property af the primary key cannot be mantaived Inthe Tble24.1 SID is primary ey ad primary key cannot be Table241 BID [Name | Chase oementer) | gw ‘01 | Ankit Y 19 eon | San = a 3003] Soave o 2 Sour = 18 ‘i Referential integrity constraint: ‘This rule states that if fereign hey in Table 2.42 refer to the primary key of Table 243, then every value ofthe foreign Key a Table242mustbe nullorbesvallhe Table 243. Tobie 242, Forsin Kay ARE [ As [ON 1 [askt_[ 18 [0 2 [rates 30 [seavir [22 [144 — Not lowed as DNO 4 int STsswsth Aaa] Seed a pinay eye Tale 2.43, in Table242, BNO wa fen ey ened Relationship Table 243. fii Domain constraints Primary Key enaincotrints eiyhawhatat ofueantirbe tae aig ofeach ate xX mat nem an Scanned with CamScanner Relational Data co ea . et =~ arrency ete An atribte vay rte “ TEBE] Wat tection agsben? incase ba opr 1. Therelational geben sa procedural query lange 2 Means are of operations that take one or two relation touprodacee new ration av ent x L- Theoperatns inthe relational algebra are sect, pret Si Aiferece cartesian pact and renate asi relational algebra operations are as follows: 1 Select operation Theslect operation slot tuples that sates ane FO Select oeratinis denoted by signs € Thepeeiateappearsasa sobcript to. 4 Thearrunent relation sin parenthesis afte the & 3 Project operation S = eat 4 Te project operation is a unary operation thet ‘rpesestrelton with certain atribates left oot i nan 2AACSITSems) atabase Management System, ‘b_ Inpreject operation dupente ows are cliniated ce Projections denoted by pi), A. Setdifference operation: ‘The et difference operation denoted by (-)allows us toi tuples {hare in ne elation but are atin anther, ‘Theexpresson r= produces atelation containing hove uplein 4 Cartesian product operation : ‘The artesian product operation denoted by a roe (allows ws {scone fnformation fom aay two elations, The easton prouctofrelatione ry andro wlten sry xt & Rename operation ‘The rename operatr is donated by rh (0 Given lations algebra expression nae turn the eealtefexperaion E under the name ‘The rename operation ean be wed to rename a elation to get thesame relation under new name ‘The rename operation can be used to oltain a new relation with ‘new ames given tothe original attribute of eriginl relation at Panett atl B BEER] Consider the folowing rela Student teen, name, address, major) Course (coe, titled Registered san, coe) Use relational algebra to answer the following 1% Lit the codes of courses in which at least ons registered (registered coursen) List the tte of registered courses, List the codes of courses for which no student is registered. The ttle of courses for which no student is registered. Name of students and th titles of courses they registered to. ‘SSNs of studente who are registered for both databaneryntera and analysis of algorithms. ‘SSNs of students who are registered for both database systems and analysis of algorithms, ‘The name of students who are registered for both database systems and analysis of algorithms. 8 Scanned with CamScanner rettonal Data Mode & TAN guagy indents seed stents egiterd, ml eer) Spesceer! Oe tg ee istered >2(Ohie = Furth Cos) a delegates Sto’ Con) ‘Analysis of Algorithms’ Course) rf) ‘ fepstered))P2 COU) (Cour) ~ Fat vdvaCourse) b a Stents Reitred sth Student) ATH fanction ban Reiter) (St) Repserd) os ape nour St) operations in relational Wacba | What are the addition algebra? ‘Toe aditional operations ofreltions| algebra are: LSet intersection operation: : is nana return arelation that cotais ‘2 Setitersectioniadepoted by, and ret ‘pics latareinboth ofits argument relations, The et operation awrite as: roe=r-0-8) 2 Natural join operation + ~The natural jin is a binary operation that allows us to combine ‘rain elections and a cartesian product into one operation Its denoted by the join symbol D<. 1b The natural ein operation forms a cartesian product ofits tr arguments performs a selection forcing equality on those stributet that eppear in both relation rchemas and finally removes duplicate trates - DOACHITSem5) 2m division operators denctd by the eymbe (+). relation +sisa relation on schema RS. Atupletisinr +aitand 2 Bi ref two condition ad a tisintly 9 1b Forevery tuple ins, thee tuple, in satisiying bth of the following i 4isi=4s1 ie IR-SI ‘The division operation can be written in terms of fundamental operation as follows Pee Tyg ~My g lly g(X8)-Fy g g(r) 4 Assignment operation : The ansignment operation, denoted by =, stork ike assignment in a programming language. ‘GaeFE | Give the following queries in the relational algebra stubject(eode, lecturer) [What are the names of students enrolled in ¢s3020 7 Which subjects is Hector taking ? Who teaches cs1600? Who teaches 1500 or s302077 Who teaches at least two different subjects ? vi, What are the names of students in e+1500 or 3307? vi, What are the names of students in both es 1600 and ex1200? 5 Cty cel tent enllein)) 4 FlOsap tac St¥entO< enrolledin)) Herat « elect) ‘curate st dec lee) Forthisquery wehave to relat subjet titel Todiaambiqnte relation, we willeall the subject relation Rand’S “ eta « Shara Rite se D8 SI) “sed aiennstentondeneledaU (a(, st Saas ae: Scanned with CamScanner tatase Management System PALACCSTT-Sem-5) “aquery in TRC is expressed ae tyro -puat in itis the st ofall tuples ch that predicate Pis trac fort. The FRiliine ell essed to denote the value of tuple on attribute A and Pee sed to denote that tuple iin relation [tuple varialeis said tobe a ive variable unless i is quastifed by Formulae are built sing the atoms and the following rules An stomise ermal rmala, then are P, and (P) BER I, and P, are frmilae, then 40 are Pyv Py. Py ny 208 ASP 4. HP,G) is formate containing a fee tple variables and risa isha then eeriPjaliand v ser (Pyare lo forme ‘Domain Relational Calculus (DRC) : L [DRC aces doxain variables that take on values from an attributes Gonsie, rather than valoesforan entire tuple An expression in the DRC is ofthe form eee SBE fy. fe ose F Fepresent domain variable. P repeesents formula tempos of atone ‘Az stem in DRC has coe ofthe following farms (2 eriwhere isa elaticaonn attribctes ands, ‘re demain variables or domain constant. : 263, wheres and y are domain rarishle ond 9 a comparison petit (<=, #, >, 21 Tee attributes sand y mist have the emain thas ean be compared, © £8e.where xis domain variable, die a comparison cperator and is & constant in the domain of the attribute for which 7 is Gomais venatle Fotowng are the roles to bd up th forma: 2 Aseemisafrmala, BHP, iea formnlathen soin-P, © EP, sot Py ae frmila, then are Pv Py Py Peas Scanned with CamScanner aasacdsttsens) \ Tetional Data Model & Language UE Pya) ia formula in x, where x 8 # domain variable, then ‘3 qP a and VAP (x) ae ao formula, PART-4, Introduction on SQL: Character of SQ Advantage of SQ ae Questions Anrwern Tong Annee Type and Medium Answer Type Questions ee = WHeTIOT] Write short note on SQL. Explain various characteisticn ofsQl. Teen] ‘SQL stands for Structared Query Language. Its a non procedural language that can be used for retrieval and, ‘management of data stored in relational database Tear be wed for defining the strcture of date, modifying data inthe database and specising the security constraints. "The two major categories of SQL commands are: ‘8 Data Definition Language (DDL) : DDL provides commants that ean be ured to create, modify and delete database objects ‘Data Manipulation Language (DML : DML provides commands that ean be used to access and manipulate the data, that is, to ‘erie, insert, delete and update data in. database, Characteristis of SQL . 1 2 3 ‘SQL usages extremely exile It uses a freeform syntax that gives the user the ability to structure ‘SQL etatementa in away best suited to them. ‘Bach SQL request is parsed bythe RDBMS before execution, to check for proper eyntax and to optimize the request. Unlike certain programming languages, ther is no need to tart SQL ‘Matementh ia particular column or bo Bnised in sgl ine. The tame SQL request can be written in variety of way, are the advantages and disadvantages of SQL? Database Management System eines 1 Bae... ‘SQL, which makes it userdrendy anges & Standardised language: Due to decuments plato worwideto alls, Msn vide orm amount of dati ction, deletion, ma retrieved quickly niplationot data ‘Tota peg SESE Ir op SE te ere em 5 Interactive language : Easy t9 learn complex queries canbe recsvedineecmaa, ATPL newest Disadvantages of SQL: 1 Complex interface SQL bas dtl i nist ers uncomfortable whledealingwithtbedatsg at Efe Cost :Some versions ae eestly anid hence, o lan hence, programmers cannot access Partial control: Due to hen! sven tothe database, rules complete contro isnot PART-S SQL Dota Type and Literl i sans "SQL Operators hee Pata Didier hare i ‘Long Answer Type and Medium Answer Type Quelioad ee ‘Que 2.12. ] What are the different datatypes used in! SQL? =a] SQL supports flowing datatypes 1. char in): A fixed length character string with user epcied maximum ae seth charactor string with user specie Scanned with CamScanner petationa Data Model & Language ering with User specieg earace varchar) Aare et! 2 elena sersnninteyr wich i ite pede nt A al integer machi Sn me mere dA fied pit mo S emtetpignundd ti dis a ae jn and double precision Noating dole precision Posing i ol © ph otic wih ache dependent ree iads A loating point number with precision ofat east n digits, ao erm inecmanns yes ui month gt) 2aFy og fte month i dimer Te ine te dyin bors, inte and so subset ofthe integers that maching ie independent subset of integer with user defined precision 1, rtothe right ofthe decimal a QaeEAE] What ore the types of literal used in SQL. Taewer ‘The four kinds of tera valve supported in SQL. are 1. Charscter string: Character sttingaare written ata sequence ofeharacters enclosed inaingle quotes. bb Thesingle quote character represented within characte tring ty two ingle quotes. Far example, Computer Eng, Structured Query Language 2 Bitstring: A Abitstringia written either asa sequence of Os and Ixeneloced in ‘ingle quotes and preceded by the letter ‘or as a sequence of hexadecimal digit enlosed in single quotes and preceded by the eer 1 Forexampl,tF 1011011, BY, BU, XA), XT & Bxact numeric: 4 Theseliterals are written asa signed or unsigned decimal nursber osiby with decimal point. bs Porexample, 8, 80,99:00,0.9, + 99.93, 99 99, 4 Approximate numeric: Approximate numercliterals are written as exact numeri iteals {allowed by the letter‘; followed bya signed or unsigned integer, ' Forenample, 5E5, £5 5ES, + SSE-C, «SSE, OSSE, ~5.55E-0 sav agent Stem SGA LCT Sem) tl Mette aWtenest pe nang ease queda | Wont we Taw aren gps o SQL commands re pine - Jeet a corand i wed Lan toplesin table Syater: oor eto table name attribute, 2 Upiate: 1 Tlscommani ed tak hangs nb vasa Thetatle bh Ttusesot and whore clause Syntax Update able. name st atribute name = new value where condition; a Dele ‘4 Thiscommand is used to remove tuples, 'bTuples can be deleted feomonly one tabe ata time, Syntax : Delete from table_name where endition; 4. Select: This command in used to ot ‘ormore table Syntax Select attribute. attribute, fom table_name where condition; & Attertable: ‘8. This command is used tomake changes inthe structure of table b. This command is used & toaddan attribute fi todropan attribute torename an attribute ‘add and drop a constraint attribute, values (ralues ist); ciove asubset of tuples fom one Stee Aerie tte amen 2h el. so datatype, Aer bletale name drop roma cone Aer tahea se dep ctinene USSFAB5] Write w short note on SQL DDL commands, Scanned with CamScanner fpararetor parame fe arecratet using ‘i. os ened treate ae Fla 1 CREATE TARLE: Thiecowmand inwsed me Sarereapni 88 (CREATE TABLE ation.name mt ree ella datatype (20roy GER tay etd datatype ei =e Thstypeofcreatcomm et ra new table froma the structure of TE TABLE. AS! th structure a 2c Suondtocreatel exiting table ‘he generalis vata ofthis form i (CREATE TABLE elation name (Gel 8, fil) AS SELECT field field? FROM relation_name2: siractre of relations re changed using ALTER verb, 1 ALTER TABLE...ADD..:Thisisused toad some extra clu oan exiting able. The generalized format is ALTERTABLE relation name ADD (new field datatype sz, ew fel datatype it) ew ielda datatype (size); ALTER TABLE... MODIFY =: This form ‘vith swells datatype of existing relation ALTERTABLE relation name MODIFY feldi new datatype (size, field2 new datatype size), fielin new data type size); ‘Que 2.16] Draw an ER diagram of Hospital or Bank with show ion, Aggregation, Generalization. Aluo convert it® nal eehemas and SQ1.DDL. [ARTU 201716, Markell field rr tnngement System 5 pate Manage DITACHT Sem) teational schemas reek branch-name, branch-city, assets) irper customer name, customerstrect, cust cast tomer-cty, customer i srount aceount-number, Balance) ia) ne doan-number, amount) caplosee (employee-i, employee-name, tele samigent length, dependentnamey " “Pehemambe, start: date, asm (ayment-number, payment-amount,payment-date) ist aving-aecount (interest-rate) wt ‘Checking account (overdra-amount) Scanned with CamScanner ee etn Dae Mol Laneey pe Maroon’ tom, DAVACCHIT Sem) PABA ICHITem5) Unary operators {SQL of FR Angra: Se an aranchcy vacant a Aran rar ima —_—— beanehsame rr pater st gi momine )0807 88, an creatine, cna aca i cana yet vara (20) 7 pivnion cme kr + [eon - creat able an ‘ocrcer me am aaa same imay be, cnt ompone re af _— = Ccfocname ara ee | See mi Sega qrerh wy nin ard ag mma ‘Operator me 5 Ely vara 10% =n" Teel seuiepaynet— tomy i ( : ae crete por irr : ira uni mtr 10) ceo m Gretortan ropa sere date beh z Tethan repli onesie wurat (octubre ay, I Hone ‘Fie 317. Capa op, ‘a Oem ocaai seen tnegaermrtatenin cee ai pin set rr he ren er ciate everest: suber 38 [Operator Detinition =a = cme RD hear trick cope mates TERETE Derive the operators nd itn Ae mrntroe there arenes 5 G8 iret ter pe naa ees Re exes wv wed sopcrm easton =e rr i ead hem See en eas Ditterent types of BAL operstors ae: t 1 Atha eertey : third 2 reauenmonmem ® a oerrnts i rac, tsi, dvds aod negate data aloe i ‘Trea of thi exprenion ins razr vale, ‘Set operators Set operators cabinet ets of oe trent Scanned with CamScanner petationl Data Mode & Language = Defisiticn | ce ccrarmsal dance rom bthaverier | ENN sas cn on ete oth erg SET | Rearns evan ro ected by SES TL erat owe that are inthe Bet Bere pat est in second one RQOA(CSTTSemS)_ as | Somes rg BTA Son me the DBMS uses when evaluating Orn te eral DEMS Eggo Renate sae eee bh TheDEMS evauster 5 highest romnisoee st Sepanes Soe jecouriatenat aa Tei i || Prefix for bost variable Sa ee “Baxrounds stable or elon alias or itera text , aa fanagement System stave ena ALA CSITSems) Fi] What are the relational algebra operations supported Bogut Wetethe SQL satement foreach operation wel osc relational algebra operations: Refer Q 2.5, Page 2-64, Uni2 Jovetatement for relational algebra operations: {Select operation : Consider the oan relation, Joan loan_number, branch name, amount) Find ll the tuples in which the amount is more than 12000, then we Saou» 21088) : Project operation We writethe querytolistall the customer names andthelr cites as: 1, tear me cnuoe sy (CUBE) Set difference operation : We can find all customers of the bank ‘who have an account but nota loan by writing Thaetner tne (2PO8OE)~ Tappan (OTTO) io Greist ermal operator pede 4 cartesian product; We ave the folowing we als a ae | remove, sorrmammracricgs Ee | [ie] Nese] a es ae fo Character sseseaton | ae ee | wa} 2s aD “Tr fot conditions are rue sos Tbe on | Tre ifeither conditions are true | Aouilroo TEMION | Reerval ata rom both queria | INTERSECT | Returns only rows that match both queries | a late the « operation between [personnel x software ‘MINUS ‘Returns only row that do not match both queries Scanned with CamScanner we er) eationa Data Mode &Langagg 2-22 (CSITSem = Name + 10 a - 101 = a 5 Sur 2 103, Seal = = = 2 104 x 7 Ter mo 4 106 BB a ie cc 4 106 cc a © ner lation with tributes Title, Author, Year ap Ca etre nk elation ows "ops haar ten 28) me, rt te i nant te ea es PART-6 2 © Tables, Views and Indexes, Queries and Sub 3 TETATT ive th bret explanation of vow: 1 Alene ral slit, whe content are derived fo ot ing lan ont dosnt nee or 2 The contents of view are determined by executing a query based ‘ny rlaton and it doesnot form the part of database schema Each tine view in referted to, it contents are derived from tons on which it eased. sotto aes Manet PACTS) roe cone wel anyother latin at ceeding Silent tu Serre renee 6 feces SER Sateen te tcrrinec sa Ar Rt eee rug ah eo eemegeeet Sanne wt ASSELECT a nae ERE a au Fences Coiasa area ee Senne een tiga ata hans POitane ee om AS SELECT BOOK title, Category, Price, BOOK.P 1D, Pname, State FROM BOOK, PUBLISHER WHERE BOOKP_ID= PUBLISHER PID; ‘Gae2W,] Describe indexesin SQL. Taswer Inuexes are special lookup tables tha the database search engine ean ‘use tospeed updata retrieval Anindex helpst speed up SELECT queries and WHERE clauses, tit ‘ows down data input, withthe UPDATE and the INSERT atatenent Indexes can be created or dropped with no effect on the data, Indexes are used to retrieve data from the database more quickly. ‘The users cannot see the indexes they arejust used orp up archon ‘aueries, © Syntax: (CREATE INDEX index ON TABLE column; bere the index isthe name given to that index and TABLE i the name (ofthe table on which that index is ereated and column i the name of ‘hat column for which itis applied Unique indexes are used for the maintenance ofthe integrity ofthe ‘ata present in the table ax well as forthe fast performance; it doesnot allow multiple values to enter into the table Syntax for creating unique index is CREATE UNIQUE INDEX index name Scanned with CamScanner Felatonal Data Model & Language ON TABLE ctu: revere avin from the dat DROP INDEX index mae, FERRET] Baan ut query with enamels ietonary by wing the DROP INDEX gocy nest inside aarece 2°" Goren rust be ensaeed witin parenthedt ~- with tbe SELECT, INSERT, UPDATE, of Be SSS ae whee operator ike = 2535 1M, srighnthe WHERE clause ofanother SQL, SELECT acest ; Anders aim called a ioee query while th statement containing SERSSEG Seated an eter quer: Tpetaes query ences at efor ite parent query so thatthe result TSSSc Sate can te ceed to the outer query gyets of SQL peb-query :Arub-qury with the EN operator, SELECT estas sae FROM ile sanel WHERE hans same IN SELECT columa_name FROM ile sane? WHERE eatent Example: “We have the {owing tw tables ‘student’ and taarks' with common field rangement System pata Me 2ASACSTT Ses) Soconser arr te ‘Marks’ containing tot marks ofthe student nd scone ering both ables soe 2 je with sub cot sunt, aName,bTta marks sr Srowtstdent mak jydentID = bStudentID AND b Total, marks > wut ISELECT Total. marks ‘FROM marks WHERE StudeatID ="VOO2); query resul , BeedenetD | Ne ‘voor as Poel merke voor soaeeee | eeaTa : PART-7 “Aggregate Functions Insert Update and Delete Opertion. ‘Questions Answers ‘Long Answer Type and Medium Answer Type Questions ‘WEEE | Write ull relation operation in SQL. Explain any one otthen. Sate on = Marks Explain ageeyate function in Se TS eg [wr [ae ‘wot 05} | Lasts teveare many fl eatin operations ie =r = 5 1 imine deta = = = 4 Diplating in unin nection anddierence Sie : | Orenine ye ace —) [wou td | Acpeene hen ‘Now considering table Student’, we want to write a query to identify all Angregate function ‘deus who get more marks than the student whose StudentID is VOU2, ‘we dont know the marke of VON. ser 1. Agsregate functions are functions that take a collection of clues as ‘input and return a single value Scanned with CamScanner 226A (CTTSem 8) 2 SQhofters five built-in agaregate functions Average av Spats: ang ((Distinet [AIL m> ‘Purpose Returns average value of ignoring ml values, query: select agai rice ae Average Price” from books 16 Minimum in Syntax in (Distvet | AIL expe) ‘Parpose Returns ininum value of expression eample ‘Slo seleet nnit_prce.ae“Mininar Price” fr Output: Baample: Let us consider ‘output: Ninna Pace 30 ss Maxionum sans Syintay mas (f Ditinct | AML pe) Prpoe tetas maxim vahie of expres Baample: SQL> select maxlunit peo ae" Pree” from took; Outpt [Raine Pree] eo Distinet | AIL my Sah et unit pele aot Outputs i tational Date Model & Language System 227A(cenTems) Count ant ({ Distinet | All}, Spa tates the number foe reeves ber of roms where expr i not null Seale oun aN. of Bakar sa arose Neat Banke i Explainhow the GROUP BY clause in SQL works What, | Beeternce betwen WHERE and HAVINGlaae coca | GROUP BY: | EN HOUT BY was added to SQL tense geegte ection ike SUD | hath peoate al eta waves eer tine apa without the GROUP BY funtion i imo poste te Reston Tireachindisidual groupofeolumnvalyes Penns nthe su, ‘The syntax for the GROUP BY function SELECT columns, SUM column) FROM table GROUP BY column, ample: Ths"Sale Table: Troant ‘500 ‘00 700 And hie SQL. ELECT Company, SUMAmount) FROM Sales GROUP BY Company Return lowing result | Gompany mount 1S ~1B600 \ i 100 | i Scanned with CamScanner

You might also like