• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Dbms narrative question answers
 

Dbms narrative question answers

on

  • 485 views

Database Management System

Database Management System

Statistics

Views

Total Views
485
Views on SlideShare
485
Embed Views
0

Actions

Likes
0
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Dbms narrative question answers Dbms narrative question answers Document Transcript

    • 1 PGDCS Descriptive Answers of DBMSShort Note: i) View [PGDCS 2011 Q2] [PGDCS 2009 Q.2] [PGDCS 2008 Q.10a] ii) Datamodels [PGDCS 2011 Q2] [PGDCS 2009 Q.2] iii) Unique Key [PGDCS 2010 Q.9] iv) Primary Key [PGDCS 2008 Q.3] v) Foreign Key [PGDCS 2009 Q.2] vi) Joins [PGDCS 2011 Q2] [PGDCS 2010 Q.9] vii) Index [PGDCS 2011 Q2] [PGDCS 2010 Q.9] [PGDCS 2009 Q.7a] viii) Sequence [PGDCS 2011 Q2] [PGDCS 2010 Q.9] [PGDCS 2009 Q.7c] [PGDCS 2008 Q.3] ix) SDLC [PGDCS 2011 Q2] [PGDCS 2009 Q.2] x) DDL [PGDCS 2011 Q2] [PGDCS 2010 Q.9] [PGDCS 2008 Q.8a] xi) DML [PGDCS 2011 Q8a] [PGDCS 2009 Q.8a] [PGDCS 2008 Q.8a] xii) Normalization [PGDCS 2011 Q2] [PGDCS 2009 Q.2] [PGDCS 2008 Q.3] xiii) Subquery [PGDCS 2010 Q.9] xiv) Group Function [PGDCS 2010 Q.9] xv) Case Manipulation Function [PGDCS 2010 Q.9] xvi) Single Row Function [PGDCS 2009 Q.2] xvii) Cartesian Product [PGDCS 2009 Q.2] xviii) Object [PGDCS 2008 Q.3] xix) Polymorphism [PGDCS 2008 Q.3] xx) Encapsulation [PGDCS 2008 Q.3]View:A view consists of a stored query accessible as a virtual table in a relational database or a set of documents ina document-oriented database composed of the result set of a query or map and reduce functionsViews can provide advantages over tables:  Views can represent a subset of the data contained in a table  Views can join and simplify multiple tables into a single virtual table  Views can act as aggregated tables, where the database engine aggregates data (sum, average etc.) and presents the calculated results as part of the data  Views can hide the complexity of data;  Views take very little space to store; the database contains only the definition of a view, not a copy of all the data it presents  Depending on the SQL engine used, views can provide extra security  Views can limit the degree of exposure of a table or tables to the outer worldQuestion: Difference between Two Type of Views [PGDCS 2008 Q.10b]There are two types of VIEW in ORACLE: Simple View and Complex View  Simple view derives data from only one table but complex view derives data from many table  Simple view contain no functions or group of data but complex view contain function or group of data  Simple view always allow DML operation through the view but complex view does not always allow
    • 2Data Models:A data model s an abstract model that documents and organizes the business data for communication betweenteam members and is used as a plan for developing applications, specifically how data is stored and accessed.It is a combination of three components: 1) A collection of data structure types (the building blocks of any database that conforms to the model); 2) A collection of operators or inferencing rules, which can be applied to any valid instances of the data types listed in (1), to retrieve or derive data from any parts of those structures in any combinations desired; 3) A collection of general integrity rules, which implicitly or explicitly define the set of consistent database states or changes of state or both—these rules may sometimes be expressed as insert-update-delete rules.Unique Key:A unique key is used to uniquely identify rows in an Oracle table. There can be one and only one row for eachunique key value.Primary Key:A primary key is a single field or combination of fields that uniquely defines a record. None of the fields that arepart of the primary key can contain a null value. A table can have only one primary key.  In Oracle, a primary key can not contain more than 32 columns.  A primary key can be defined in either a CREATE TABLE statement or an ALTER TABLE statement.Foreign Key:A foreign key means that values in one table must also appear in another table.The referenced table is called the parent table while the table with the foreign key is called the child table. Theforeign key in the child table will generally reference a primary key in the parent table.A foreign key can be defined in either a CREATE TABLE statement or an ALTER TABLE statement.
    • 3Joins:A join clause combines records from two or more tables in a database. It creates a set that can be saved as a tableor used as is.A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQLspecifies four types of JOIN: INNER, OUTER, LEFT, and RIGHT. As a special case, a table (base table, view, or joinedtable) can JOIN to itself in a self-join.Examples:In the following tables the DepartmentID column of the Department table (which can be designatedas Department.DepartmentID) is the primary key, while Employee.DepartmentID is a foreign key.Employee table Department tableLastName DepartmentID DepartmentID DepartmentNameRafferty 31 31 SalesJones 33 33 EngineeringSteinberg 33 34 ClericalRobinson 34 35 MarketingSmith 34John NULLThe queries given in the examples above will join the Employee and Department tables using the DepartmentIDcolumn of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), thequery will combine the LastName, DepartmentID and DepartmentName columns from the two tables into a resultrow. Where the DepartmentID does not match, no result row is generated.Thus the result of the execution of either of the two queries above will be:Employee.LastName Employee.DepartmentID Department.DepartmentName Department.DepartmentIDRobinson 34 Clerical 34Jones 33 Engineering 33Smith 34 Clerical 34Steinberg 33 Engineering 33Rafferty 31 Sales 31Index:Index in oracle helps to trace the information faster just like an index in a book. Index entries keep informationabout the columns that are part of the index in a sorted order. If you query data with an index, the data retrieval ismuch faster.Example:The example below creates an index student_idx in table student for column student_nameCREATE INDEX student_idx ON student (student_name);
    • 4Sequence:Sequences are database objects from which multiple users can generate unique integers. We can use sequences toautomatically generate primary key values.Applications of SequencesAuto generation of numbers is the primary objective of a Sequence. It meets the below goals in an application.SDLCThe Systems Development LifeCycle (SDLC) is a process used in the development, creation, and maintenance of aninformation system. This process is often used in the creation or updating of a database system, and can serve as auseful tool for anyone trying to undertake a large database project.In software engineering, the SDLC concept underpins many kinds of software development methodologies. Thesemethodologies form the framework for planning and controlling the creation of an information system:the software development process.The SDLC has five phases: The Planning / Evaluation phase, the Analysis phase, the Design phase, theImplementation phase, and the Maintenance / Testing phaseModel of the Systems Development Life Cycle
    • 5DDLData Definition Language (DDL) statements are used to define the database structure or schema. Some examples: o CREATE - to create objects in the database o ALTER - alters the structure of the database o DROP - delete objects from the database o TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed o COMMENT - add comments to the data dictionary o RENAME - rename an objectDMLData Manipulation Language (DML) statements are used for managing data within schema objects. Someexamples: o SELECT - retrieve data from the a database o INSERT - insert data into a table o UPDATE - updates existing data within a table o DELETE - deletes all records from a table, the space for the records remain o MERGE - UPSERT operation (insert or update) o CALL - call a PL/SQL or Java subprogram o EXPLAIN PLAN - explain access path to data o LOCK TABLE - control concurrencyNormalization:Normalization is a series of steps followed to obtain a database design that allows for efficient access and storageof data. These steps reduce data redundancy and the chances of data becoming inconsistent.There are two goals of the normalization process eliminating redundant data (for example, storing the same datain more than one table) and ensuring data dependencies make sense (only storing related data in a table).First Normal Form eliminates repeating groups by putting each into a separate table and connecting them with aone-to-many relationship.Second Normal Form eliminates functional dependencies on a partial key by putting the fields in a separate tablefrom those that are dependent on the whole key.Third Normal Form eliminates functional dependencies on non-key fields by putting them in a separate table. Atthis stage, all non-key fields are dependent on the key, the whole key and nothing but the key.Subquery:A subquery is a query within a query.In Oracle, we can create subqueries within your SQL statements. These subqueries can reside in the WHERE clause,the FROM clause, or the SELECT clause.For example:select * from all_tablestabswhere tabs.table_name (select cols.table_namein from all_tab_columns cols where cols.column_name = SUPPLIER_ID);
    • 6GROUP FunctionThe GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group theresults by one or more columns.The syntax for the GROUP BY clause is:SELECT column1, column2, ... column_n, aggregate_function (expression)FROM tablesWHERE predicatesGROUP BY column1, column2, ... column_n;Case Manipulation Functions:Case-manipulation functions are used to convert from lower to upper or mixed case.These conversions can be used to format the output and when doing searches for specific strings.As can be seen in the following examples, Case- manipulation functions are often helpful when we are searchingfor data in an Oracle database if you do not know in which case the data records are stored. From Oracle’s pointof view ‘V’ and ‘v’ are NOT the same character, and it will therefore not return the record if you are not using thecorrect case when searching.LOWER(c): returns c with all characters converted to lower caseINITCAP(c): returns c with the first letter of each word converted to uppercase and the remaining letters tolowercase.UPPER(c): returns c with all characters converted to upper case To know more about different functions of Oracle go to following link: http://elearning.algonquincollege.com/coursemat/dat2355d/functions.htmlSingle-row functionThe single row functions operate on single rows and return only one result per row. In general, the functions takeone or more inputs as arguments and return a single value as output. The arguments can be a user-suppliedconstant, variable, column name and an expression.The features of single row functions are: Act on each row returned in the query. Perform calculations on data. Modify the data items. Manipulate the output for groups of rows. Format numbers and dates. Converts column data types. Returns one result per row. Used in SELECT, WHERE and ORDER BY clauses. Single row functions can be nested.The single row functions are categorized into: Character Functions: Character functions accept character inputs and can return either character or numbervalues as output. Number Functions: Number functions accepts numeric inputs and returns only numeric values as output. Date Functions: Date functions operate on date data type and returns a date value or numeric value. Conversions Functions: Converts from one data type to another data type. General Functions To see the examples of Single Row function go to the link http://www.folkstalk.com/2012/01/oracle-single-row-functions-examples.html
    • 7Cartesian Products:If two tables in a join query have no join condition, then Oracle Database returns their Cartesian product. Oraclecombines each row of one table with each row of the other. A Cartesian product always generates many rows andis rarely useful.For example, the Cartesian product of two tables, each with 100 rows, has 10,000 rows. Always include a joincondition unless you specifically need a Cartesian product. If a query joins three or more tables and you do notspecify a join condition for a specific pair, then the optimizer may choose a join order that avoids producing anintermediate Cartesian product.A Cartesian product is formed when:  A join condition is omitted  A join condition is invalid  All rows in the first table are joined to all rows in the second tableObject: Database tables contain only data. Objects can include the ability to perform operations that are likely to be needed on that data. Thus a purchase order object might include a method to sum the cost of all the items purchased. Or a customer object might have methods to return the customers buying history and payment pattern. An application can simply call the methods to retrieve the information.Using object types makes for greater efficiency:  Object types and their methods are stored with the data in the database, so they are available for any application to use. Developers can benefit from work that is already done and do not need to re-create similar structures in every application.  We can fetch and manipulate a set of related objects as a single unit. A single request to fetch an object from the server can retrieve other objects that are connected to it. For example, when you select a customer object and get the customers name, phone, and the multiple parts of his address in a single round-trip between the client and the server. When you reference a column of a SQL object type, we retrieve the whole object.Example of An Object Type and Object Instances
    • 8Polymorphism:Polymorphism is the ability to use an operator or function in different ways "Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of object. Example: function overloading, function overriding, virtual functions. Another example can be a plus + sign, used for adding two integers or for using it to concatenate two strings. It has two types 1) Run time polymorphism 2) Compile time Polymorphism function overloading, function overriding, operator overloading are the examples of Compile Time & Virtual Function is example of Run timeEncapsulationEncapsulation describes the ability of an object to hide its data and methods from the rest of the world - one ofthe fundamental principles of OOP (Object Oriented Programming).Question: Define DBMS [PGDCS 2011:Q3] [PGDCS 2009 Q.3] [PGDCS 2008 Q.4]DBMS (Database Management System) is a program that defines the rules for data storage and retrieval.A DBMS allows different user application programs to concurrently access the same database. DBMSs may use avariety of database models, such as the relational model or object model, to conveniently describe and supportapplications.Question: Describe Twelve rule of Dr.E.F Codd. [PGDCS 2011 Q.3] [PGDCS 2010 Q.6a] [PGDCS 2009 Q.3b] [PGDCS 2008 Q.4]Codds twelve rules are a set of thirteen rules (numbered zero to twelve) proposed by Edgar F. Codd, a pioneer ofthe relational model fordatabases, designed to define what is required from a database management system inorder for it to be considered relational, i.e., a relational database management system (RDBMS).The rulesRule 1: Information Rule=>All Information (inlcuding metadata) is to be represented as data stored in cells of tables.=>The rows and columns have to be strictly unordered.Rule 2: Guaranteed Access=>Each unique piece of data (atomic value) should be accesible by : TableName + Primary Key (Row) + Attribute(Column)=>Violation: Ability to directly access via pointersRule3: Systematic treatment of NULL values=> NULLs may mean: Missing data, Not applicable, No value=> Should be handled consistently – Not Zero or Blank=> Primary keys — Not NULL=> expressions on NULL should give NULLRule4: Active On-Line Catalog=>Database dictionary (Catalog) to have description of the Database=>Catalog to be governed by same rules as rest of the database=>The same query language to be used on catalog as on the application database
    • 9Rule5: Powerful language=>One well defined language to provide all manners of access to data=>Example: SQL=>If file supporting table can be accessed by any manner except a SQL Interface, then a violationRule6: View Updation Rule=>All views that are theoretically updatable should be updatable=>View = ”Virtual table”, temporarily derived from base tables=>Example: If a view is formed as join of 3 tables, changes to view should be reflected in base tables=>Not updatable: View does not have NOT-NULL attribute of base table=>Problems with computed fields in view e.g. Total Income = White income + Black incomeRule7:Relational level operations=>There must be insert, update, delete operations at the level of Relations=>Set operations like Union,Intersection and Minus should be supportedRule8: Physical Data Independence=>The physical storage of data should not matter to the system=>If say, some file supporting table was renamed or moved from one disk to another, it should not effect theapplications.Rule9: Logical Data Independence=>If there is change in the logical structure (table structures) of the database the user view of the data should notchange=>implemented through views. Say, if a table is split into two tables, a new view should give result as the join ofthe two tables=>Difficult rule to satisfyRule10: Integrity Independence=>The database should be able to enforce its own integrity rather than using other programs=>Integrity rules = Filter to allow correct data, should be stored in Data Dictionary=>Key and check constraints, triggers etc should be stored in Data Dictionary=>This also makes RDBMS independent of front endRule11: Distribution Independence=>A database should work properly regardless of its distribution across a network=>This lays foundation of Distributed databases=>Similiar to Rule8 only that applies to distribution on a local DiskRule12: Nonsubversion Rule=>If low level access is allowed to a system it should not be able to subvert or bypass integrity rules to change data=>This may be achieved by some sort of locking or encryption=>Some low level access tools are provided by vendors that violate these rules for extra speedQuestion: What is ER Modelling? [PGDCS 2011 Q4a] [PGDCS 2010 Q.8a] [PGDCS 2009 Q.4a] [PGDCS 2008 Q.5a]An entity-relationship model (ER model for short) is an abstract and conceptual representation of data. Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semanticdata model of a system, often a relational database, and its requirements in a top-down fashion. Diagrams createdby this process are called entity-relationship diagrams or ER diagrams.Features of the E-R Model: 1. The E-R diagram used for representing E-R Model can be easily converted into Relations (tables) in Relational Model. 2. The E-R Model is used for the purpose of good database design by the database developer so to use that data model in various DBMS. 3. It is helpful as a problem decomposition tool as it shows the entities and the relationship between those entities. 4. It is inherently an iterative process. On later modifications, the entities can be inserted into this model. 5. It is very simple and easy to understand by various types of users and designers because specific standards are used for their representation.
    • 10 An Example of ER Model: The sentence contains a subject (boy), an object (ice cream) and a verb (eats) that defines the relationship between the subject and the object We now have defined structures for at least three tables like the following: Table Boy Name Address Phone Table Ice Cream Manufacturer Flavour Price Table Eats Date Time Question: Describe the Benefits of ER Modeling: [PGDCS 2011 Q4b] [PGDCS 2010 Q.8b] [PGDCS 2009 Q.4b] [PGDCS 2008 Q.5b] Conceptual simplicity Visual representation Effective communication Integration with the relational database model Question: Describe the Key Components of ER Modeling [PGDCS 2011 Q4c] [PGDCS 2010 Q.8c] [PGDCS 2009 Q.4c] [PGDCS 2008 Q.5c] The three main components of an ERD are: Entities: The entity is a person, object, place or event for which data is collected. For example, if you consider the information system for a business, entities would include not only customers, but the customers address, and orders as well. The entity is represented by a rectangle and labelled with a singular noun. Attribute: The relationship is the interaction between the entities. In the example above, the customer places an order, so the word "places" defines the relationship between that instance of a customer and the order or orders that they place. A relationship may be represented by a diamond shape, or more simply, by the line connecting the entities. In either case, verbs are used to label the relationships. Relationship: The cardinality defines the relationship between the entities in terms of numbers. An entity may be optional: for example, a sales rep could have no customers or could have one or many customers; or mandatory: for example, there must be at least one product listed in an order. There are several different types of cardinality notation; crows foot notation, used here, is a common one. In crows foot notation, a single bar indicatesone, a double bar indicates one and only one (for example, a single instance of a product can only be stored in one warehouse), a circle indicates zero, and a crows footindicates many. The three main cardinal relationships are: one-to-one, expressed as 1:1; one-to-many, expressed as 1:M; and many-to-many, expressed as M:N.
    • 11Question: Describe the Rules of conversion of ERD into Tables[PGDCS 2011 Q4d] [PGDCS 2010 Q.8d] [PGDCS 2009 Q.4d] [PGDCS 2008 Q.5c]Basic Conversion RulesThe basic rules convert everything on the ERD except generalization hierarchies. You should apply these rules untileverything on an ERD is converted except for generalization hierarchies. You should use the first 2 rules before theother rules. As you apply these rules, you can use a check mark to indicate the converted parts of an ERD. 1. Entity Type Rule: Each entity type (except subtypes) becomes a table. The PK of ET (if not weak) becomes the PK of the table. The attributes of the ET become columns in the table. This rule should be used first before the relationship rules. 2. 1-M Relationship Rule: Each 1-M relationship becomes a FK in the table corresponding to the child type (the entity type near Crow’s Foot symbol). If the minimum cardinality on the parent side of the relationship is one, the FK cannot accept null values (NOT NULL must be used). 3. M-N Relationship Rule: Each M-N relationship becomes a separate table. The PK of the table is a combined key consisting of the primary keys of the entity types participating in the M-N relationship. 4. Identification Dependency Rule: Each identifying relationship (denoted by a solid relationship line) adds a component to a PK. The PK of the table corresponding to the weak entity consists of: a) The underlined local key (if any) in the weak entity and b) The PK(s) of the entity type(s) connected by identifying relationship(s).[ PK = Primary Key; FK = Foreign Key; ET: Entity Type]Question: Write 8(Eight) Character functions in Oracle [PGDCS 2011 Q7a]A character function is a function that takes one or more character values as parameters and returns either acharacter value or a number value. The Built-In Character Functions (In Answer sheet Write any Eight functions) Name Description ASCII Returns the ASCII code of a character. CHR Returns the character associated with the specified collating code. CONCAT Concatenates two strings into one. INITCAP Sets the first letter of each word to uppercase. All other letters are set to lowercase. INSTR Returns the location in a string of the specified substring. LENGTH Returns the length of a string. LOWER Converts all letters to lowercase. LPAD Pads a string on the left with the specified characters. LTRIM Trims the left side of a string of all specified characters. REPLACE Replaces a character sequence in a string with a different set of characters. RPAD Pads a string on the right with the specified characters. RTRIM Trims the right side of a string of all specified characters. SOUNDEX Returns the "soundex" of a string. SUBSTR Returns the specified portion of a string. TRANSLATE Translates single characters in a string to different characters. UPPER Converts all letters in the string to uppercase.
    • 12Question: What is Role? How to Create and grant privileges to a Role? [PGDCS 2011 Q7b] [PGDCS 2010 Q.5b]A role is a set or group of privileges that can be granted to users or another role. This is a great way for databaseadministrators to save time and effort.Creating a RoleTo create a role, you must have CREATE ROLE system privileges.The syntax for creating a role is: CREATE ROLE role_name [ NOT IDENTIFIED | IDENTIFIED {BY password | USING [schema.] package | EXTERNALLY | GLOBALLY } ;Note: If both the NOT IDENTIFIED and IDENTIFIED phrases are omitted in the CREATE ROLE statement, the role will be created as a NOTIDENTIFIED role.The role_name phrase is the name of the new role that you are creating. This is how you will refer to the grouping of privileges.The NOT IDENTIFIED phrase means that the role is immediately enabled. No password is required to enable the role.The IDENTIFIED phrase means that a user must be authorized by a specified method before the role is enabled.The BY password phrase means that a user must supply a password to enable the role.The USING package phrase means that you are creating an application role - a role that is enabled only by applications using anauthorized package.The EXTERNALLY phrase means that a user must be authorized by an external service to enable the role. An external service canbe an operating system or third-party service.The GLOBALLY phrase means that a user must be authorized by the enterprise directory service to enable the role.For Example: CREATE ROLE test_role;This first example creates a role called test_role. CREATE ROLE test_role IDENTIFIED BY test123;This second example creates the same role called test_role, but now it is password protected with the password oftest123.Grant Privileges (on Tables) to RolesYou can grant roles various privileges to tables. These privileges can be any combination of select, insert, update,delete, references, alter, and index. Below is an explanation of what each privilege means. Privilege Description Select Ability to query the table with a select statement. Insert Ability to add new rows to the table with the insert statement. Update Ability to update rows in the table with the update statement. Delete Ability to delete rows from the table with the delete statement. References Ability to create a constraint that refers to the table. Alter Ability to change the table definition with the alter table statement. Index Ability to create an index on the table with the create index statement.The syntax for granting privileges on a table is: grant privileges on object to role_nameFor example, if we wanted to grant select, insert, update, and delete privileges on a table called suppliers to a rolenamed test_role, you would execute the following statement: grant select, insert, update, delete on suppliers to test_role;You can also use the all keyword to indicate that you wish all permissions to be granted. For example: grant all on suppliers to test_role; [Details about Roles: http://www.techonthenet.com/oracle/roles.php]
    • 13Question: List any Six Datatypes used in Oracle. [PGDCS 2010 Q.8c]Oracle Built-in DatatypesBuilt-In Datatype Syntaxcharacter_datatypes { CHAR [ (size [ BYTE | CHAR ]) ] | VARCHAR2 (size [ BYTE | CHAR ]) | NCHAR [ (size) ] | NVARCHAR2 (size) }datetime_datatypes { DATE | TIMESTAMP [ (fractional_seconds_precision) ] [ WITH [ LOCAL ] TIME ZONE ]) | INTERVAL YEAR [ (year_precision) ] TO MONTH | INTERVAL DAY [ (day_precision) ] TO SECOND [ (fractional_seconds_precision) ] }large_object_datatypes { BLOB | CLOB | NCLOB | BFILE }long_and_raw_datatypes { LONG | LONG RAW | RAW (size) }number_datatypes { NUMBER [ (precision [, scale ]) ] | BINARY_FLOAT | BINARY_DOUBLE }rowid_datatypes { ROWID | UROWID [ (size) ] } To know more datatypes got to the link: http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10758/sqlqr06.htmQuestion: What is Rollback? Describe the state of data before and after Rollback.[PGDCS 2010 Q.4a][PGDCS 2008 Q.3]The ROLLBACK statement is the inverse of the COMMIT statement. It undoes some or all database changes madeduring the current transaction.The ROLLBACK statement ends the current transaction and undoes any changes made during that transaction. Ifwe make a mistake, such as deleting the wrong row from a table, a rollback restores the original data. If we cannotfinish a transaction because an exception is raised or a SQL statement fails, a rollback lets us take corrective actionand perhaps start over.We should explicitly commit or roll back every transaction. Whether we issue the commit or rollback in our SQLprogram or from a client program depends on the application logic. If we do not commit or roll back a transactionexplicitly, the client environment determines its final state.Question: When a database Transaction Occurred? Describe the state of Data after commit.[PGDCS 2010 Q.4b]We Use the COMMIT statement to end current transaction and make permanent all changes performed in thetransaction. A transaction is a sequence of SQL statements that Oracle Database treats as a single unit. Thisstatement also erases all savepoints in the transaction and releases transaction locks.Oracle Database issues an implicit COMMIT before and after any data definition language (DDL) statement.We can also use this statement to  Commit an in-doubt distributed transaction manually  Terminate a read-only transaction begun by a SET TRANSACTION statement
    • 14Question: Which Types of DCL statements are used in Oracle? [PGDCS 2010 Q.4c] [PGDCS 2009 Q.2]Data Control Language (DCL) statements. There are two types of DCL commands in Oracle: o GRANT - gives users access privileges to database o REVOKE - withdraw access privileges given with the GRANT commandQuestion:Why constraints are used in database? List the Constraints types used in Oracle.[PGDCS 2011 Q9a] [PGDCS 2010 Q.6a] [PGDCS 2010 Q.9a] [PGDCS 2008 Q.9a]Oracle constraints are means in the process of defining some conditions about the database that must remain truewhile inputting/modifying/deleting data in the database.Constraints are used to enforce table rules and prevent data dependent deletion (enforce database integrity). Youmay also use them to enforce business rules (with some magination).We Use a constraint to define an integrity constraint—a rule that restricts the values in a database.Oracle Database lets us create six types of constraints  A NOT NULL constraint prohibits a database value from being null.  A unique constraint prohibits multiple rows from having the same value in the same column or combination of columns but allows some values to be null.  A primary key constraint combines a NOT NULL constraint and a unique constraint in a single declaration. That is, it prohibits multiple rows from having the same value in the same column or combination of columns and prohibits values from being null.  A foreign key constraint requires values in one table to match values in another table.  A check constraint requires a value in the database to comply with a specified condition.  A REF column by definition references an object in another object type or in a relational table. A REF constraint lets you further describe the relationship between the REF column and the object it references.Question: Describe the functions of DBA. [PGDCS 2010 Q.7a]Functions of DBA? Database administration is more of an operational or technical level function responsible for physical databasedesign, security enforcement, and database performance. Tasks include maintaining the data dictionary,monitoring performance, and enforcing organizational standards and security.1. Selection of hardware and software  Keep up with current technological trends  Predict future changes  Emphasis on established off the shelf products2. Managing data security and privacy  Protection of data against accidental or intentional loss, destruction, or misuse  Firewalls  Establishment of user privileges
    • 15  Complicated by use of distributed systems such as internet access and client/ server technology.3. Managing Data Integrity  Integrity controls protects data from unauthorized use  Data consistency  Maintaining data relationship  Domains- sets allowable values  Assertions- enforce database conditions4. Data backup  We must assume that a database will eventually fail  Establishment procedures o how often should the data be back-up? o what data should be backed up more frequently? o who is responsible for the back ups?  Back up facilities o automatic dump- facility that produces backup copy of the entire database o periodic backup- done on periodic basis such as nightly or weekly o cold backup- database is shut down during backup o hot backup- a selected portion of the database is shut down and backed up at a given time o backups stored in a secure, off-site location5. Database recovery  Application of proven strategies for reinstallation of database after crash  Recovery facilities include backup, journalizing, checkpoint, and recovery manager  Journalizing facilities include: o audit trail of transactions and database updates o transaction log which records essential data for each transaction processed against the database o database change log shows images of updated data. The log stores a copy of the image before and after modification.  Checkpoint facilities: o when the DBMS refuses to accept a new transaction, the system is in a quiet state o database and transactions are synchronized o allows the recovery manager to resume processing from a short period instead of repeating the entire day  Recovery and Restart Procedures o switch- mirrored databases o restore/rerun- reprocess transactions against the backup o transaction integrity- commit or abort all transaction changes o backward recovery (rollback)- apply before images6. Tuning database performance  Set installation parameters/ upgrade DBMS  Monitor memory and CPU usage  Input/ output contention o user striping o distribution of heavily accessed files
    • 16  Application tuning by modifying SQL code in application7. Improving query processing performance[PGDCS 2011 Q5]Problem:Analyze a system that records information about people allocated to projects. During the analysis we identifiedvarious attributes concerning the enterprise: Project code, Project Type, Project Description, Employee ID, Employee Name, Employee Grade, Salary Scale, Date Employee joined project, Allocated time of employee in project, Department ID, Department Name.UnNormalized TableProject CodeProject TypeProject DescriptionEmployee IDEmployee NameEmployee GradeSalary ScaleDate of Employee Joined ProjectAllocated time of employee on ProjectDepartment IDDepartment NameFirst Normal Form  Eliminate repeating groups in individual tables.  Create a separate table for each set of related data.  Identify each set of related data with a primary key.Project CodeProject TypeProject DescriptionEmployee IDEmployee NameEmployee GradeSalary ScaleDate of Employee Joined ProjectAllocated time of employee on ProjectDepartment IDDepartment NameSecond Normal Form  Create separate tables for sets of values that apply to multiple records.  Relate these tables with a foreign key. PK Project Code Project Type Project Description
    • 17. PK Employee ID Employee Name Date of Employee Joined Project Allocated time of employee on ProjectFK Employee GradePK Employee Grade Salary Scale Department ID Department NameThird Normal Form  Eliminate fields that do not depend on the key.Project Table. PK Project Code Project Type Project DescriptionEmployee TablePK Employee IDFK Project Code Date of Employee Joined Project Allocated time of employee on ProjectGrade TablePK Employee Grade Salary ScaleDepartment TablePK Department ID Department Name Learn Normalization from Youtube Demonstration: http://www.youtube.com/watch?v=fg7r3DgS3rA