SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
1


                                                      PGDCS
                                           Descriptive Answers of DBMS
Short 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 in
a document-oriented database composed of the result set of a query or map and reduce functions

Views 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 world

Question: 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
2



Data Models:
A data model s an abstract model that documents and organizes the business data for communication between
team 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 each
unique 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 are
part 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. The
foreign 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.
3


Joins:
A join clause combines records from two or more tables in a database. It creates a set that can be saved as a table
or used as is.

A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQL
specifies four types of JOIN: INNER, OUTER, LEFT, and RIGHT. As a special case, a table (base table, view, or joined
table) can JOIN to itself in a self-join.

Examples:
In the following tables the DepartmentID column of the Department table (which can be designated
as Department.DepartmentID) is the primary key, while Employee.DepartmentID is a foreign key.

Employee table                           Department table
LastName DepartmentID                    DepartmentID DepartmentName
Rafferty    31                           31                  Sales
Jones       33                           33                  Engineering
Steinberg 33                             34                  Clerical
Robinson 34                              35                  Marketing
Smith       34
John        NULL

The queries given in the examples above will join the Employee and Department tables using the DepartmentID
column of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), the
query will combine the LastName, DepartmentID and DepartmentName columns from the two tables into a result
row. 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.DepartmentID
Robinson              34                          Clerical                          34
Jones                 33                          Engineering                       33
Smith                 34                          Clerical                          34
Steinberg             33                          Engineering                       33
Rafferty              31                          Sales                             31

Index:
Index in oracle helps to trace the information faster just like an index in a book. Index entries keep information
about the columns that are part of the index in a sorted order. If you query data with an index, the data retrieval is
much faster.

Example:
The example below creates an index student_idx in table student for column student_name
CREATE INDEX student_idx
     ON student (student_name);
4


Sequence:
Sequences are database objects from which multiple users can generate unique integers. We can use sequences to
automatically generate primary key values.


Applications of Sequences
Auto generation of numbers is the primary objective of a Sequence. It meets the below goals in an application.




SDLC
The Systems Development LifeCycle (SDLC) is a process used in the development, creation, and maintenance of an
information system. This process is often used in the creation or updating of a database system, and can serve as a
useful tool for anyone trying to undertake a large database project.
In software engineering, the SDLC concept underpins many kinds of software development methodologies. These
methodologies 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, the
Implementation phase, and the Maintenance / Testing phase




Model of the Systems Development Life Cycle
5


DDL
Data 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 object

DML
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some
examples:

    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 concurrency

Normalization:
Normalization is a series of steps followed to obtain a database design that allows for efficient access and storage
of 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 data
in 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 a
one-to-many relationship.
Second Normal Form eliminates functional dependencies on a partial key by putting the fields in a separate table
from 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. At
this 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_tables
tabs
where tabs.table_name (select cols.table_name
in
                         from all_tab_columns cols
                         where cols.column_name = 'SUPPLIER_ID');
6


GROUP Function
The GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the
results by one or more columns.

The syntax for the GROUP BY clause is:
SELECT column1, column2, ... column_n, aggregate_function (expression)
FROM tables
WHERE predicates
GROUP 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 searching
for data in an Oracle database if you do not know in which case the data records are stored. From Oracle’s point
of view ‘V’ and ‘v’ are NOT the same character, and it will therefore not return the record if you are not using the
correct case when searching.

LOWER(c): returns c with all characters converted to lower case
INITCAP(c): returns c with the first letter of each word converted to uppercase and the remaining letters to
lowercase.
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.html
Single-row function
The single row functions operate on single rows and return only one result per row. In general, the functions take
one or more inputs as arguments and return a single value as output. The arguments can be a user-supplied
constant, 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 number
values 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
7


Cartesian Products:
If two tables in a join query have no join condition, then Oracle Database returns their Cartesian product. Oracle
combines each row of one table with each row of the other. A Cartesian product always generates many rows and
is rarely useful.

For example, the Cartesian product of two tables, each with 100 rows, has 10,000 rows. Always include a join
condition unless you specifically need a Cartesian product. If a query joins three or more tables and you do not
specify a join condition for a specific pair, then the optimizer may choose a join order that avoids producing an
intermediate 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 table

Object:
    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 customer's 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 customer's 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
8


Polymorphism:
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 time


Encapsulation
Encapsulation describes the ability of an object to hide its data and methods from the rest of the world - one of
the 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 a
variety of database models, such as the relational model or object model, to conveniently describe and support
applications.

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]
Codd's twelve rules are a set of thirteen rules (numbered zero to twelve) proposed by Edgar F. Codd, a pioneer of
the relational model fordatabases, designed to define what is required from a database management system in
order for it to be considered relational, i.e., a relational database management system (RDBMS).

The rules
Rule 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 pointers
Rule3: 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 NULL
Rule4: 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
9


Rule5: 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 violation
Rule6: 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 income
Rule7:Relational level operations
=>There must be insert, update, delete operations at the level of Relations
=>Set operations like Union,Intersection and Minus should be supported
Rule8: 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 the
applications.
Rule9: Logical Data Independence
=>If there is change in the logical structure (table structures) of the database the user view of the data should not
change
=>implemented through views. Say, if a table is split into two tables, a new view should give result as the join of
the two tables
=>Difficult rule to satisfy
Rule10: 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 end
Rule11: 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 Disk
Rule12: 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 speed

Question: 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 semantic
data model of a system, often a relational database, and its requirements in a top-down fashion. Diagrams created
by 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 customer's 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; crow's foot notation, used here, is a common one. In crow's 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 crow's 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.
11


Question: 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 Rules
The basic rules convert everything on the ERD except generalization hierarchies. You should apply these rules until
everything on an ERD is converted except for generalization hierarchies. You should use the first 2 rules before the
other 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 a
character 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.
12


Question: 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 database
administrators to save time and effort.

Creating a Role
To 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 NOT
IDENTIFIED 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 an
authorized package.
The EXTERNALLY phrase means that a user must be authorized by an external service to enable the role. An external service can
be 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 of
test123.

Grant Privileges (on Tables) to Roles
You 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_name
For example, if we wanted to grant select, insert, update, and delete privileges on a table called suppliers to a role
named 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]
13



Question: List any Six Datatypes used in Oracle.                      [PGDCS 2010 Q.8c]


Oracle Built-in Datatypes


Built-In Datatype                         Syntax
character_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.htm

Question: 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 made
during the current transaction.

The ROLLBACK statement ends the current transaction and undoes any changes made during that transaction. If
we make a mistake, such as deleting the wrong row from a table, a rollback restores the original data. If we cannot
finish a transaction because an exception is raised or a SQL statement fails, a rollback lets us take corrective action
and perhaps start over.

We should explicitly commit or roll back every transaction. Whether we issue the commit or rollback in our SQL
program or from a client program depends on the application logic. If we do not commit or roll back a transaction
explicitly, 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 the
transaction. A transaction is a sequence of SQL statements that Oracle Database treats as a single unit. This
statement 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
14


Question: 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 user's access privileges to database
    o    REVOKE - withdraw access privileges given with the GRANT command




Question: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 true
while inputting/modifying/deleting data in the database.

Constraints are used to enforce table rules and prevent data dependent deletion (enforce database integrity). You
may 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 database
design, 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 products

2. 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 conditions

4. 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 location

5. 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 images

6. 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 application

7. Improving query processing performance

[PGDCS 2011 Q5]
Problem:
Analyze a system that records information about people allocated to projects. During the analysis we identified
various 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 Table
Project Code
Project Type
Project Description
Employee ID
Employee Name
Employee Grade
Salary Scale
Date of Employee Joined Project
Allocated time of employee on Project
Department ID
Department Name


First 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 Code
Project Type
Project Description


Employee ID
Employee Name
Employee Grade
Salary Scale
Date of Employee Joined Project
Allocated time of employee on Project
Department ID
Department Name

Second 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 Project
FK      Employee Grade


PK     Employee Grade
       Salary Scale
       Department ID
       Department Name


Third Normal Form
     Eliminate fields that do not depend on the key.


Project Table
. PK    Project Code
        Project Type
        Project Description


Employee Table
PK     Employee ID
FK     Project Code
       Date of Employee Joined Project
       Allocated time of employee on Project


Grade Table
PK     Employee Grade
       Salary Scale


Department Table
PK     Department ID
       Department Name


                                                  Learn Normalization from Youtube Demonstration:
                                                  http://www.youtube.com/watch?v=fg7r3DgS3rA

Más contenido relacionado

La actualidad más candente

BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comagathachristie291
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro projectARVIND SARDAR
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comthomashard72
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comagathachristie256
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comKeatonJennings120
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comagathachristie241
 
Practical index dms 22319
Practical index dms 22319Practical index dms 22319
Practical index dms 22319ARVIND SARDAR
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comkopiko33
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comagathachristie204
 
CIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comCIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comkopiko105
 

La actualidad más candente (17)

BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.com
 
Database Architecture
Database ArchitectureDatabase Architecture
Database Architecture
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.com
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.com
 
Practical index dms 22319
Practical index dms 22319Practical index dms 22319
Practical index dms 22319
 
Sq lite module2
Sq lite module2Sq lite module2
Sq lite module2
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.com
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.com
 
Sq lite module9
Sq lite module9Sq lite module9
Sq lite module9
 
Sq lite module1
Sq lite module1Sq lite module1
Sq lite module1
 
Sq lite module4
Sq lite module4Sq lite module4
Sq lite module4
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
PT- Oracle session01
PT- Oracle session01 PT- Oracle session01
PT- Oracle session01
 
CIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comCIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.com
 

Similar a Dbms narrative question answers

Database Performance
Database PerformanceDatabase Performance
Database PerformanceBoris Hristov
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement systemFaisalGhffar
 
SQL Tutorial
SQL TutorialSQL Tutorial
SQL Tutorialziamd
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Aaron Shilo
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredDanish Mehraj
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-bookVipul Wankar
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-bookVipul Wankar
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorialMohd Tousif
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Rakibul Hasan Pranto
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-convertedgayaramesh
 
NoSQL - A Closer Look to Couchbase
NoSQL - A Closer Look to CouchbaseNoSQL - A Closer Look to Couchbase
NoSQL - A Closer Look to CouchbaseMohammad Shaker
 

Similar a Dbms narrative question answers (20)

Database Performance
Database PerformanceDatabase Performance
Database Performance
 
DBMS summer 19.pdf
DBMS summer 19.pdfDBMS summer 19.pdf
DBMS summer 19.pdf
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
 
SQL
SQLSQL
SQL
 
SQL Tutorial
SQL TutorialSQL Tutorial
SQL Tutorial
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
 
Db2 faqs
Db2 faqsDb2 faqs
Db2 faqs
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
Database testing
Database testingDatabase testing
Database testing
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
T6
T6T6
T6
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-book
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-book
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
SQL
SQLSQL
SQL
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-converted
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
NoSQL - A Closer Look to Couchbase
NoSQL - A Closer Look to CouchbaseNoSQL - A Closer Look to Couchbase
NoSQL - A Closer Look to Couchbase
 

Último

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Último (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Dbms narrative question answers

  • 1. 1 PGDCS Descriptive Answers of DBMS Short 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 in a document-oriented database composed of the result set of a query or map and reduce functions Views 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 world Question: 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
  • 2. 2 Data Models: A data model s an abstract model that documents and organizes the business data for communication between team 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 each unique 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 are part 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. The foreign 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.
  • 3. 3 Joins: A join clause combines records from two or more tables in a database. It creates a set that can be saved as a table or used as is. A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQL specifies four types of JOIN: INNER, OUTER, LEFT, and RIGHT. As a special case, a table (base table, view, or joined table) can JOIN to itself in a self-join. Examples: In the following tables the DepartmentID column of the Department table (which can be designated as Department.DepartmentID) is the primary key, while Employee.DepartmentID is a foreign key. Employee table Department table LastName DepartmentID DepartmentID DepartmentName Rafferty 31 31 Sales Jones 33 33 Engineering Steinberg 33 34 Clerical Robinson 34 35 Marketing Smith 34 John NULL The queries given in the examples above will join the Employee and Department tables using the DepartmentID column of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), the query will combine the LastName, DepartmentID and DepartmentName columns from the two tables into a result row. 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.DepartmentID Robinson 34 Clerical 34 Jones 33 Engineering 33 Smith 34 Clerical 34 Steinberg 33 Engineering 33 Rafferty 31 Sales 31 Index: Index in oracle helps to trace the information faster just like an index in a book. Index entries keep information about the columns that are part of the index in a sorted order. If you query data with an index, the data retrieval is much faster. Example: The example below creates an index student_idx in table student for column student_name CREATE INDEX student_idx ON student (student_name);
  • 4. 4 Sequence: Sequences are database objects from which multiple users can generate unique integers. We can use sequences to automatically generate primary key values. Applications of Sequences Auto generation of numbers is the primary objective of a Sequence. It meets the below goals in an application. SDLC The Systems Development LifeCycle (SDLC) is a process used in the development, creation, and maintenance of an information system. This process is often used in the creation or updating of a database system, and can serve as a useful tool for anyone trying to undertake a large database project. In software engineering, the SDLC concept underpins many kinds of software development methodologies. These methodologies 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, the Implementation phase, and the Maintenance / Testing phase Model of the Systems Development Life Cycle
  • 5. 5 DDL Data 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 object DML Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples: 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 concurrency Normalization: Normalization is a series of steps followed to obtain a database design that allows for efficient access and storage of 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 data in 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 a one-to-many relationship. Second Normal Form eliminates functional dependencies on a partial key by putting the fields in a separate table from 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. At this 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_tables tabs where tabs.table_name (select cols.table_name in from all_tab_columns cols where cols.column_name = 'SUPPLIER_ID');
  • 6. 6 GROUP Function The GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns. The syntax for the GROUP BY clause is: SELECT column1, column2, ... column_n, aggregate_function (expression) FROM tables WHERE predicates GROUP 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 searching for data in an Oracle database if you do not know in which case the data records are stored. From Oracle’s point of view ‘V’ and ‘v’ are NOT the same character, and it will therefore not return the record if you are not using the correct case when searching. LOWER(c): returns c with all characters converted to lower case INITCAP(c): returns c with the first letter of each word converted to uppercase and the remaining letters to lowercase. 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.html Single-row function The single row functions operate on single rows and return only one result per row. In general, the functions take one or more inputs as arguments and return a single value as output. The arguments can be a user-supplied constant, 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 number values 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
  • 7. 7 Cartesian Products: If two tables in a join query have no join condition, then Oracle Database returns their Cartesian product. Oracle combines each row of one table with each row of the other. A Cartesian product always generates many rows and is rarely useful. For example, the Cartesian product of two tables, each with 100 rows, has 10,000 rows. Always include a join condition unless you specifically need a Cartesian product. If a query joins three or more tables and you do not specify a join condition for a specific pair, then the optimizer may choose a join order that avoids producing an intermediate 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 table Object: 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 customer's 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 customer's 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
  • 8. 8 Polymorphism: 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 time Encapsulation Encapsulation describes the ability of an object to hide its data and methods from the rest of the world - one of the 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 a variety of database models, such as the relational model or object model, to conveniently describe and support applications. 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] Codd's twelve rules are a set of thirteen rules (numbered zero to twelve) proposed by Edgar F. Codd, a pioneer of the relational model fordatabases, designed to define what is required from a database management system in order for it to be considered relational, i.e., a relational database management system (RDBMS). The rules Rule 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 pointers Rule3: 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 NULL Rule4: 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
  • 9. 9 Rule5: 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 violation Rule6: 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 income Rule7:Relational level operations =>There must be insert, update, delete operations at the level of Relations =>Set operations like Union,Intersection and Minus should be supported Rule8: 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 the applications. Rule9: Logical Data Independence =>If there is change in the logical structure (table structures) of the database the user view of the data should not change =>implemented through views. Say, if a table is split into two tables, a new view should give result as the join of the two tables =>Difficult rule to satisfy Rule10: 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 end Rule11: 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 Disk Rule12: 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 speed Question: 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 semantic data model of a system, often a relational database, and its requirements in a top-down fashion. Diagrams created by 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. 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 customer's 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; crow's foot notation, used here, is a common one. In crow's 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 crow's 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.
  • 11. 11 Question: 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 Rules The basic rules convert everything on the ERD except generalization hierarchies. You should apply these rules until everything on an ERD is converted except for generalization hierarchies. You should use the first 2 rules before the other 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 a character 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.
  • 12. 12 Question: 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 database administrators to save time and effort. Creating a Role To 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 NOT IDENTIFIED 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 an authorized package. The EXTERNALLY phrase means that a user must be authorized by an external service to enable the role. An external service can be 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 of test123. Grant Privileges (on Tables) to Roles You 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_name For example, if we wanted to grant select, insert, update, and delete privileges on a table called suppliers to a role named 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]
  • 13. 13 Question: List any Six Datatypes used in Oracle. [PGDCS 2010 Q.8c] Oracle Built-in Datatypes Built-In Datatype Syntax character_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.htm Question: 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 made during the current transaction. The ROLLBACK statement ends the current transaction and undoes any changes made during that transaction. If we make a mistake, such as deleting the wrong row from a table, a rollback restores the original data. If we cannot finish a transaction because an exception is raised or a SQL statement fails, a rollback lets us take corrective action and perhaps start over. We should explicitly commit or roll back every transaction. Whether we issue the commit or rollback in our SQL program or from a client program depends on the application logic. If we do not commit or roll back a transaction explicitly, 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 the transaction. A transaction is a sequence of SQL statements that Oracle Database treats as a single unit. This statement 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
  • 14. 14 Question: 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 user's access privileges to database o REVOKE - withdraw access privileges given with the GRANT command Question: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 true while inputting/modifying/deleting data in the database. Constraints are used to enforce table rules and prevent data dependent deletion (enforce database integrity). You may 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 database design, 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 products 2. Managing data security and privacy  Protection of data against accidental or intentional loss, destruction, or misuse  Firewalls  Establishment of user privileges
  • 15. 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 conditions 4. 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 location 5. 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 images 6. 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. 16  Application tuning by modifying SQL code in application 7. Improving query processing performance [PGDCS 2011 Q5] Problem: Analyze a system that records information about people allocated to projects. During the analysis we identified various 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 Table Project Code Project Type Project Description Employee ID Employee Name Employee Grade Salary Scale Date of Employee Joined Project Allocated time of employee on Project Department ID Department Name First 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 Code Project Type Project Description Employee ID Employee Name Employee Grade Salary Scale Date of Employee Joined Project Allocated time of employee on Project Department ID Department Name Second 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. 17 . PK Employee ID Employee Name Date of Employee Joined Project Allocated time of employee on Project FK Employee Grade PK Employee Grade Salary Scale Department ID Department Name Third Normal Form  Eliminate fields that do not depend on the key. Project Table . PK Project Code Project Type Project Description Employee Table PK Employee ID FK Project Code Date of Employee Joined Project Allocated time of employee on Project Grade Table PK Employee Grade Salary Scale Department Table PK Department ID Department Name Learn Normalization from Youtube Demonstration: http://www.youtube.com/watch?v=fg7r3DgS3rA