0% found this document useful (0 votes)
5 views

module-1(db)

The document outlines key concepts and topics related to Database Management Systems (DBMS), including data models, manipulation languages, and database design principles. It also includes previous year question papers from Punjab Technical University, covering various aspects of database architecture, query processing, and security. Additionally, it discusses advanced topics such as distributed databases and concurrency control techniques.

Uploaded by

dev.sangeeta9973
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views

module-1(db)

The document outlines key concepts and topics related to Database Management Systems (DBMS), including data models, manipulation languages, and database design principles. It also includes previous year question papers from Punjab Technical University, covering various aspects of database architecture, query processing, and security. Additionally, it discusses advanced topics such as distributed databases and concurrency control techniques.

Uploaded by

dev.sangeeta9973
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 43
MED Sy CTL On _ Datahase ] Management Syslsins ESC lati) SOLVED PREVIOUS YEAR QUESTION PAPERS amas ear LORDS MODEL TEST PAPERS (UNSOLVED) Nace haya EN ay att ee ee og a jab Technical University ~ Syllabus — Database system architecture Data Abstraction, Data Independence, D Manipulation_Language-(DME) dels; re Ged Data mods, modal, relétional and obja “Manipulation operations. ~ o1 Relational query languages Relational algebra, Tuple and domain relational calculus, SQL3, DDL and DML constructs, Open source and Commercial DBMS - MYSQL, ORACLE, DB2, SQL server. Relational database design: Domain and data dependency, Armstrong's axioms, Dependency preservation, Lossless design. Query processing and ‘optimization: Evaluation of relational algebra expressions, Query equivalence, Join strategies, Query optimization algorithms. Storage strategies, Indices, B-trees, hashing. Transaction_processing 1s Concurrency conitel, ACID property, Serializability of scheduling, Locking and timestamp based schedulers, Multi-version and optimistic Concurrency Control schemes, Database recovery. % Database Security + > . Authentication, Authorization and access control, DAC, MAC and RBAC models, Intrusion detection, SQL injection. a Advanced Topics Object oriented and object relational databases, Logical databases, Web databases, Distributed databases. 3 (DBMs) nn LORD) Database Management Systems ——— ne Management Systems: PUNJAB TECHNICAL UNIVERSITY QUESTION PAPERS | UNIVERSITY QUESTION PAPER, DEC.—2020 | SECTION bre Is Data Independence ? - Ans. Refer to Chapter No. 1 Q.No. 3 on Page No. 3 22 -tenne the term Entity. ns. Refer to Chapter No. 1 Q.No. 51 on Page No. 34 _ 8 3-Biferencs between relation calculus and relational algebra. ins. Refer to Chapter No. 2 Q.No. 42 on Page No. 75 ~ 94 What Is Transitive Dependency ? ‘Ans. Refetto Chapter No. 2 Q.No. 57 on Page No. 85 ) Q 5, Wiiat is Indexing ? abonte Chapter No. 3 Q.No. 5 on Page No. 90 - Explain briefly various kinds of privileges. ‘Ans. Refer to Chapter No. 5 Q.No. 17 on Page No. 141 Q 7, Wirt is shadow paging ? . iS. Refer to Chapter 4 Q.No. 35 on Page No. 126 poe tom is transaction ? ‘Ans. Refertp Chapter No. 4 Q.No. 2 on Page No. 98 "a scthy dtaace security is important ? ins. Refer to Chapter No. 5 Q.No. 18 on Page No. 141 Q 40-What is Locking ? ins. Refer to Chapter No. 4 Q.No. 12 on Page No. 103 SECTION - B Q 14+What are integrity constraints ? Why they are important 2 fis. Refer to Chapter No. 1_Q.No. 52 on Page No. 35 a1 fat is the purpose of normalization in DBMS ? ns. Refer to Chapter No. 2 Q.No. 21 on Page No. 50 Q 13. Discuss various concurrency control techniques. Ans. Refer to Chapter No. 4 Q.No. 14&15 on Page No. 1068107 ; _ Bc bigucs the importance of Authentication. 5 c Ens, Refer to Chapter No. 5 Q.No. 19 on Page No. 141 . Explain Distributed database with its advantages. ‘Ans. Refer to Chapter No. 6 Q.No. 33 on Page No. 166 [s] pems PUNJAB TECHNICAL UNIVERSITY QUESTION PAPERS UNIVERSITY QUESTION PAPER, DEC.—2020 SECTION -A _ gece is Data Independence ? Ans. Refer to Cha; ipter No. 1 Q.No. 3 on Page No. 3 Q 2-Détine the term Entity. 's. Fefer to Chapter No. 1 Q.No. 51 on Page No. 34 ifference between relation calculus and relational algebra. 's. Refer to Chapter No. 2 Q.No. 42 on Page No. 75 What is Transitive Dependency ? Ans. Referto Chapter No. 2 Q.No. 57 on Page No. 85 Q 5, Wifat is Indexing 7 S. Befer to Chapter No. 3 Q.No. 5 on Page No. 90 Explain briefly various’ kinds of privileges. ‘Ans. Refer to Chapter No. 5 Q.No. 17 on Page No. 141 Q 7 What is shadow paging ? . iS. Refer to Chapter 4 Q.No. 35 on Page No. 126 What is transaction 2 £ ns. Refertp Chapter No. 4 Q.No. 2 on Page No. 98 "aan ’ Q9-Why database security is important ? is. Refer to Chapter No. 5 Q.No. 18 on Page No. 144 - What is Locking ? ns. Refer to Chapter No. 4 Q.No. 12 on Page No. 103 : Q if i i SECTION -B Q 14-What are integrity constraints ? Why they are important ? ns. Refer to Chapter No. 1_Q.No. 52 on Page No. 35 Q1 is the purpose of normalization in DBMS ? i ns. Refer to Chapter No. 2 Q.No. 21 on Page No. 50 Q 13. Discuss various concurrency control techniques. ns. Refer, to Chapter No. 4 Q.No. 14&15 on Page No. 1068107 Q.44-Discuss the importance of Authentication. ins, Réfer to Chapter No. 5 Q.No. 19 on Page No. 141 6. Explain Distributed database with its advantages. ‘Ans. Refer to Chapter No. 6 Q.No. 33 on Page No. 166 5 Dems a SECTION - C (a) What is data model ? Explain Its types. a ols. jain various data mo o © Ex rfotor to Chaptor No. 1 Q.No. 35 on Page No paases to Chapter No. 1 Q.No. 35 on Pago No. Ww hing. Write note on has! 3 Refer to Chapter No. 3 Q.No. 14 on Page No. 94 ' vam ane What are Object-Orlented Databases ? Write its advan: ‘ages and Q.18. advantages. carat Refer to Chapter No. 6 Q.No. 13 on Page No. 149 UNIVERSITY QUESTION PAPER, AUGUST-2022 a 16. SECTION —-A Q }-tist two major disadvantages of file processing system. fis. Refer to Chapter No. 1 Q.No. 34 hat is data independence? . . ‘Ans, lefer to Chapter No. 1Q.No.3 - hat is meaning of functional dependence? . Ans. A lunctional dependency (FD) is a relationship between two attributes, typically petween the PK and other non-key attributes within a table. For any relation R. attribute Y is functionally dependent on attribute X (usually the PK), if for every valid instance of X, that value of X uniquely determines the value of Y. 7 ine view level In DBMS architecture. ns. This is the highest level in the three level architecture and closest to the user. It is” also known as the view level. The external level only'shows the relevant database content to the Users in the form of, views and hides the rest of the data. . (e) Detine the term DML. 5 se! ue a = 3 9 é g 2 3 9 $ 3 ‘Sequence pf actions such as commit are performed in a serial manner. efine checkpoint. thy wjeler to Chapter No. 4 Q.No. 26(2) (h) Whats" derived attribute 2 . A derived attribute as the name su ests is the one that i lated Hite pec erved at isutes me Guagests is can be derived or calculate tribe, | TM® 29e of the student can be calculated from data of the birth present as an attribute, () Explain cascading roll back. - If in a schedule, failure of one transaction caus: : ‘uses Several other dependent oc “Fer. ——ae other depend x LORDS Database Management Systems transactions to rollback of abort, th . ther cascading Rollback or cascading soo uc a Schedule is called as a cascading schedule or A) What are web databases? It simply leads to the wastage of CPU.time. Z © Ans. Refer to Chapter No. 6 Q.No. 41 : SECTION ~B Qa ompare and contrast file processing system and database management system. Ans. Refer to Chapter No. 1 Q.No. 34 Q.3-Befine Normalization. Explain 2NF and 3NF with the help of a suitable example. ins, Refer to Chapter No. 2 Q.No. 21 What is access control? Discuss DAC and MAC access control models. ‘Ans. Refer to Chapter No. 5 Q.No. 14 & 13. o a 5. Es hat are key constraints? Explain different types of key constraints using Ans. Refer to Chapter No. 1 Q.No. 52 Q 6. Explain the insert, update and delete statement of SQL with example? Ans. Refer to Chapter No. 2. Q.No. 51 SECTION-C _ hat is Concurrency Control? Explain the concept of concurrency control jestamp. Ans. Refer to Chapter No. 4 Q.No. 9 & 14 Q 8. Consider the following-elational schema in which an employee can work in more than one department. Employee (Emp_id : int, Emp_name:str, SALARY:real). Work (Emp_ID : int, DEPT_ID:int) Department (Dept_id:int, Dept_name:str, mgr_id:int floor_no:int) Write the following query by example (OBE) queries (a) Display the names of all employes who work on the 12th floor and earn less than 1NR 5,000. (b) Print the names of all managers who manage 2 or more department on the same floor. Ans. Refer to Chapter No. 1 Q.No. 48 Q 9. Write a short note on (a) Distributed databases. ins. ReteF to Chapter No. 6 Q.No. 33 (b) 0 phase locking protocol ins. Refer to Chapter No. 4 Q.No. 13 goa Rv wm Chapter 1 pata Abstraction, Data Independence, Data Definition Language (DDL), Data Manipulation anguage (DML), Data models : Entity-relationship model, network model, relational and object oriented Data models; integrity constraints, data manipulation operations. POINTS TO REMEMBER EA "Data : Itis a collection of rawsfacts and figure which is basic for decision making. Anything which is unorganized is‘called data. DataBase : A database is a collection of data which is organized in a way that allows for easy data retrieval and manipulation. * DataBase system : It is the way in which databases are arranged. DBMS : It is the software:component or logical tool to handle the databases. DBA : The DBA is the custodian of data and controller of data. Information : The processed form of data is called information: Knowledge : The information which contains wisdom is called knowledge. Data independence : The ability to modify a scheme definition in one level without affecting a scheme definition in a higher level is called data independence. Physcial Data independence : The ability to modify the physical scheme without causing application programs to be rewritten, Modification at this level are usefully to improve performance. Logical Data independence : The ability to modify the conceptual scheme without causing application programs to be rewritten. Usually done when logical structure of database is altered. Data Definition : A DBMS must define a structure for stored data and provide a means for auser - to define and organize their data within that structure. Data Retrieval : A DBMS must provide a toolset that allows a user to retrieve data stored in the database. Data integrity : Data integrity means the consistency and accuracy of data in the databas Inconsistency : The different copies of same data may have different values. Redundancy : Repetition of data in a database is called redundancy. Data base administrator : A group of persons with an overview of one or more databases who controls the design and use of these database. Schema : The plan or layout of the database is known as schema. Logical schema : The logical schema is concerned with exploiting the data structures offered by a DBMS in order to make scheme, understandable to the user. 1 Database System Architecture we e AR RRRRAHTD BR A BRRR HARRAH R aa LoD) Database Management Systems Physical Schema : The physical Schema is hidden beneath the logical schema and usualy be ot easily without affecting application. Soren The plan for aview is often called subschema, Data Model : Data model can be defined as an integrated collection of concepts for describing pad manipulating data, relationship between data and constraints on the data in an organisation Entity : Refers to real world objects which have some properties attachedtoit, ierarchical Model : Model in which data is organised in the form of parent child relationship, Network Model : Model in which records are connected to one another through a link. Relational Model : Model in which records are representedin the form of relations. Attributes : An attribute is a property that describes an entity. Relationship : Itis association among entities. One to one : Here each entity in X is associated with atmost one entity in Y. One of many : Here each entity in X is associated with many entities in Y but each entity ny is associated with one entity In X. < : Many of many : Here each entity in X is associated with atmost one entity in Y but each entity in Y is associated with many entities in X. Relation : Itis connection between two entities. ‘Tuple : Itis a row in the relation. Degree : Number of attributes or column in a relation. Cardinality : Number of tuplesin the relation. Tuple : A row of a relations calledtuple. = Domain : A set of values that an attribute is permitted to take. Primary key : Each relation must have an attribute that uniquely identifies each tuple. Secondary key : The key which is not giving the unique identification and have duplicate information. : Candidate Key : Combination of attribute that uniquely, identify an instance of an entity set. Atternative Key ; A candidate key which is not the primary key. Fofeign Key : The non key attribute which is a primary key of other table. Super key : If we add additional attributes to the primary key the resulting combination would still uniquely identify an instance of the entity'set. Query languages : Query languages are computer languages used to make queries into databases and information systems. : DML (Datamainpulation language): Some language that gives instructions to the programming language and other languages is called data manipulation language. DDL (Data Definition language): DBMS provide a facility known as DDL. DDL can be used to _ define conceptual schema and also give some details about how to implement this schema in the physical devices used to store the data. Structured Query Language (SQL): SQL is relational language through which user.can query data from the database. Normalization : Itis a process the taking data from a problem and reducing it to set of relations. First Normal Form : A relations is in 1NF If the values in the relations are atomic for every single attribute of the relation. F sierire MenEvETTISLLE 3 olations is In 2NF If and only If itis 1NI tribute js ully dependent on primary koy. es areca taeu cee aurea re Third Normal Form : A rolation A is in SNF If itis in 2NF and every non key attribute of Ris non transtivoly dependent on each candidate key of R. r® Functional Dependency : Attribute of B of a rolation Ris functionally dependent on attribute A ‘on Rll, at evory instant in timo, each value of A has no more than one value of B associated with {tin relation R. f» Boyce Code (BCNF) : A relations R is in BONF If it is in 3NF and every determinant is a candidate key. Fourth Normal form : A relation is in 4NF If itis in BCNF and there is no multivalued dependency inrelation. ‘Fifth Normal form : A table is in Fifth normal form if it cannot have a lossless decomposition info any number of smaller tables, © Denormalization : Denormalization involves adding redundant data to a normalized database to reduce certain types of problem with database queries that combine data from various tables into a single table. QUESTION-ANSWERS _-2rT- What is data inconsistency 2 = s (PTU, Dec. 2006) ‘Ans. Due to redundancy, the values of two entities differ from each other that is one of the values is updated and the other ofte has not been updated. This leads to inconsistency of data. With the use of DBMS, It is.possible to reduce the redundancy. Onée the redundancy is controlled or removed, the data will always be in consistent state. . What is data redundancy ? (PTU, May 2008 ; Dec. 2007) ‘Ans. When same information is stored at multiple places, this duplication of data is called as Data redundancy and because of this, inconsistency may occur which means the value of an attribute is differerent at different places. It the database approach, the centralized control of data by the DBA avoid unnecessary duplication of data and effectively reduces the total amount of data storage required. - What is data Independence ? > (PTU, May 2019 ; Dec. 2020, 2018, 2007) ‘Ans. Data independence is defined as the capability to change the schema at one level-of database system without having to change the schema at the next higher level. . 1. Physical Data Independence : Itis the capability to change internal schema without having to change conceptual schema. a 2. Logical Data Independence : It is the capability to change conceptual schema without having to change the external schema. - What do you mean by database schema ? Ans. The overall design of database is called database schema. Three schema are there: : () Physical schema : Physical schema is the schema that describes the database design at Physical level. (il) Logical Schema : Logical schema is the schema that describes the database design at logical level. at (PTU, Dec. 2014) = LORDS Database Management Sy, q ery Sub schema : Sub schema is the schema that describes the database design at Sitforan, Concertuat Conceptual level q Prysical ‘Stored Database | Physical levelintemal level Architecture of DBMS Q 5. Whatis the difference between the file processing system and database system, Ans. File processing system : File processing systems a collection of application Programs ‘that performs services for the end users such as the production of reports. Each program defines and manages is own data. There is a significant amount of data, redundancy in file based. Systems. To become more effective, a new approach was required what emerged were the database and DBMs. Database system : Database system overcomes the disadvantages of file oriented system, Database system fs 2 tool that simplifies the task of managing the data and extracting useful information in 2 timely fashion. They eliminates problems related with data redundancy and data Control by Svoporting an integrated and centralised data structure. Data are controlled via data’ dictionary system which itself is controlled by DBA. Q6. Define ER diagram with the help of an example? * data is stored. Tee > Ceearany Hospital patabase System Architecture 5 Ser lower level entity to make further higher level entity. Account 's Bottom up A ‘Approach sore] coon | Specialisation : Specialisation is opposite to generalization. Itis a top down approach in which one higher level entity can be broken down Into two lower level entity. In specialization, some higher jevel entities may not have lower level entity sets at all. : Student é 2 | ep up a process d Is A Ex-student] ‘Current student Q8.What do you mean by relationship 7 Explain different types of relationship? Ans. Relationship : Relationship is the association among entities. It Is represented by a diamond symbol in ER diagram. The attributes which represents properties of relation and listed next tothe relation. For e.g. : Relationship between teacher and class. Teacher teaches class. Class is assigned to a teacher. Teacher Class Enti Attribut Teacher 1D, Name, Address, DOJ Class Class, Section, Roomno, Capacity Several relationships may exist between the same entities. For e.g. : Employee works in and manages a department of a Sompany. Depariment Degree of Relationship : Degree of relationship refors to the number and participating entity types ina relationship. Itis number of entities associated or participants In a relationship. LOAD) Vatavads MarayeIMent Sten, 2 three degrees of relationships ; i : 1 Reearalve Relatlonship : Its relationship between the instances of a single oritity typ. entity ype is assosiated more than once in different roles. These are also called unary relationship 4 2, Binary relationship : It is relationship between instance of two entities... : 3. Ternary Relationship :Itis an association among three entities and its degree of relationshiy . oe cardinalty (Connectivity) of « relationship : The connectivity of a relationship describes 4 constraint on the mapping of the associated entity occurances in the relationship, Values for occurances are elther one or many. There are three basic constructs of connectivity for binary relationship. (i) One to one (1: 1) (i) One to many (1: N) ii) Many to Many (N : N) ae one to-one (1: 1) : A mapping R from X to Y is one to one to one If each entity in X is associated with at most one entity in Y-and viceversa. (ee <{ One to Many (1:N) : A mapping R from X to Y Is one to many if each entity in X is associated with many entities in Y but each entity in Y is. associated with one entity in X. : 5S) Many to one mapping (N:1) : A mapping R from X to Y is many to one if each entity in X is associated with atmost one entity in Y but each entity in Y is associated with many entities in X. g» Il Y Many to Many mapping : A mapping R from X to Y Is many to many if each entity from X is. associated with many entities in Y and one entity in.Y Is associated with many entities in X. mavagemen petite In briet about RDBMS 7 RadDk ono dotoboy stim +" (PTU, May 2014) ‘Ans. Any DBMS that uses the relational data model for data storage and modelling is called RDBMS. In RDBMS vie can create relations aiviong tabies.and can access the information from tables while table Is stored in separate file and may or may not have identical structures. The RDBMS 's based upon the rules given by Dr. Codd known as Dr. Codd's Rules. @ 10. Explain the differences between a weak entity and a strong entity. Ans. An oniity set that does not possess sulficient attributes to form a primary key is called a weak entity set one that dos have a primary key is called a strong entity set. For example : The entity set transaction has attributes transaction number, date and amount. Ditfereht transactions on different accounts could share the same number, These are not sufficioot to X patabase System Architecture form @ entity: primary key. Thus transaction Is weak entity set Member of a weak entity set is a subordinate entity. @ 11, Distinguish between RDBMS and DBMS. Ans. 7 . Member of strong entity set is a dominant RDBMS DBMS Tt stands for relational database | 1. It stands for database management management system system. ROBMS can maintain many user at same | 2. time. It have relational data integrity. 3. It is client/server based application. It | 4. means we use RDBMS with visual basic. DBMS can not maintain many users at same time Ithave no relational data integrity. It do not support client/server based application. diagram Notions. uss the varlous symbols used In ER dlagram. oe (PTU, May 2009, 2007 ; Dec. 2005) ‘Symbol Meaning Entity Type . Relationship Type — Attribute ———=> Key Aitribute Peainany Kor) —<—_> Muttivalued Atrribute Composite Attribute ~ LOD) Database Management Sy, 2 ——+ : )) Derived Atrribute | icipation of E2in R | ans E, Total Participation Le] E, ; Database Management Systems ii) ig non procedural w SL psec ‘a rango of usos and usors DBA's application programmos, managomon, and end users can use SQL. (iv) it provides commands for the following tasks : © Querying data 2 Inserting, updating and deleting data. 0 Creating, modifying and deleting database objects. . Controlling access to the database and databaso objects. Guamteeing database consistency. , Q Monitoring database performance and Configuration. Q 20. What Is the difference between Delete and Drop ? ; Ans. DROP is a DDL statement as’it is used to delete an entire table along with its structure whereas Delete is a DML statement as it is used to delete all or some specific rows of the table, 921, What Is BCNE ? (PTU, May 2018 ; Dec. 2015) ‘Ans. Boyce-codd normal form (BCNF) is based on functional dependencies that takes into account all candiate keys in a relation. A relation is in BCNF, If and only if, every determinant is a candidate key. To test whether a relation is in BCNF, we identify all the determinants and make sure that they are candidate keys. The difference between BNF and BCNF is that for a functional dependency A-B, SNF allows this dependency in a relation if B is a primary key attribute and A is'not a candidate key wheras BCNF insists that for this dependency to remain in a relation. A must have a condidate key. Therefore, Boyce-codd normal form isa stronger form of SNF such that every relation in BCNFis also in SNF. However, a rélation in SNF is not necessarily In BCNF. . _opWnet are multivalued dependencies ? (PTU, May 2017, 2016) ni Attributes B has a.mulivalued dependency on attribute A if for each value of attribute A there are more than one values of attribute B. It is denoted as A+ 3B § Example: Relation: Person Name Mobile no ‘Alay ‘92539-56331 Amit 81467-23995 Sumit 98872-95608 Sumit 81724-99558 In the above table, Sumit has two mobile members which means that there are more than one values of attribute mobile no for each value of altribute name. Q 23. Define normalization ? Ans. Normalization is a technique used for designing Relational database tables to minimize duplication of information and thus increasing logical consistency. Norrnalization means to represent the database design in a normal form. A normal form represents a good database design. A relational table is said to be in a particular normal form if it satisfies a certain set of constraints. It is used to eliminate various amomalies and in consistencies. Thére are basically three types of anamolies from where a database may suffer. 1, Update Anomaly 2. Delete Anomaly 3. Insert Anomaly patabase System Architecture Normalization is used to eliminate the above anomalies. The process of norm: be broken down into several steps : (a) Eliminate repeating groups : Make a separate table for each set of related attributes and give each table a primary key. (©) Eliminate redundant data : If an attribute depends on oniy part of a multivalued key, remove it to a separate table, () Ellminate column not dependent on the key : If attributes do not contribute to.a description of the key, move them to a separate table. Q 24, What are the weaknesses of SQL ? (PTU, Dec. 2015 ; May 2014) Ans. The major weakness of SQL is its rudimentary user interface. It has no provision for formatting screens and reports. It accept command lines from the keyboard and send retrieved values tothe keyboard, 25, Is a relation with 5 rows and R2 is a relation with 3 rows, how many will the cartes Product of R1 and R2. have. 5 (PTU, May 2014) Ans. Ri =5 rows R2 =3 rows - RIXR2.=15 rows. i 2 ° Q26. What does COUNT function do In SQL. (PTU, May 2014) Ans. The count function returns the total number of NOTNULL values in a set of records. Null values are not counted unless count(*) is used, which counts the total number of rows in the table. Syntax Count ([Distinc/ALL] columnname)) Eg. SQL > Select couint (*), Count (Comm), Count (Distinct Deptno) from emp. ‘on execution, the result will be * Count ") counts the total number of rows, count (comm) counts the non-null values for COMM Column and COUNT (DISTINCT DEPT NO) counts the distinct values of the Deptne column. .027, What are the varlous functions of DBA ? (PTU, May 2017) Ans, Database Administrator (DBA) is a technical person who implements the data administrator Policies. Ho is responsible for authorizing access, monitoring database Use, providing satistactory response time, backups and recovery from failure. DBA Is the person or group of persons responsible for overall control of the database system. : Functions and Responsibilities of DBA : Following aié some important functions and responsibilties of DBA: (V) Data Dictionary management : Management and control of data dictionary Is an important activily performed by DBA. In this contoxt, DBA creates the data definition, data validation rules, Gefines user access, documentation of data cctionary, creation and distribution of informational reports from the data dictionary. All) Database Design : DBA performs the duty of database dosign at conceptual level and intemal level. He plays an advisory role forthe external level. On the basis of enter prise's requirements, DBA creates the conceptual design that consists of all the entities attributes and relationships etc. DBA also determines the physical access methods to be used and allocation of Physical storage for the database. {ill To define Integrity constraints specifications : OBA is responsible to define integrity Constraints on databases. These help to maintain database integrity. Le Ss Database Managernent Systems LoD eS 2 eae eae ‘onduct training on how to acces, (Iv) Operational training to usors : It oie DBA toc : 8 lictionary and othor technics the ow ordination ofthe database environment (v) Co-ordinating various nevis : DBA makes ho co-arlnet mt A databans ‘Thore exists nood of coordination in contox! of various activites ike colactien © Rate ANN An , urity privacy and integrity which is ful y DBA. design database maintainonco databaso security pr database and ensures that performance (vl) Job Monitoring : DBA monitors jobs running on the inate ers. With change if requirements, is not dograded by very expansive tasks submitted by some u! " DBA \s responsible for making appropriate adjustments of tuning of the database. ‘tn / (vil) Database Authorization and Access method : Granting privileges to the respective users on the database access Is the function of DBA, DBA creates a log of information about the authorized users and thelr level of access to the database. (vill) Routine maintenance : DBA maintains periodical backups of the database either on to hard disks, compact disks or on to remote servers to prevent loss of data in case of disasters. A DBA is also responsible for repairing damage of the database due to misuse of software and hardware failures. an . (lx) DBMS Performace planning, monitoring and tuning :-DBA is responsible for optimal performance. It Is the DBA who defines the procedures for recovering from failures, if any, takes corrective actions at right time to enhance services to user in the DBMS enviorment. 28. Should a real world object be modeled as an entity or as an attribute. (PTU, May 2014) ‘Ans. Yes, An entity s an object in the real world and the descriptive properties attached to the entity is known as attribute, ‘ . Q.29, Discuss classification of databases ? Ans. DBMS (Database management system) : Itis software to manage many databases. A DEMS is a software component or logical tool to handle the databases. All the queries from user about the data stored in the database will bo handled by DBMS, There are many DBMS . val the market ke dBase, Fox Pro oracle, unity, Access etc, YPEMS avaliable in RDBMS (Relational Database mana, tho database, use of data di igement system) : Each database system uses approach HDBMS (Hoterogenous DBMS) th Of data like student data, teacher wan atabaso which s entoly alforont, " S™"PCYE® data ote. In HDB DDBMS (Distributed DBMS) In this System, Database is split into number of fragments patabase system Architecture aa which are stored on different computers, ‘These are connected via networks and are responsible for their work. E.g, Banking system, m Network Site SileA Sie 8 For e.g : An orgainzation may have an office in a building and have many subbuilding that are connected using LAN. The current trend is towards distributed systems. This isa céntralized system connected to intelligent remote sites. That remote site have own storage and processing capabilities but in a centralized or netwrok there is a single storage. OODBMS (Object oriented DBMS) : Object oriented Database management systems (QODBMSs) have been developed to support new kinds of applications for which semantic and content are represented more efficiently with the object model. Therefore, the OODBMSs represent the two main problems : Q Impedence mismatch Q., Interoperability problem between object models. @ 30. What is the difference between procedural DML and non procedural DML. (PTU, May 2014) Ans. Data mainpulation language is used for data mainpulation Data mainpulation is Retrieval of information stored in database Insertion of information to the database te Deletion of information from the database % Updating of information stored in the database Types of Data mainpulation language : Procedural DML Non procedura/Declarative DML Procedural DML : In procedural DML user has to specify what data are needed and how to get it, Non procedural DML : In declartive DML user has to specify what data are needed without specifying how to get it. ji : E.g. Structured Query language (SQL). Q31. What is structured Query language ? (PTU, Dec. 2014) Ans. SQL is the language used to mainpulate relational databases. SQL is tied very closely with the relational model. It is simple and powerful language used to create, manipulate and retrieve data and structures in the database. Today, SQL is accepted as the universal standard database access language. SQL is used by most commercial database applications. SQL knowledge will continue to be a fundamental skill as there is currently no mature and viable alternative language that accomplishes the same functionality. 32. What are the advantages and disadvantages of a database approach. . (PTU, Dec. 2005) Ans. DBMS is composed of four elements. The first element is data. Data : Data is a collection of raw facts and figures. LO2D> Database Management sy, 14 it is Jatabase is the collection of data in some files. It contains information About ene Particular enterprise. 5 7 tient data and so on, Example : Bank stores customer's data, Hospital a ie that enables the usere to DBMS : DBMS is a collection of programs or it is ae fe and retrieve the data Cleats and maintain a database, Also DBMS allows the users to insert, update ai rom the “9. MS-Access, Fox-Pro, Oracle etc. ee i ana DBMS : The main advantages of the database otro Over the filg rocessing system are as follows : * @ Reduction of Redundancy : In the database approach, the centrailzed control of data by the DBA avoid unnegessary duplication of data and effectively reduces the total amount of data Storage required, | : (i) Avoid in consistency of data : Because of the duplication, inconsistency may occur which means the value of an attribute is different at different Places. With the use of DBMS, itis possibietg reduce the redundancy. Once. Tedundancy is removed, the data will always be in Consistent state, Gi) Sharing of data : Data sharing means that the stored deta ie accessible to multiple 2pplications or users. The DBMS interfaces with pplication programs, so that the data contained in the database Can bé used by multiple application and users, . v) Data privacy and security : in order to ensure that the. database is acessed through proper channels, various security measures are applied in DBMS. . (v) Data integrity : Data integrity means that the date, Contained in the database is both accurate aaa consistent. Centralized control can also ensure thay adequate checks are incorporated in the DBMS to provide data integrity, (vi) Increased concurrency : DBMS fhanage concurrent di Problem of loss of information or loss of integr (9) Conflict resolution : Since the database in under the control of DBA, he or she should ‘resolve the conflicting requirements of various users and applications, . Disadvantages of using DBMS : Although, DBMS he so file processing system, still it is not free from disadvantages, The {') Complexity of backup and recovery : Backup ann in DBMS. The administrator of recovery. extermely large piece of software. It occupies many gigabytes of storage disk space and requires (WV) Increased data security requirements : Because of natural calamity or hardware or software patabase System Architecture ~~ 15 problems, database may be destroyed ti activities. ved that could be fatal to the concerned organizations business (v) Failure and aaa ae fa et ezccclated with centralized database : Failure of any h a . 7 _ gystemis failed, he overall activities are blocked. amabase environment. the cena a eS i are the various objectives of Database systems. : is a collection of programs or it is a software that enables the users to create and aintain ms 7 database. Also DBMS allows the users to insert, update and retrieve the data from the E.g. MS-Access, Fox-Pro, oracle etc. a ort eee management system : The following are the various obejetives of et : A Defining conceptual schema and Database Creation : The DBMS provide functions to jefine the structure of the data in the application. These include defining and modifying the record structure, the type and sizé of fields and the various conditions to be satisfied by the data in each eld. E 2. Data Storage Rettieval and update : Once the data structure is defined, data needs to be inserted, modified or deleted. The functions which performs these operations are also part of the DBMS. These functions can handle planned and unplanned data manipulation needs. --- 3. Data Security and integrity : The main objective of the DBMS is also to handle the security and integrity of data in the application. These’can be easily invoked by the application and hence the application programme need not to code these features in his programes. 4, Data Recovery and Concurrency : Recoveries of data after a system failure and concurrent access of records by muliple users are also handled by the DBMS. Since DBMSs support sharing of data among multiple usérs, they must provide a mechanism for managing concurrent access to the “database. DBMSs ensure that the database is kept in consistant state and that the integrity of the data is preserved. It ensures that the database is updated correctly when multiple users are updating the database concurrently. - 5. Performance : Optimizing the performance of queries is one of the important objective of a DBMS. Hence the DBMS has a set of programs forming the query optimizer which evaluates the different implementations of query and chooses the best among them. 6. Authorization Services : DBA is a technical person that is authorised to perform the activities relevent to provide the access to the users. The DBMS supports data contro! langyage which is used to provide security.to the data. 7. Data independence service : DBMS supports the independence of programs from the actual structure of the database. It provides two types of independence that is physical data independence and logical data independence. 8. Controlling Redundancy : In file processing system, there was a problem of redundancy. The main objective of the DBMS is to have a design that stores each logical data item in only one place in the database. So this design does not permit inconsistency and also saves the storage space. : 035 Es6iai the main difference between file processing system and a database system? ~——PTU, Dec. 2019 ; May 2017, 2014) _ Ans. () File processing system : Before inception of database mangament system, the traditional LOAD» Database Management g File processing ssing system. Ste, file oe the endusers SUCH as the prog, rane N data, For example in an organisation, 4° ih some other departments, They Pes cl * to intonation processingis Known a8 2 HON of aplication programs that perform ee roars Each program defines and manages its OW” CAN, eN'sIs Payroll department and personnel departm en eee Sedartement store details of employees like : SAI ils of employees like EMPLOYEE (om Similarty, personnel department also stores detail es name, designation, sex, date of birth, salary) se departments and this There is a significant amount of data redundancy in these dep: handles data entry file maint hanoens in file based systems. Each set of departmental Se TEE structure and storage 2nd the generation of a fixed set of specifie reports. er pecome more effectivea nec app’ files and records are defined in the application program. Pens och \“SS required. What emerged good were the database and DBMS. are the various limitation, Disadvantages of file Processing system : The following S Of fig Processing system, : i 7 Duplieation : In file system, often identical data is stored in many as Because: of redundancy the problem of data inconsistency is created. Eg. Inalarge aa: atnonn 2 exists tig Separate departments i.e. payrdll and personnel. The functioning of payrol wes ee a Soncemeg wah wages and salaries of employees and personal departments is concerned with the informa about employer work, education as well as occuptional skils. As both departments hand fies felevantto the employees, there exists data items that are used in both sides, such data redundaney* (Qcrease data editing, maintenance and stora Je bosts. = . jculty in accessing data: Tn traditional file processing, retrieval of data in a convenion ankGinion manner is not possible, 7 Limited Data sharing : Traditional fle criented system has a limited data sharing opportunities, Each aplication has its own private fles and users have tle Oppurtunities to share data outside thei, own 2ppiications. To obtain data from several incompatible files in Separate systems will require a, major programing effort. E : { ackof data integration : Several types of consistency cofistrdints are applied to the datavalues Stored in the database. However, when new constraints are Tequired to apply, it is difficult in file Processing system to ‘change the program to enforce them, z (ll) Database system : D: Database systemis a tool that sit itself is controlled by DBA. Advantages of Database system: . (Reduction of Redundancy : In the database Spproach, the centralized contro of data by he apase 5) px 17 pes oa unnecossaty duplication of data and effectively reduces the total amount of data storage ied (ji) Avold Inconsistency of data : Because of the duplication, in consistency may occur which moans the value of an attribute is different of different places. With the use of DBMS, it is possible to reduce the redundancy. Once redundanoy is removed, the data will always be in consistant state. (ii) Sharing of data : Data sharing means that the stored data is accessible to multiple aoplications or users. The DBMS interfaces with application programs, so that the Data contained in the database can be used by multiple applications and users. (iv) Data privacy and Security : In order to ensure that the database is accessed through proper channels, various security measures are applied in DBMS. (v) Data integrity : Data integrity means that the data contained in the database is both accurate ~ and consistent. Centralized control can also ensure that atlequate checks are incorporated in the DBMS to provide data integrity. (vi) Increased concurrency : DBMS manage-concurrent database access and prevents the problem of loss of information or loss of integrity. : (vil) Proper Database Administration : In the database system, the database administrator (OBA) manages the database by having a centralized control over the data. (viii) Ease of Application Development : In case of traditional file system, application development and data handling is not an easy task. By using database management features the development of applications as well as proper handing of data is possible. (ix) Data independence : Data independence is a useful advantage in database environment since it allows for changes at one level of database without affecting other levels. (x) Conflict Resolution : Since the database is under the control of DBA, hé or she should resolve the conflicting requirements of various users and applications. , Q35. Define Data Model. Explain in detail various types of data models. : : : (PTU, May 2017 ; Dec: 2020, 2015) eau OR Compare Hierarchical, network and Relational model. . ‘Ans. Data model can be defined as an 4 integrated collection of concepts for describing and manipulation of data, relationship between data and constraints on the data in an organisation, Data modelis a higher level description of the schema. Ithelps to identify the definable information required by an organization. : Data model is comprised of three components : (J) Structured part : Itconsists of a set of rules according to which database can be constructed. (il) Manipulative part : It defines the types of operation that are allowed on data. (ili) Integrity rules : These ensure that data is accurate. Data models are broadly classified as : 1. Object based Data models 2. Physical Data models 3. Record based Data models. 1. Object based Data models : In this model, the focus is on real world objects. These are also, called as conceptual models. These describes data and its relationships. It has flexible data structuring capabilities. Data integrity constraints can be explicity specified using object based data models... The four main types of object based data models are : ()) Entity Relationship model (ER Model) - 18 (ii) Object oriented model (ii) Semantic model (iv) Functional model i fe propert () ER model : An entity refers to real world objects which have some properties Attached, ‘shown in ER diagram below : june salance Account LOWS Database Management Sy Customer > Deposit There are two entities : (@) Customer and (b) Account represented by rectangle. -- Ovals represent attributes of the entity. Deposit is the relationship between customer and account. (il) Object oriented model : This model, also models a database as a collection of objeg, Each object has data as well as method to mainpulate the data, This data and the Method are groupeg * together to form a class. Gi) Semantic data model : Entities in the semantic system represent only the object in an object oriented system but do not include behaviour, (@v) Functional data model : This model was used to view the database as a collection of defined functions and to use functional language for ‘quering the database. 2. Physical Data motels : These models are used to describe the details of how is storedin computer along with their record structures access paths and Ordening. The most common physical data models are : (i) Unifying mode! , (ii) Frame memory model. z (i) Network model (iil) Relational model. This model establishes one to mar Q Theres single root node ny relationships. This model follows following constraints: Each child node has a single parent node . 3 a ew ei oa Node is through its parent node. ‘or accessing and storing data is preorder traversal For example Bank + + TTC [Erect occont Fixed depoat Saving Nene 100 | rama Nene 33 Up Barzooo Lf Baraao0 Lf earea00 pee + fineness Tle #000 Bal 5000 Uf sareooo] - Taro ‘The relationship used here is one to many as one bank has many accounts Advantages - : 1. Simplicity : Data has naturally hierarchical relationship therefore it is easy to view data arranged in this manner. 2: Efficiency : This database is very efficient for expressing one to many relationships. 3. Data security : This was the first database model which offered database secirrty provided and enforced by DBMS. 7 ‘ ’ 4, Data integrity : This model is based on parent child relationship, the child segments are always automatically referred by its parent. So this model promotes data integrity. * 5.No standards : There is no precise set of standard concepts nor does the implementation of model confirm to a specific standard in hierarchical data model. . 6. Simple : The relationship between various layers of records is simple. 7. Data independence : The DBMS creates an environment in which data independence can be maintained. : : Disadvantages : 1. Implementation complexity : The model is very easy to design but itis quite complex to implement. f . eS 2. Data management problem : If wé make any changes in database structure then we need to make necessary changes in all application programs that access database. 3, Operational Anamolies : This model suffer from insertion, updation and deletion anamolies. The retrieval operation is very complex. ‘4, Implementation Limitation : The many to many relationships which are very common in * sealife are very difficult to implement in this model, because it is based on one to many relationship only. an , (li) Netwrok Model : This database model consists of a collection of records connected to one nother through alink. A link is an assoication between two records. This model implements many to many relationships. LOADS Database Managements,» ee, 20 For al ae ‘AecountNo. [ Balance] A A-rVihar Del. > 540 4000 B B-25 Jal. —>} 320 3000, c B/20 Tgr Ngr | Kolkata] =} 940 60 aeea gee. standards have been developed and enforced in this type of database mony 2. Conceptual simplicity : This network model is conceptually very simple and easy todas, 3. Capability to handle more relationships : It can handle one to many and many to mary relationships which is the real help in modelling real life situation: 4, Ease of Data access : The data access is easier and flexible. 5. Data integrity: This model does not allow ‘a member to exist without’an owner. Thus auser must define the owner record and then thé member record: Thus, it ensures data integrity. Disadvantages : . 1. System Complexity : All the.records are maintained using pointers so the whole database structures becomes very complex. 2. Operational Anamolies : Insertion, deletion and updation operation of any record requte large number of adjustments which makes its implementation very complex and complicated. 3. Data management problem : If changes are made to database structure, all the application program need to be modified before they can access data. (ili) Relational model : Dr. E.F codd first introduced the relational database model in 1970s. consists of three components : * 1. Set of relations and set of domains that define the way in which the data can be represerte! (Data structure). 2. Tho operations that can be performed on data (Data manipulation). 3. Integrity rules, that defines the procedure to perfect the data (Data integrity). For example BCA Table Relation RoliNo Name Age Marks Father's Name ! A 15 - 7) XYZ _ 8 4 : 85 POR 3 c 16 82 DEF Columns : Properties/Attibutes/tields Rows : Information/Record/Tuple, Tables called elation, Each data fieldis as row and the tuple of the table, Advantages : (i) Conceptually very simple : itis veiy storage details and the designer can concent Consideredas the column and each recordis conse rsp and frees the designer from the physica! ” 'e on the logical view of database. ud — patabase System Architecture 24 (il) Structural Independence : Any change in the structure of database does not affect tne pgMs's data access mechanism in any way. The programs therefore do not need any modification even when the structure is modified. (ill) Design Implementation, maintenance and usage ease : The structural indepencence andthe data independence makes the database design, maintenance and usage much easier # other models. Disadvantages: (i) Hardware Overheads : RDBMS hides the implementation complexity and the physical data storage details from the user. So RDBMS needs powerful machines to run smoothly. It increases hardware overhead. Comparison between Hierarchical, Network and Relational model S.No | Basis say Hierarchical model _| Network model Relational model | 1 | Insertion Wecannotinsertthe |Itdoesnot suffer | Italso-does not suffer - information of a child | from any anomaly _| from any insertion | who does not have any] of insertion. anomaly. | L parent. | 2_| Deletion The deletion of parent | itdoesnot suffer | if doesnot suffer 1 result inthe deletion | fromdeletion from deletion - | of child record, anomaly. anomaly. | 3 | Inconsistency | There may be problem | Network model does | Relational model } a of inconsistency during] not suffer from does not suffer from | update operation. update anomaly. . | update anomaly. | 4_| Nameot Retrieve algorithms | Retrieve algorithms | Retrieve algonthms algorithms | are complex and arecomplexand _| are simple and symmetric. | asymmetric. symmetric. : | 5 | Relation Relationbetween | The relation between| The relation between between record is of parent record is expressed | records is expressed by a Record child relation. in the form of relation that contains key. ; pointers. | > 6 | Typeot Implements one to implements many _ | Implements one to many | relation many relationship to many relationship | and many to many relationship easily. 7 | Physical | Inmaintains physical | Iralso maintains [Tt does not maintain fecord connection among _| physical connection | any such physical 7 records. among records. records. @ | Record | Searching for —] Searching for Aunique indexed key Searching records is very difficult.| records is easy isused to search records. | Q 36. Explain the concept of a view In SQL ? (PTU, Dec. 2014) Ans. A view is a query of one or more tables that provides another way of presenting information. A view is a "stored query’. It can be used just as if it was a table. But the main difference is that it doen't actually contain or store data, The only thing that a view actually requires is the SELECT statement that defines it. However, the data is accessible through the view just as if you are accessing anormal table, So a view can be also be considered as a virtual table, Views do not actually store data rather aos stem Avchitecture 24 Ww gtructural Indopendonce : Any chango In the structure of database does not affect the ppus's data ‘accoss mechanism in any way, Tho programs thorofora do not nead any modification yon whan tho structuro Is modified. (iil) Design Implementation, maintonanco and usage ease : Tho structural independence andthe data Indopondence makes the database dosign, maintenance and usage much easier than other modols: Disadvantages: (i) Hardware Overhonds : RDBMS hidos tho implomontation complexity and the physical data storage details {rom the user. So RDBMS noods poworful machines to run smoothly. It increases hardware overhead. Comparison betweon Hierarchical, Network and Relational mode! S.No | Basis Hlorarchicalmodel | Networkmodel _| Relational model 1} Insertion We cannot insert the | It does not suffer _ | Italsordoes not suffer Information of achild | from anyanomaly _| fromanyinsertion who does not have any of insertion. anomaly. parent. Z| Deletion ‘The delollon of parent | irdoes not suffer | If does not suffer result inthe deletion | fromdeletion from deletion of child record. anomaly. anomaly. 3H nconsistency | There may be problem | Network model does | Relational model of inconsistency during] not suffer from does not suffer from update operation. update anomaly. _._| update anomaly. 4_[ Name of Retrieve algorithms | Retrieve algorithms | Retrieve algorithms algorithms | arecomplexand arecomplexand _| are simple and symmetric. asymmetric. symmetric. |—5_| Retation Relation between Tho relation between| The relation between between record is of parent record is expressed | records is expressed by a Record child relation. in the form of relation that contains key. - pointers. 6 _| Type of Tmplaments ona To] Implements many | Implements one to many relation many relationship to many relationship | and many to many relationship easily. | 7_| Physical Tnmaintalns physical | Tralso maintains _| It does not maintain record connection among _| physical connection | any such physical records. among records. records. & | Record ‘Searching for Searching for unique indexed key Searching _| records is vory difficult.) records is easy isused to search records. | 36. Explain the concept of a view In SQL 7 (PTU, Dec. 2014) ‘Ans. A view is 4 query of one or more tables that provides another way of presenting information. Aview is a "stored query”. It can be used just as if it was a table. But the main difference is that it doen't actually contain or store data, The only thing that a-view actually requires is the SELECT statement that defines it. However, the data is accessible through the view just as if you are accessing anormal table. So a view can be also be considered as a virtual table, Views do not actually store data rather a ; LOIS Database Managements a 22 basod, referred to as the base tabigs on x thoy derive thoir data from the tables on which they m * views. Base tables thomsolves may bo tables or views. ‘Syntax Create [or replace] view As sore han lho aw oF OR REPLACE anton rca avi already exists. To create a view, auuser must have the privileges oot logos Onen ee table and view referenced in the view. You must have the system p! VIEW g CREATE ANY VIEW. E.g. . A user whose job is clerk do not has access to SAL Column of the EMP table, SQL > create or replace view clerk As Select emp no, ename, job, deptno, hiredate from emp View created bi 4 On execution of the above query, a view willbe created once a view is created itcan be tretey as table, You can now perform the various DML statements like SELECT, INSERT, UPDATE ang DELETE on the view created. So to reterive the records of the-'clerk’ view you can use the following SELECTstatement. SQL > Select * from clerk; Q 37. Write a short note on stored procedure and triggers. (PTU, Dec. 2914) Ans. Stored procedures : A stored procedure is a named PL/SQL code block that has been compiled and stored in one of the oracie's engines system table. Before the procedure is stored, the oracle engine parses and compiles the procedure. fan error occurs during the creation of the procedure, an invalid procedure gets created. After creation, the oracle engine displays a message that procedure was creation with compilation errors but it does not displays the errors. To display the errors occured in the procedure use the SHOW_ERRORS Command at the SQL prompt. After storing it in the “database, it can be called by another application or PLISQL subprogram, | « To create the stored procedure, you must have the create procedure privilege. Synatax: — CREATE [OR Replace] procedure [(parameter {IN/OUT/INOUT} datatype) {IS/AS} [local_declaration); BEGIN, : 3 execution_Section; " [Execution exection_section;] END []; Where optional OR REPLACE clause is needed when you are trying to recreate a procedure * with the name already existing in your schema, When the user executes the stored procedure the oracle engine checks the execute privilege for the stored procedure of that user. If the user is invalid then access is denied and ifthe user is valid then oracle engine checks the statis of called procedure whether it is valid or not. If it is valid, it will execute it, 7 Trlager : A trigger is PUSQL blocks that automatically gets @xecuted when the user performs a data manipulation action or event. A trigger gets automatically executed whenever the user performs an insert, update or deleta operations, Trigger are helpful in performing following operations : 1. Enhancing database integrity that can't be enforced upto a desired level by usirig the default a - qersnase System Architecture 23 ny constraints which are : (a) Check (b) NotNULL (c) Unique (d) Foreign key (e) Primary key. 2. Can help to audit changes to the information present in the table of the database. 3. Can be used to enforce complex business rules. Types of Triggers : Oracle has different types of riggers to enable the developer to accomplish a variety of tasks. The different types of triggers are : Rowand statement triggers Before and Atter triggers. Row and statement triggers : Row triggers : A row trigger is fired each time a row in the table is affected by the triggering E.9. It an UPDATE statement updates multiple rows of a table, a row trigger is fired once te each row affected by the update statement. If the triggering statements affects no rows. the rigg2! not executed at all. Row triggers should be used when some processing is required whenever 2 er statement affects a single row in a table. : Statement triggers : A staterient rigger is fired on behalf of the triggering statement independent cf the number of rows the triggering statement affects. Statement triggers should be used whena triggering statement affects rows in a table but the processing required is completely independent of the number of rows affected. is Sefore and after triggers : When defining a trigger itis necessary to specify the trigger timing ite. specifying when the trigging action is to be executed in relation to the triggering statement. BEFORE and AFTER apply to both row and statement trigger. Before Triggers : Before trigger execute the trigger action before the triggering statement. “These types of triggers are commonly used in the following situation : BEFORE triggers are used when the trigger action should determine whether or not the triggering statement shouldbe allowed to complete. By using a BEFORE trigger you can eliminate unnecessory processing of the triggering statement. : BEFORE triggers are used to derive specific column values before completing & triggering INSERT or UPDATE statement. : after triggers : AFTER trigger executes the trigger action after the triggering statement is* executed. These types of triggers are commonly used in the following situation. After triggers are teed when you want the triggering statement to complete before executing the trigger action. BEFORE trigger is already present, an AFTER trigger can perform different actions on the ‘same triggering statement. : : . Q.38. Differentiate between SQL commands DROP TABLE and DROP VIEW. : i (PTU, May 2014) Ans. DROP TABLE : Sometimes itis necessary to remove table from a database completely oryou may be dropping table that was created for a particular task and are no longer needed. Syntax for dropping a table is’ : Drop Table [CASCADE CONSTRAINTS}; DROP VIEW : A view can be dropped and then recreated. When you'drop a view, all associated grants are dropped. After the view is recreated, necessary privileges must be regranted. you can drop aview using a DROP VIEW command. SQL > DROP VIEW ~ View dropped. . LOWS Database Management, (PTU, Dag BMS ? TU, 39, What are the various components of DI ponents eac of which ig aaa sare COMy 8 h ‘Ans. A DBMS is a composition of ae oe are shownin te foloing age : ftware compor Particular operation. The major so! 24 DBA Users Programmers Basso Appicalion [ Queries scher oy DNS -_ Query 'SSOr BN ye sroprocessor >] _provontor Dictionary Database objec cose —>] _Dalabate manager Aoi | Fie range m ~ System ito Dalaba and : system catalog Major components/Elements of a DBMS : The above figure shows the following components of DEMS : : Q Database engine Diskmanager _ File manager Query processor Data and Datafiles Data Dictionary Communication systems Security utiities, 3 Data base manager : This component Plays an important role during the Tuntime when the. Gatabase accesses are tobe handled. Itis basically responsible for the updating and retrieval operations that are carried out in the database, : + Disk manager : This component is responsible for controlling access to the information that is Stored on the disk. The data is transferred from the main memory to the disk with the help of disk manager. : File manager : File manager allows the Fer 0 consider the disk as a collection Of files. Each stored file has a unique file ID and ®ach record Is identified by a record ID which is also unique. File manager allows to retrieve a record froma file, store a record into a file, create a file, destory a file etc. Query processor: The queries entered by the US®rS are handled by the Query processor. The Query is analyzed and executed by Senerating calls to the database engine, Seen OC0o0o0ogo0gn0 asansse System Architecture DML preprocessor : This mosuie coments DN #80089 function calls in the host language Sor 10 generate the appropriate cade. Dictionay Treraget: Ths comotnentts taailtor ee cioags ci dscumasiaion syenentansenee avsomar nt mation information about users and other information nalatad to system adminigaton Ths component is Mainly used by database administrators, users and database designers Data Dictomnary : Data dictionary is the repository of descristion of cata in the database. The esta Sictonary is an integral part of the DBMSs and stores metadata oF information about the GATADASA “bute HaMe and definition for each table in the database. Data dichonanes att the database aoministrator in the management of a database, user view definitions as well as their use. DDL Compiler : The DDL compiler converts DDL statements into a set of tables containing Sata. These tables are then stored in the system catalog while contro! information is stored in ta file headers. Communication system : The component deals with the acosss of the database located at remote place through local computers. The transmission media for communication may be satelite communication or telephone lines The machines are interconnected Via communication networks Le LANS, WANS ete, . Security utilities : The data can be lost or damaged due to catastorphic faire in order to restore the database from such fallure, a backup utility creates a backup copy of the database. Data and Datafiles : A datafile is associated to one database. Incase the data requested by the user is notavailable in the main memory, itis transferred from the datafiles to the main memory. _24ecWrite shortnote on levels of database abstraction. ; (PTU, Dec. 2019, 2017, 2014 ; May 2018, 2016, 2014) Ans. Levels of Database Abstraction : DBMSis a collection of inter-related files and a sot of programs that allow several users to access and modity these files, A major purpose of a database system is to provide user with’ an abstract view of the data, That is the system hides certain detall ot how the datais stored and maintained. However, in order for the system to be usable data must be retrieved efficiently. Levels of database abstraction is called three level architecture, The goal of the architecture is to separate the user applications and the physical database, User ° 2s ML State MENTS EMOIIAS Han ATOIEATON PATAM The DIL preprocessor must interact with Query 5 | Usertevel Conceptual level ‘Stored Database } Physical leveltotemal level (I) Physical level ; It is the lowest level of abstraction, It describes how the data is actually Stored and also describe the data structure and access methods to be used by databases. (il) Conceptual level : It is next higher level of abstraction which describe the structure of whole database for community of users global view of data. ( LOWS Database Management level abstraction. It describg oniy ap : 26 _- _ - ighest (Hl) View tevel : View lovelfoxtornal ~ is tho hig! Of entire database in which user is interosted. ' lod a’ Schema : Tho overall design of database is call Threo sch hero : Nat physical love), @ Pivatalatane: This schema describes the database design at phy: level, m mi logical lever, i the database design at : Ml) Logt : This schema descitbes 7 a Subsheme chs schema descrites the database design at different views of databag Sonne we] [Be Name. character, Name Class character Fees umber s database schema, 8, Intemal schema [Stored items datatypes. Rolino number Name character Class character Fees number - College Management Mapping between views : DBMS is responsible for mapping between the three types of, Two types of mapping are required in the DBMS. () External conceptual mapping : A mapping between the external and Conceptual view gives the correspondence. among the records and relationship of the external and Conceptual view, ‘The extemal view is an abstraction of the conceptual view which in tum is an abstraction of intemal view. There is a mapping from a particular logical fecord in the external view to the conceptual record in the conceptual view. ' ‘ (i) Conceptual internal mapping : Conceptual schema is related to the internal schema by Schema, “logical record in conceptual schema. Mapping between the conceptual and the method of deriving the conceptual record from physical database, internal levels specifies _Oswirte short note on Data Independence. oR (PTU, May 2017) Explain difference between physical and logical data independence ? (PTU, Dec. 2017, 2015, 2014) Data independence is defined as the capabilty to change the stem without having to change the schema at the next higher There are two types of data independence. (I) Physical Data Independence : Physical data indoy Ans, Data Independence : ‘schema at one level of database s (tl) Logical Data independence : Logical data Independence indicates that the conceptual = patabase System Architecture 27 schema can be changed without affecting the existing external schemas. The change would bo absorbed by the mapping between the external and concéptual levels, Logical data Independence also insulates application programs from operation such as combining two records into one or spliting an existing record into two or more records. Logical data Independence is achieved by providing the external level or user view of the database, External External External schema, schema, schoma Extemal/conceptual Logical data mapping Tndopondonce + Conceptual ‘schema Conceptuainteral Physical data mapping oT idependence Internal schema Data Independence and Mapping Q 42, What is SQL * plus ? * _ (PTU, Dec. 2016, 2014) Ans. SQL" plus is a component of oracle 8! and is used for executing SQL statements. SQL* plus is also used for developing scripts for constructing indexes, tables and other database objects. Itis also valuable for.prototyping the SQL statements that your application will use. After you have refined the appropriate SQL statements, you can incorporate them into. application tools such as. visual Basic, oracle forms etc. Another advantage of using SQL * plus is that it offers a consistent enviornment for the execution of scripts regardless of the operating system in which it resides. It can also function as a report writer with the capability to subtotal, total and suppress repeating values. Q 43. Whatis control structure ? (PTU, Dec. 2014) Ans. Control structures are conditional statements. and loop constructs which help you to build the code that gets executed in your PLISQL. Almost every piece of code you write will require conditional control, which is the ability, to direct the flow of execution through your program based of a condition. There are a number of different types of conditional statement and looping constructs, in order to help tomake your code efficient and readable. The various control structures include : O Conditional contro! Q._Interative control Q Sequential contro! ‘ Q 44, What are the components of DDL. ? Explain with example. : (PTU, Dec. 2014, 2013) Ans. Data definition language (DDL) statements consists of those statements in SQL language that are responsible for creating, modifying or dropping database structures such as tables, views, indexes. Oracle implicitly commits the current transaction before and after even DDL fails. Thus, if Concludes that any uncommitted changes.made prior to the DDL statement submission connot be tolled back. These statememnt are commonly used by database design and database administrator 28 are O ALTER TABLE © DROP TABLE QO RENAME TABLE ind manage data, itis necessary to ore. "ABLE : In orderto store ar tables oma using CREATE TABLE command, The CREATE TABLE go, CREATE TABLEMVIEW/INDEX es! TI < “ree tion. The various compon no database structures used by an applica for establishing 130 § p ato tay es, rman Y the table, name of columns in the table as well as the datatypes ag i¢ "equitea name of . associated Syntax: h each column of the table. CREATE TABLE < tablename> (column name datatype (Size) inname datatype (size); terete name represents the name of the table to be Cteated. The datatype Satatype of each column. Example : Let us consider UNIVERSITY database whic! h stores information about insta ColumnName | Datatype Size Description instid Number 4 Indentification nambor Name + Varchar2 15 Name of instructor DOB Data oa Data of birth Post Varehard 20 Post of instructor - Phone Number 8 Phone number SQL> CREATE TABLE instructor (instid Number(4) Name Varchar2 (15) DOB date, Post Varchare (20) Phone Number (9); ALTER occur which table, moditying an existing column. Table : Ater the tables are created and begin to be used requirements are lie ‘equires modifications in the structure of the table such as adding new columns to rlnlion etc So these modifications os re vocal Vs the ALTER table Statement, This. statement ct eee ts There are Many types of ‘Modifications that TABLE statement Such as Q Addor dorp one ormore columns, to/tror OQ Increase or, decrease the width of the 9; ting column trom man D Change an exis, Q To enable or dis, 2 Addimodity/del Specity a deta assc hange the struct ‘Oclated to/from the table. mn. lure of the table and not its conn © made to the structure ofthe tables using Al 1m oxisting table, xisting column “ idatory to ptional or vice versa. able integrity constrain Ste integrity constraints ult Value for existing cot, patabase System Architecture DROP Table : Sometimes it is necco: may be dropping table that was created for a particular task or no longer needed. ‘Syntax : Drop Table
Now let us delete the INSTRUCTOR tablo using DROP TABLE statement. SQL > DROP TABLE INSTRUCTOR. 29 ssary to remove table from a database completely or you RENAMING Tables : Oracle provides the facility to change the name of the table by using a ALTER TABLE statement, when you rename the table, oracle automatically updates foreign keys in the data dictonary but it does't update a stored code modules, storéd queries or reports client applications so care must be taken when renaming the tables. Syntax ALTER TABLE RENAME TO to To remove the INSTRUCTOR table to TEACHER, the statement is SQL> ALTER TABLE INSTRUCTOR RENAME TO TEACHER; OR SQL > RANAME INSTRUCTOR TO TEACHER; oracle. Q 45. What is the rollback of database ? Explain the process with a1 n example from (PTU, May 2014) Ans. The Roll back statement is used to undo all the changes that the user-has made to the database since the last commit statement was issued or since the database session begins which ever is later. If you havé complete a series of insert, update or delete statements but have not yet explicitly or implicitly committed them and you encounter a problem such as computer failure, oracle will automatically roll back ariy uncommitted work. The synatx is : SQL > Rollback; Consider a DEPARTMENT table using two columns 'DEPT_ID' and ‘DNAME® containing departments ID and name of the department respectively. Initially the table consists of two rows as shown below: r Dept_id DNAME T COMPUTER 2 ENGLISH SQL > COMMIT; ‘SQL > INSERT into Departmemnt values (3, ‘Math’; 1 row created. : . SQL > insert into Department values (4, ‘commerce’ 1 row created, + SQL> ROLLBACK; Roliback Complete, é SQL > Select * from Departemt; Dept_id DNAME 7 COMPUTER 2 ENGLISH Now let us insert two rows in the DEPARTMENT tabie using INSERT statement. TT 03D) Database Manageme, q _30 jes have been rolleg back Noy It will display the origional table with onh execute the following statement : ‘Math’); 'SOL = INSERT into Department values (3,'Math); 1 row created, c jerce’); SOL INSERT into Department values (4 ‘Comm T row created : SQL > COMMIT; . Commit complete SQL > insert into Departe ‘1 row created SQL > Rollback; Roll back complete. two rows as chan mnt values (5, Hind!) ‘SQL > Select * from Department; ~ DeptD. DNAME. 1 ‘COMPUTER 2 ENGLISH 3 MATH 4 COMMERCE Be SAVE POINT?A SAVEPOINT allows you tocreate marked point with a transaction. You ma ¢ point without rong back any of the work that precededy rollback your transaction to that marke i ale ah SAVEPOINT's are a useful transaction failure since they allow you to divide a single large transacian into a series of smaller parts. While all the stétements executed are still part ofthe larger transact, roll them back as if they were a single statement, you can group certain statements together and a “Anyother prior statements in the transactions are unaffected: You may have multiple SAVEPOINTS in a single transaction. . e The Syntax is ‘SQL > SAVEPOINT ; Where is the name given to a savepoint. : To selectively ROLL BACK a group of ‘statements within a large transaction use the ROLLBACK TO Now let is again consider the DEPARTMENT table. SQL> INSERT INTO Department values (5, 'HINDI'); 1 rowcreated SQL > SAVEPOINT ABC; Savepoint created; SQL > INSERT INTO DEPARTMENT VALUES (6, ‘History’); 1 rowcreated SQL > ROLLBACK TO ABC; * Roll back Complete, | SQL > Select * form DEPARTMENT ; Deptid |. DName COMPUTER ENGLISH MATH : COMMERCE HINDI anon

You might also like