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

Rdbms Ass

A database view is a logical query that allows users to access data without running complex queries each time. Views simplify queries and allow changes to the underlying data implementation without updating queries. Materialized views pre-execute queries and store results for faster access, at the cost of less up-to-date data. Normalization organizes data to avoid redundancy and illogical data dependencies. It involves structuring tables to conform to increasing normal forms like 1NF, 2NF and 3NF. Shadow paging is a copy-on-write technique that avoids in-place updates by allocating shadow pages for modifications instead of the original pages.

Uploaded by

Harsh Thakur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views

Rdbms Ass

A database view is a logical query that allows users to access data without running complex queries each time. Views simplify queries and allow changes to the underlying data implementation without updating queries. Materialized views pre-execute queries and store results for faster access, at the cost of less up-to-date data. Normalization organizes data to avoid redundancy and illogical data dependencies. It involves structuring tables to conform to increasing normal forms like 1NF, 2NF and 3NF. Shadow paging is a copy-on-write technique that avoids in-place updates by allocating shadow pages for modifications instead of the original pages.

Uploaded by

Harsh Thakur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Q1. what is a view? How is view defined?

A database view is a logical table query that permits the database architect to
create a special view of data without having to have a larger complex query
used each time. This makes the query run faster than even using prepared
statements.
For example, you might create a view to show the last 10 blog posts, which
would allow you to simply say:

select * from `last_10_posts`

instead of

select * from post order by post date desc limit 10 where public = true and
owner id = 5

As you can see, using a view can greatly the preparation time of a query, and
also allows you to change the implementation of the underlying view without
having to go to each place where that query takes place and update the code
multiple times.

Advanced view features

Various database management system have extended the views from read-only
subsets of data

The Oracle database introduced the concept of materialized views: pre-


executed, non-virtual views commonly used in data warehousing. They give a
static snapshot of the data and may include data from remote sources. The
accuracy of a materialized view depends on the frequency or trigger
mechanisms behind its updates. DB2 provides so-called "materialized query
tables" (MQTs) for the same purpose. Microsoft SQL Server introduced in its
2000 version indexed views which only store a separate index from the table,
but not the entire data.
Q2 . What are Normal Forms?

Normalization is the process of efficiently organizing data in a database. 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). Both of these are
worthy goals as they reduce the amount of space a database consumes and
ensure that data is logically stored.

The normal forms (abbrev. NF) of relational database theory provide criteria for
determining a table's degree of vulnerability to logical inconsistencies and
anomalies. The higher the normal form applicable to a table, the less vulnerable
it is to inconsistencies and anomalies. Each table has a "highest normal form"
(HNF): by definition, a table always meets the requirements of its HNF and of
all normal forms lower than its HNF; also by definition, a table fails to meet the
requirements of any normal form higher than its HNF.

The normal forms are applicable to individual tables; to say that an entire
database is in normal form n is to say that all of its tables are in normal form n.

Newcomers to database design sometimes suppose that normalization proceeds


in an iterative fashion, i.e. a 1 NF design is first normalized to 2NF, then to
3NF, and so on. This is not an accurate description of how normalization
typically works. A sensibly designed table is likely to be in 3NF on the first
attempt; furthermore, if it is 3NF, it is overwhelmingly likely to have an HNF of
5NF. Achieving the "higher" normal forms (above 3NF) does not usually
require an extra expenditure of effort on the part of the designer, because 3NF
tables usually need no modification to meet the requirements of these higher
normal forms.

Q3. List the type of privileges available in SQL?

There are two types of privileges:

 System privileges
 Schema object privileges

System Privileges

A system privilege is the right to perform a particular action, or to perform an


action on any schema objects of a particular type. For example, the privileges to
create table spaces and to delete the rows of any table in a database are system
privileges. There are over 60 distinct system privileges.

Schema Object Privileges

A schema object privilege is a privilege or right to perform a particular action


on a specific schema object:

 Table
 View
 Sequence
 Procedure
 Function
 Package

Different object privileges are available for different types of schema objects.
For example, the privilege to delete rows from the departments table is an object
privilege.

Some schema objects, such as clusters, indexes, triggers, and database links, do
not have associated object privileges. Their use is controlled with system
privileges. For example, to alter a cluster, a user must own the cluster or have
the ALTER ANY CLUSTER system privilege.

A schema object and its synonym are equivalent with respect to privileges. That
is, the object privileges granted for a table, view, sequence, procedure, function,
or package apply whether referencing the base object by name or using a
synonym.

Q4. What is meant by granting privilege?

A privilege is a right to execute a particular type of SQL statement or to access


another user's object. Some examples of privileges include the right to:

 Connect to the database (create a session)


 Create a table
 Select rows from another user's table
 Execute another user's stored procedure

You grant privileges to users so these users can accomplish tasks required for
their job. You should grant a privilege only to a user who absolutely requires
the privilege to accomplish necessary work. Excessive granting of unnecessary
privileges can compromise security. A user can receive a privilege in two
different ways:

 You can grant privileges to users explicitly. For example, you can
explicitly grant the privilege to insert records into the employees table to
the user SCOTT.
 You can also grant privileges to a role (a named group of privileges), and
then grant the role to one or more users. For example, you can grant the
privileges to select, insert, update, and delete records from the employees
table to the role named clerk, which in turn you can grant to the users .

Because roles allow for easier and better management of privileges, you
should normally grant privileges to roles and not to specific users.

Only users who have been granted a specific system privilege with the ADMIN
OPTION or users with the system privileges GRANT ANY PRIVILEGE or
GRANT ANY OBJECT PRIVILEGE can grant or revoke system privileges to
other users. Schema object privileges can be granted to and revoked from users
and roles. If you grant object privileges to roles, you can make the privileges
selectively available. Object privileges for users and roles can be granted or
revoked using the following:

 The SQL statements GRANT and REVOKE, respectively.

Q5. Explain the concept of Shadow Paging?

Shadow paging is a copy-on-write technique for avoiding in-place updates of


pages. Instead, when a page is to be modified, a shadow page is allocated. Since
the shadow page has no references (from other pages on disk), it can be
modified liberally, without concern for consistency constraints, etc. When the
page is ready to become durable, all pages that referred to the original are
updated to refer to the new replacement page instead. Because the page is
"activated" only when it is ready, it is atomic.

If the referring pages must also be updated via shadow paging, this procedure
may recurse many times, becoming quite costly. One solution, employed by the
WAFL file system is to be lazy about making pages durable (i.e. write-behind
caching). This increases performance significantly by avoiding many writes on
hotspots high up in the referential hierarchy (eg: a file system superblock) at the
cost of high commit latency.

Write ahead logging is a more popular solution that uses in-place updates.
Shadow paging is similar to the old master-new master batch processing
technique used in mainframe database systems. In these systems, the output of
each batch run (possibly a day's work) was written to two separate disks or other
form of storage medium. One was kept for backup, and the other was used as
the starting point for the next day's work.

Shadow paging is also similar to purely functional data structures, in that in-
place updates are avoided.

Shadow paging is an alternative to log-based recovery techniques, which has


both advantages and disadvantages. It may require fewer disk accesses, but it is
hard to extend paging to allow multiple concurrent transactions. The paging is
very similar to paging schemes used by the operating system for memory
management.

Performance of Shadow Paging:

- To commit a transaction :
* Flush all modified pages in main memory to disk.
* Output current page table to disk.
* Make the current page table the new shadow page table, as follows:

1. Keep a pointer to the shadow page table at a fixed (known) location on disk.
2. To make the current page table the new shadow page table, simply update the
pointer to point to current page table on disk.
- Once pointer to shadow page table has been written, transaction is committed.
- No recovery is needed after a crash: New transactions can start right away,
using the shadow page table.
- Pages not pointed to from current/shadow page table should be freed (garbage
collected).

Advantages of shadow-paging technique:

- No overhead of writing log records.


- Recovery is trivial.

Disadvantages of shadow-page technique:

- Commit overhead : The commit of a single transaction using shadow paging


requires multiple blocks to be output — the current page table, the actual data
and the disk address of the current page table. Log-based schemes need to
output only the log records.
- Data fragmentation : Shadow paging causes database pages to change
locations (therefore, no longer contiguous.
- Garbage collection : Each time that a transaction commits, the database
pages containing the old version of data changed by the transactions must
become inaccessible. Such pages are considered to be garbage since they are not
part of the free space and do not contain any usable information. Periodically it
is necessary to find all of the garbage pages and add them to the list of free
pages. This process is called garbage collection and imposes additional
overhead and complexity on the system.

Q6. Write a short note on ORACLE server and SQL server?

SQL SERVER Architecture


Protocol layer

Protocol layer implements the external interface to SQL Server. All operations
that can be invoked on SQL Server are communicated to it via a Microsoft-
defined format, called Tabular Data Stream (TDS). TDS is an application layer
protocol, used to transfer data between a database server and a client. Initially
designed and developed by Sybase Inc. for their Sybase SQL Server relational
database engine in 1984, and later by Microsoft in Microsoft SQL Server, TDS
packets can be encased in other physical transport dependent protocols,
including TCP/IP, Named pipes, and Shared memory. Consequently, access to
SQL Server is available over these protocols. In addition, the SQL Server API is
also exposed over web services.

Data storage

The main unit of data storage is a database, which is a collection of tables with
typed columns. SQL Server supports different data types, including primary
types such as Integer, Float, Decimal, Char (including character strings), Var
char (variable length character strings), binary (for unstructured blobs of data),
Text (for textual data) among other

Buffer management

SQL Server buffers pages in RAM to minimize disc I/O. Any 8 KB page can be
buffered in-memory, and the set of all pages currently buffered is called the
buffer cache. The amount of memory available to SQL Server decides how
many pages will be cached in memory. The buffer cache is managed by the
Buffer Manager. Either reading from or writing to any page copies it to the
buffer cache. Subsequent reads or writes are redirected to the in-memory copy,
rather than the on-disc version.

ORACLE SERVER
the Oracle Application Server 10g (the "g" stands for grid), consists of an
integrated, standards-based software platform. It forms part of Oracle
Corporation's Fusion Middleware technology stack. The heart of Oracle
Application Server consists of Oracle HTTP Server (based on Apache HTTP
Server) and OC4J (Oracle AS Containers for Java EE) which deploys Java EE-
based applications. The latest version of OC4J offers full compatibility with the
Java EE 1.4 specifications.

Oracle Application Server became the first platform designed for grid
computing as well as with full life-cycle support for service-oriented
architecture (SOA).

The current release of Oracle Application Server, 10g R3, does not feature a
metadata repository tier, relying instead on metadata repositories provided in
previous releases.

Q7.Explain the various ways of Recovery from concurrent transaction?

A computer system, like any other mechanical or electrical system is subject to


failure. There are a variety of causes, including disk crash, power failure,
software errors, a fire in the machine room, or even sabotage. Whatever the
cause, information may be lost. The database must take actions in advance to
ensure that the atomicity and durability properties of transactions are preserved.
An integral part of a database system is a recovery scheme that is responsible
for the restoration of the database to a consistent stage that existed prior to the
occurrence of the failure.

Recovery with Concurrent Transactions


Regardless of the number of concurrent transactions, the disk has only one
single disk buffer and one single log. These are shared by all transactions. The
buffer blocks are shared by a transactions. We allow immediate updates, and
permit a buffer block to have data items updated by one or more transactions.
Buffer Management
Log-Record Buffering

The cost of performing the output of a block to stable storage is sufficiently


high that it is desirable to output multiple log records at once, using a buffer.
When the buffer is full, it is output with as few output operations as possible.
However, a log record may reside in only main memory for a considerable time
before it is actually written to stable storage. Such log records are lost if the
system crashes. It is necessary, therefore, to write all buffers related to a
transaction when it is committed. There is no problem written the other
uncommitted transactions at this time.

Database Buffering

Database buffering is the standard operating system concept of virtual memory.


Whenever blocks of the database in memory must be replaced, all modified data
blocks and log records associated with those blocks must be written to the disk.

Q8. What are triggers? How are they differ from a insertion?

Triggers are special kind of stored procedures that get executed automatically
when an INSERT, UPDATE or DELETE operation takes place on a table.

Triggers can’t be invoked on demand. They get triggered only when an


associated action (INSERT, UPDATE and DELETE) happens on the table on
which they are defined.

Triggers are generally used to implement business rules, auditing. Triggers can
also be used to extend the referential integrity checks, but wherever possible,
use constraints for this purpose, instead of triggers, as constraints are much
faster. There are many types of triggers available. To state a
few are namely:

 Row-Level Triggers
 Statement-Level Triggers
 Before Trigger
 After Trigger
 Schema Triggers
 Database level Triggers

You might also like