Sunteți pe pagina 1din 12

LPU

ASSIGNMENT
NO1 OF
MANAGING
DATABASE

SUBMITTED TO
SUBMITTED BY
MISS.GARGI SHARMA
VARUN KATOCH
E3801B53

BCA-MCA
Q1. Properties satisfied by a transaction for a transfer of funds
from one bank account to another. Evaluate?
Ans.1
Atomicity
Atomicity requires that database modifications must follow an
"all or nothing" rule. Each transaction is said to be atomic if
when one part of the transaction fails, the entire transaction
fails and database state is left unchanged. It is critical that the
database management system maintains the atomic nature of
transactions in spite of any application, DBMS, operating
system or hardware failure.
Transactions can fail for several kinds of reasons:

1. Hardware failure:
2. System failure
3. Database failure
4. Application failure

Consistency
The consistency property ensures that the database remains in
a consistent state; more precisely, it says that any transaction
will take the database from one consistent state to another
consistent state. The consistency property does not say how the
DBMS should handle an inconsistency other than ensure the
database is clean at the end of the transaction. If, for some
reason, a transaction is executed that violates the database’s
consistency rules, the entire transaction could be rolled back to
the pre-transactional state - or it would be equally valid for the
DBMS to take some patch-up action to get the database in a
consistent state.

Isolation
Isolation refers to the requirement that other operations cannot
access data that has been modified during a transaction that
has not yet completed. The question of isolation occurs in case
of concurrent transactions, (i.e. multiple transactions occurring
at the same time) and within the same database. Each
transaction must remain unaware of other concurrently
executing transactions, except that one transaction may be
forced to wait for the completion of another transaction that
has modified data that the waiting transaction requires. If the
isolation system does not exist, then the data could be put into
an inconsistent state. This could happen if one transaction is in
the process of modifying data but has not yet completed, and
then a second transaction reads and modifies that uncommitted
data from the first transaction. If the first transaction fails and
the second one succeeds, that violation of transactional
isolation will cause data inconsistency.
Durability
Durability is the ability of the DBMS to recover the committed
transaction updates against any kind of system failure
(hardware or software). Durability is the DBMS's guarantee
that once the user has been notified of a transaction's success
the transaction will not be lost, the transaction's data changes
will survive system failure, and that all integrity constraints
have been satisfied, so the DBMS won't need to reverse the
transaction. Many DBMSs implement durability by writing
transactions into a transaction log that can be reprocessed to
recreate the system state right before any later failure. A
transaction is deemed committed only after it is entered in the
log.
Durability does not imply a permanent state of the database. A
subsequent transaction may modify data changed by a prior
transaction without violating the durability principle.
Q2. Design a small application on student management
system for the purpose of enquiry; we will use any
database system to store persistent data.
Ans2.
create table Student_Information_Register
( Roll_Num varchar(50),App_Num varchar(50) ,First_Name
varchar(50),Last_Name varchar(50),Prog_Code
char(10),Sch_Code varchar(50),Address varchar(50),City
char(20),State char(20),Country varchar(50),Zip_Code
char(10),Phone_Num varchar(30),Email varchar(50),Gender
char(1));
insert into
Student_Information_Register(‘1’,’1024’,’Varun’,’Katoch’,’140’,’
169’,’Nehru
Nagar’,’Pathankot’,’Punjab’,’India’,’145001’,’9988474941’,’katoc
h.varun@gmail.com’,’Male’);

insert into
Student_Information_Register(‘2’,’1025’,’Manpreet’,’Singh’,’14
0’,’169’,’Deep
Nagar’,’Barnala’,’Punjab’,’India’,’146201’,’9453636378’,’msraib
arnala@gmail.com’,’Male’);

insert into
Student_Information_Register(‘3’,’1026’,’Manpreet’,’Sandhu’,’1
40’,’169’,’Madhuvan
Nagar’,’Ludhiana’,’Punjab’,’India’,’144401’,’9878628187’,’mitra
ndichatri16@gmail.com’,’Male’);

insert into
Student_Information_Register(‘4’,’1027’,’Vishavpreet’,’Singh’,’
140’,’169’,’Gandhi
Nagar’,’Ludhiana’,’Punjab’,’India’,’144401’,’9464765663’,’visha
v778@gmail.com’,’Male’);
Q3. We have a problem that would arise if the responsibilities
were not discharged. For this problem list five
responsibilities of a database management system.
Ans 3.
Atomicity

The atomicity property identifies that the transaction is atomic.


An atomic transaction is either fully completed, or is not begun
at all. Any updates that a transaction might affect on a system
are completed in their entirety. If for any reason an error occurs
and the transaction is unable to complete all of its steps, the
then system is returned to the state it was in before the
transaction was started. An example of an atomic transaction is
an account transfer transaction. The money is removed from
account A then placed into account B. If the system fails after
removing the money from account A, then the transaction
processing system will put the money back into account A, thus
returning the system to its original state. This is known as
a rollback, as we said at the beginning of this chapter..

Consistency

A transaction enforces consistency in the system state by


ensuring that at the end of any transaction the system is in a
valid state. If the transaction completes successfully, then all
changes to the system will have been properly made, and the
system will be in a valid state. If any error occurs in a
transaction, then any changes already made will be
automatically rolled back. This will return the system to its
state before the transaction was started. Since the system was in
a consistent state when the transaction was started, it will once
again be in a consistent state.

Looking again at the account transfer system, the system is


consistent if the total of all accounts is constant. If an error
occurs and the money is removed from account A and not
added to account B, then the total in all accounts would have
changed. The system would no longer be consistent. By rolling
back the removal from account A, the total will again be what it
should be, and the system back in a consistent state.

Isolation

When a transaction runs in isolation, it appears to be the only


action that the system is carrying out at one time. If there are
two transactions that are both performing the same function
and are running at the same time, transaction isolation will
ensure that each transaction thinks it has exclusive use of the
system. This is important in that as the transaction is being
executed, the state of the system may not be consistent. The
transaction ensures that the system remains consistent after the
transaction ends, but during an individual transaction, this may
not be the case. If a transaction was not running in isolation, it
could access data from the system that may not be consistent.
By providing transaction isolation, this is prevented from
happening.

Durability

A transaction is durable in that once it has been successfully


completed, all of the changes it made to the system are
permanent. There are safeguards that will prevent the loss of
information, even in the case of system failure. By logging the
steps that the transaction performs, the state of the system can
be recreated even if the hardware itself has failed. The concept
of durability allows the developer to know that a completed
transaction is a permanent part of the system, regardless of
what happens to the system later o

Q4. Give at least two reasons why database system support


data manipulation
using a declarative query language such as SQL, instead of
just providing a library of C or C++ functions to carry out
data manipulation.
Ans 4. First of all the c and c++ both uses the sql in built
function and if the question ask about the difference between
traditional file and database.

1:-Ease of access(open specification)

The sql dml statement are easy to handle in even complex


problem. And all data are fetched in single multidimensional
array there fore it is easy to catch up later execution.

As compare to the c/c++ it often has my sqli library function


like

My_init() Initialize global variables, and thread handler in


thread-safe programs mysql_affected_rows()Returns the
number of rows changed/deleted/inserted by the
last UPDATE, DELETE, or INSERT query

But if we don’t have this function then the the possibilities


limits as there are extra large procedure and typical handler
even for small query therefore sql prefers.

2:-Global accessibility

As we know that sql dml today are embedded in every part of


the webapplication and language we have same rule in any
language for these therefore we need this.

We can acess it in php,c/c++/java/xml/.net etc there fore ont


the other hand the c/c++ alone cant have these global
accessibility.

Q5. Consider a table Customer (cid PK, cname, city, rating)


Write SQL queries to compute the average rating using
AVG(rating); the sum of the ratings using SUM(rating);
and the number of ratings using COUNT(*).
If you divide the sum computed above by the count, would
the result be same as AVG? Justify your answer.

Ans 5.
(a) Create table Customer(cust_cid PK
varchar(50),cust_cname varchar(50),cust_city
varchar(50),cust_rating varchar(50));

Insert into Customer values(‘32’,’Varun’,’Pathankot’,’***’);


Insert into Customer values(‘33’,’Manpreet’,’Barnala’,’***’);
Insert into Customer values(‘34’,’Paramjit’,’Pathankot’,’***’);
Insert into Customer values(‘35’,’Raman’,’Pathankot’,’***’);

Select AVG (rating) FROM Customer


Select SUM (rating) FROM Customer
Select COUNT (rating) FROM Customer

b)
The result using SUM and COUNT would be smaller than
the result using AVERAGE if there are tuples with rating
= NULL. This is because all the aggregate operators,
except for COUNT, ignore NULL values. So the first
approach would compute the average over all tuples
while the second approach would compute the average
over all tuples with non-NULL rating values. However, if
the aggregation is done on the age field, the answers
using both approaches would be the same since the
age field does not take NULL values.

Q6. Adopting database administration concepts can improve


an organization’s effectiveness, since a focal point is
established for the responsibility, the management, and
the control of the total data resources. Give some of the
advantages to management of having a strong database
administration function.
Ans 6. Advantages of using the Database administration
Function
1. Controlled Redundancy
• In the file processing approach, each user defines and
implements the files needed and software applications to
manipulate those files.

• Various files are likely to have different formats and programs


may be written in different languages and same information
may be duplicated in several files.

• Data redundancy leads to

o wasted storage space,

o duplication of effort (when multiple copies of a datum need to


be updated),

o a higher likelihood of the introduction of inconsistency.

• Database design stores each logical data item at one place to


ensure consistency and saves storage.

• But sometimes, controlled redundancy is necessary to


improve the performance.

• Database should have capability to control this redundancy &


maintain consistency by specifying the checks during database
design.

2. Restricting Unauthorized Access

• A DBMS provides a security and authorization subsystem,


which is used by DBA to create user accounts and to specify
restrictions on user accounts.

• File processing system provides password mechanism and


very less security which is not sufficient to enforce security
policies like DBMS.

3. Providing Persistent Storage for Program Objects


• Object oriented database systems are compatible with
programming languages such as C++ and Java.

• A DBMS software automatically performs the conversion of a


complex object which can be stored in object oriented DBMS,
such an object is said to
be persistent due to its survival after the termination of the
program.

4. Providing Storage Structures for Efficient Query Processing

• The DBMS utilizes a variety of sophisticated techniques (view,


indexes etc.) to store and retrieve the data efficiently that are
utilized to improve the execution time of queries and updates.

• DBMS provides indexes and buffering for fast access of query


result,
the choice of index is part of physical database design and
tuning.

• The query processing and optimization module is responsible


for choosing an efficient query execution plan for each query
submitted to the
system.

5. Providing Backup & Recovery

• Data should be restored to a consistent state at the time


system crash and changes being made

• If hardware or software fails in the middle of the update


program, the recovery subsystem of DBMS ensures that update
program is resumed at the point of failure.

6. Multiple user interfaces

• DBMS provides a variety of user interfaces for the users of


varying level of technical knowledge.

• These includes query language for casual users, programming


language interfaces for application programmers, forms and
command codes for parametric users, menu driven interfaces
and natural language interfaces for stand alone users etc

7. Representing Complex Relationships among data

• A DBMS must have the capability to represent a variety of


complex relationship among the data, to define new
relationships as they arise, and to retrieve and update the
related data easily and efficiently.

8. Enforcing Integrity Constraints

• The DBMS have certain integrity constraints that hold on


data.

• These constraints are derived from the meaning of the data


and of the miniworld.

• Some constraints can be specified to the DBMS at the time of


defining data definitions and automatically enforced.

• Database does not allow violation of constraints at the time of


updating the database.

9. Permitting Inferencing and Action Using Rules

• Deductive database systems provide capabilities for defining


deduction rules for inferencing new information from the
stored database facts.

• Triggers can be associated with tables.

• A trigger is a form of a rule activated by updates to the table,


which results in performing some additional operations to
some other tables, sending messages and so on.

• Stored procedure can also be used as a part of the overall


database definition and are invoked appropriately when certain
conditions are met.

• Active database provides more powerful functionality by


providing the active rules that can automatically initiate actions
when certain events and conditions occur.
Eg-;
Advantages of credit trade

 Usually results in more customers than cash trade.


 Can charge more for goods to cover the risk of bad debt.
 Gain goodwill and loyalty of customers.
 People can buy goods and pay for them at a later date.
 Farmers can buy seeds and implements, and pay for them
only after the harvest.
 Stimulates agricultural and industrial production and
commerce.
 Can be used as a promotional tool.
 Increase the sales.
 Modest rates to be filled.
 can be a marketing tool

S-ar putea să vă placă și