Vous êtes sur la page 1sur 7

CAP200 Managing Database

Homework1
DOA: 23/08/10
DOS:6/09/10

Homework Title / No. : ________1__________________Course Code : _CAP200_____

Course Instructor : ___Anjlee _Verma____________ Course Tutor (if applicable) : ____________

Date of Allotment : _23/08/2010__________ Date of submission : ____6/09/2010_________

Student’s Roll No.___D3801A09______________ Section No. : _____D3801_________

Declaration:
I declare that this assignment is my individual work. I have not copied from any other student’s work or
from any other source except where due acknowledgment is made explicitly in the text, nor has any part
been written for me by another person.

Student’s Signature : __Himanshu Gautam__

Evaluator’s comments:
_____________________________________________________________________

Marks obtained : ___________ out of ______________________


Part A
Q1. Properties satisfied by a transaction for a transfer of funds from one
bank account to another. Evaluate.

Answer:- A money or value transfer service may be provided by persons (natural or legal)
formally through the regulated financial system or informally through non-bank financial
institutions or other business entities or any other mechanism either through the regulated
financial system (for example, use of bank accounts) or through a network or mechanism that
operates outside the regulated system. In some jurisdictions, informal systems are frequently
referred to as alternative remittance services or underground (or parallel) banking systems. Often
these systems have ties to particular geographic regions and are therefore described using a
variety of specific terms. Some examples of these terms include hawala, hundi, fei-chien, and the
black market peso exchange.

Q2. Design a small application on student management system for the


purpose of enquiry; we will use any database system to store persistent
data.

Answer:-
create table Student

Name varchar(20),

Reg_No int primary key,

Roll_No int,

Section varchar(10),
Program_Code int,

Program_Name varchar(30),

Fee varchar(20),

Address varchar(50)

insert into Student values('Himanshu',108,9,'272',140,'BCA-


MCA','25000','Ludhiana')

insert into Student values('Anuj',118,10,'271',140,'BCA-


MCA','25000','Ludhiana')

insert into Student values('Nandu',180,22,'270',140,'BCA-MCA','25000','Kolkata')

NAME REG_NO ROLL_NO SECTION PROGRAM_CODE PROGRAM_NAME FEE ADDRESS


Himanshu 108 9 272 140 BCA-MCA 25000 Ludhiana
Anuj 118 10 271 140 BCA-MCA 25000 Ludhiana
Nandu 180 22 270 140 BCA-MCA 25000 Kolkata
3 rows returned in 0.01
seconds

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.

Ansewer:-
a) Efficient data manipulation. A DBMS should make manipulation of its contents
(e.g., through relational joins) more efficient by indexing records. If it implements relational
operations in a naïve way, the worst-case running time – proportional to the product of the sizes
of the relations – could be many times slower than that of an efficient implementation. Given the
current sizes of large databases (millions to billions of records), this could mean a factor of
hundreds to thousands.

b) Consistency. A DBMS must update its contents in a safe way to reflect the results of
possibly concurrent transactions. If concurrent transactions are not conducted in a way such that
updates are noninterferent (as well as integral) then harmful effects such as invalid values can
occur.

c) Security and Isolation. A DBMS should ensure that only authorized reads and writes
occur with respect to its contents. Views should protect private information, malicious changes
(data diddling) should be prevented, and unauthorized processes should not be able to access and
transmit protected information stored within the database. If this is not done for databases with
sensitive information, then serious breaches of security at private, local, national, or international
level may occur.

d) Integrity and Durability. A DBMS should ensure that fields of records in different
parts of the database are consistent. In particular, it can be used to ensure referential integrity,
i.e., that values that appear in one relation for a given set of attributes also appear for another set
of attributes in another relation (Section 4.2.5 Silberschatz et al. 5e, p. 129 – 132). Without
integrity constraints, updates can happen that can cause erroneous conditions: overdrafts on
financial accounts at banks and departments, for example. The results should also persist, or the
user cannot be assured of the reliability of confirmation messages.

e) Back up and Recovery Services. It includes the following responsibilities: provide


database backup/recovery services, provide off-site tape storage services, provide optional
operational recovery services.

Part B

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.

Answer:-
a) Representation Independence and Transparency (Strong Typing). A DML lets
the programmer manipulate relations as first-class data structures, decreasing the chance of low-
level mistakes by hiding details of how relations are represented and transformed.

b) Efficiency. It may be more efficient to perform certain operations such as relational


joins using sort arrays and hash tables instead of iterator patterns and functions. The database
itself can keep the sequential storage records needed for bookkeeping.

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.
Answer:-
create table Customer
(
C_ID primary key,
C_Name,
City varchar(20),
Rating int
)

insert into Customer values(1,'Himanshu','Ludhinan',5)


insert into customer values(2,'Rajni','Ludhiana',3)
insert into customer values(3,'Anuj','Ludhiana',4)
insert into customer values(4,'Karan','Ludhiana',5)

select * from customer


C_ID C_NAME CITY RATING
3 Anuj Ludhiana 4
4 Karan Ludhiana 5
1 Himanshu Ludhiana 5 select Sum(RATING) from
2 Rajni Ludhiana 3 customer
4 rows returned in 0.00 seconds
SUM(RATING)
17
1 rows returned in 0.02 seconds

select AVG(Rating) from customer

AVG(RATING)

4.25

1 rows returned in 0.00 seconds

select Count(Rating) from customer

COUNT(RATING)
4
1 rows returned in 0.00 seconds
When we divide the sum computed
above by the Count the result is same as AVG as follows:-

select (SUM(Rating)/COUNT(Rating)) from Customer

(SUM(RATING)/COUNT(RATING))
4.25
1 rows returned in 0.01 seconds
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.

Answer:-
a) Data Definition. A DBA designs the basic schema and implements it by using a data
definition language (DDL) or data definition user interface to create tables.

b) Initial storage structure design. A DBA translates the initial schema design (e.g.,
star/constellation, data warehouse) into a storage design by specifying where tables actually
reside and what kind of indexing information is needed for the specified organization. Examples
include data dictionaries and multilevel indices .
c) Updating and changing schemas. A DBA maintains the schema, adding or dropping
fields to reflect reorganization of the database, refactoring it into different tables when needed,
and changing the actual physical organization of tables.

d) Administering access privileges. A DBA defines, grants and revokes privileges for
accessing tables, either directly or by means of views.

e) Backups, restores, and performance tuning. A DBA administers regular


incremental backups of database contents, storage quotas, and restoration of data corrupted or
lost in crashes. He or she may also look at usage statistics in order to decide on an acceptable
use policy (CPU quotas) and perform basic load balancing.