Você está na página 1de 13

Master of Computer Application (MCA) Semester 2

MC0067 Database Management System


(DBMS an !racle "i)
Assignment Set #
1. $%plain t&e functions an a'antages of a DBMS o'er a traitional file system(
Ans)* A DBMS is a set of software programs that controls the organization, storage,
management, and retrieval of data in a database. DBMSs are categorized according to their data
structures or types. he DBMS accepts re!uests for data from an application program and
instructs the operating system to transfer the appropriate data. he !ueries and responses must
be submitted and received according to a format that conforms to one or more applicable
protocols. "hen a DBMS is used, information systems can be changed more easily as the
organization#s information re!uirements change. $ew categories of data can be added to the
database without disruption to the e%isting system.
a'antages of a DBMS)*
Management of distributed data with different levels of transparency.
&ncrease reliability and availability.
'asier e%pansion.
(eflects organizational structure ) database fragments are located in the departments
they relate to.
*ocal autonomy ) a department can control the data about them +as they are the ones
familiar with it.,
-rotection of valuable data ) if there were ever a catastrophic event such as a fire, all
of the data would not be in one place, but distributed in multiple locations.
&mproved performance ) data is located near the site of greatest demand, and the
database systems themselves are parallelized, allowing load on the databases to be
balanced among servers. +A high load on one module of the database won#t affect other
modules of the database in a distributed database.,
'conomics ) it costs less to create a networ. of smaller computers with the power of a
single large computer.
Modularity ) systems can be modified, added and removed from the distributed
database without affecting other modules +systems,.
(eliable transactions / Due to replication of database.
0ardware, 1perating System, $etwor., 2ragmentation, DBMS, (eplication and
*ocation &ndependence.
3ontinuous operation.
1
4. Describe ine%ing an clustering tec&ni+ues ,it& rele'ant real time e%amples(
Ans)* he most important characteristics of column data are the clustering factor for the column
and the selectivity of column values, even though other important characteristics within tables are
available to the 3B1. A column called clustering5factor in the dba5inde%es view offers information
on how the table rows are synchronized with the inde%. "hen the clustering factor is close to the
number of data bloc.s and the column value is not row ordered when the clustering5factor
approaches the number of rows in the table, the table rows are synchronized with the inde%.
o illustrate this, the following !uery will filter the result set using a column value for
clustering5factor6

select
customer_name
from
customer
where
customer_state = New Mexico;
An inde% scan is faster for this !uery if the percentage of customers in $ew Me%ico is small and the
values are clustered on the data bloc.s. he decision to use an inde% versus a full/table scan is at
least partially determined by the percentage of customers in $ew Me%ico.
So, why would a 3B1 choose to perform a full/table scan when only a small number of rows are
retrieved7 he clustering5factor has the answer.
2our factors synchronize to help the 3B1 choose whether to use an inde% or a full/table scan6 the
selectivity of a column value8 the db5bloc.5size 8 the avg5row5len 8 and the cardinality. An inde%
scan is usually faster if a data column has high selectivity and a low clustering5factor.
9. Describe 'arious integrity rules ,it& a rele'ant e%ample(
Ans)* &t is important that data adhere to a predefined set of rules, as determined by the
database administrator or application developer. As an e%ample of data integrity, consider
the tables employees and departments and the business rules for the information in each
of the tables.
-ypes of Data .ntegrity
his section describes the rules that can be applied to table columns to enforce different types of data
integrity.
/ull 0ule
A null is a rule defined on a single column that allows or disallows inserts or updates of rows containing
a null +the absence of a value, in that column.
4
1ni+ue Column 2alues
A uni!ue value defined on a column +or set of columns, allows the insert or update of a row only if it
contains a uni!ue value in that column +or set of columns,.
3rimary 4ey 2alues
A primary .ey value defined on a .ey +a column or set of columns, specifies that each row in the table
can be uni!uely identified by the values in the .ey.
0eferential .ntegrity 0ules
A rule defined on a .ey +a column or set of columns, in one table that guarantees that the values in that
.ey match the values in a .ey in a related table +the referenced value,.(eferential integrity also includes
the rules that dictate what types of data manipulation are allowed on referenced values and how these
actions affect dependent values. he rules associated with referential integrity are6
(estrict6 Disallows the update or deletion of referenced data.
Set to $ull6 "hen referenced data is updated or deleted, all associated dependent data is set to
NULL.
Set to Default6 "hen referenced data is updated or deleted, all associated dependent data is set
to a default value.
3ascade6 "hen referenced data is updated, all associated dependent data is correspondingly
updated. "hen a referenced row is deleted, all associated dependent rows are deleted.
Comple% .ntegrity C&ec5ing
3omple% integrity chec.ing is a user/defined rule for a column +or set of columns, that allows or
disallows inserts, updates, or deletes of a row based on the value it contains for the column +or set of
columns,.
.ntegrity Constraints Description
An integrity constraint is a declarative method of defining a rule for a column of a table. 1racle supports
the following integrity constraints6
NOT NULL constraints for the rules associated with nulls in a column
UN!U" .ey constraints for the rule associated with uni!ue column values
#$M%$& '"& constraints for the rule associated with primary identification values
(O$")N '"& constraints for the rules associated with referential integrity. 1racle supports the
use of (O$")N '"& integrity constraints to define the referential integrity actions, including6
o :pdate and delete $o Action
o Delete *%+*%,"
o Delete +"T NULL
;. $%plain t&e t&ree*le'el arc&itecture of a DBMS ,it& a labele iagram(
Ans)* Data are actually stored as bits, or numbers and strings, but it is difficult to wor. with
data at this level.
9
&t is necessary to view data at different levels of abstraction.
Schema6
Description of data at some level. 'ach level has its own schema.
"e will be concerned with three forms of schemas6
physical,
conceptual, and
e%ternal.






<. Describe t&e relational algebra operations ,it& rele'ant real time e%amples(
Ans)* n order to implement a DBMS, there must e%ist a set of rules which state how the
database system will behave. 2or instance, somewhere in the DBMS must be a set of
statements which indicate than when someone inserts data into a row of a relation, it has the
effect which the user e%pects. 1ne way to specify this is to use words to write an =essay# as to
how the DBMS will operate, but words tend to be imprecise and open to interpretation. &nstead,
relational databases are more usually defined using (elational Algebra.
Relational Algebra is :
the formal description of how a relational database operates
an interface to the data stored in the database itself
the mathematics which underpin S>* operations
1perators in relational algebra are not necessarily the same as S>* operators, even if they have
the same name. 2or e%ample, the S'*'3 statement e%ists in S>*, and also e%ists in relational
algebra. hese two uses of S'*'3 are not the same. he DBMS must ta.e whatever S>*
statements the user types in and translate them into relational algebra operations before
applying them to the database.
;
More formally, R ? S is defined as follows6
R ? S @ A(r
1
, r
2
, ..., r
n
, s
1
, s
2
, ..., s
m
) B (r
1
, r
2
, ..., r
n
) R, (s
1
, s
2
, ..., s
m
) SC
More formally the semantics of the natural Doin is defined as follows6
More formally the semantics of the semiDoin is defined as follows6
R S @ A t 6 t R, s S, Fun +t s, C
E. 6rite about t&e atabase system en'ironment(
Ans)* Database Management System +DBMS, is a set of computer programs that controls the
creation, maintenance, and the use of a database. &t allows organizations to place control of database
development in the hands of database administrators +DBAs, and other specialists. A DBMS is a
system software pac.age that helps the use of integrated collection of data records and files .nown
as databases. &t allows different user application programs to easily access the same database.
DBMSs may use any of a variety of database models, such as the networ. model or relational
model. &n large systems, a DBMS allows users and other software to store and retrieve data in a
structured way. &nstead of having to write computer programs to e%tract information, user can as.
simple !uestions in a !uery language. hus, many DBMS pac.ages provide 2ourth/generation
programming language +;F*s, and other application development features. &t helps to specify the
logical organization for a database and access and use the information within a database. &t provides
facilities for controlling data access, enforcing data integrity, managing concurrency, and restoring
the database from bac.ups. A DBMS also provides the ability to logically present database
information to users.
G. Describe $ntity -ypes7 $ntity Sets7 Attributes an 4eys(
Ans)*
$ntity -ypes 8 Sets)* An entity is a term from the entity-relationship model.A
relational model +your database schema, is one of the ways to implement the '(
model.(elational tables represent relations between simple types li.e integers and strings, which, in
their turn, can represent everything6 entities, attributes, relationships.
An entity is any obDect in the system that we want to model and store information about
&ndividual obDects are called entities
Froups of the same type of obDects are called entity types or entity sets
'ntities are represented by rectangles +either with round or s!uare corners,
<
Attribute:-
All the data relating to an entity is held in its attributes.
An attribute is a property of an entity.
'ach attribute can have any value from its domain.
'ach entity within an entity type6
o May have any number of attributes.
o 3an have different attribute values than that in any other entity.
o 0ave the same number of attributes.
Attributes can be
simple or composite
single/valued or multi/valued
Attributes can be shown on '( models
hey appear inside ovals and are attached to their entity.
$ote that entity types can have a large number of attributes... &f all are shown then the
diagrams would be confusing. 1nly show an attribute if it adds information to the '(
diagram, or clarifies a point.
9( $%plain t&e follo,ing atabase operations ,it& one +uery e%ample for eac&)
a) .nsert)/insert statements have the following form6
&$S'( &$1 table +column1, Hcolumn2, ... I, JA*:'S +value1, Hvalue2, ...I,
he number of columns and values must be the same. &f a column is not specified, the default
value for the column is used. he values specified +or implied, by the N+"$T statement must
satisfy all the applicable constraints +such as primary .eys, *."*' constraints, and NOT NULL
constraints,. &f a synta% error occurs or if any constraints are violated, the new row is not added
to the table and an error returned instead.
'%ample6
N+"$T NTO phone_/oo0 1name2 num/er3 4%LU"+ 156ohn ,oe52 5777-898953;
b) Delete)* he ,"L"T" statement follows the synta%6
DELETE ($OM table_name HWHERE conditionI
Any rows that match the :."$" condition will be removed from the table. &f the :."$" clause is
omitted, all rows in the table are removed. he ,"L"T" statement does not return any rows8 that
is, it will not generate a result set.
E
'%ecuting a ,"L"T" statement can cause triggers to run that can cause deletes in other tables.
2or e%ample, if two tables are lin.ed by a foreign .ey and rows in the referenced table are
deleted, then it is common that rows in the referencing table would also have to be deleted to
maintain referential integrity.
Delete rows from mytable using a sub!uery in the where condition6
,"L"T" ($OM myta/le :."$" id N 1+"L"*T id ($OM myta/le93;
c) 1pate)* An S>* :-DA' statement changes the data of one or more records in a table. 'ither
all the rows can be updated, or a subset may be chosen using a condition.
he U#,%T" statement has the following form6
U#,%T" table5name +"T column5name @ value H, column5name @ value ...I H:."$"
conditionI
2or the U#,%T" to be successful, the user must have data manipulation privileges +U#,%T" privilege,
on the table or column, the updated value must not conflict with all the applicable constraints +such as
primary .eys, uni!ue inde%es, *."*' constraints, and NOT NULL constraints,.
Set the value of column C1 in table T to 1, only in those rows where the value of column C2 is
KaK.
U#,%T" T +"T *8 = 8 :."$" *9 = 5a5;
August 20#0
Master of Computer Application (MCA) Semester 2
G
MC0067 Database Management System
(DBMS an !racle "i)
Assignment Set 2
#( Describe t&e follo,ing normali:ation tec&ni+ues)
a)-&ir /ormal ;orm)* he normal forms +abbrev. $2, of relational database theory provide criteria
for determining a table#s degree of vulnerability to logical inconsistencies and anomalies. he higher the
normal form applicable to a table, the less vulnerable it is to inconsistencies and anomalies. 'ach table
has a Khighest normal formK +0$2,6 by definition, a table always meets the re!uirements of its 0$2 and
of all normal forms lower than its 0$28 also by definition, a table fails to meet the re!uirements of any
normal form higher than its 0$2.
he normal forms are applicable to individual tables8 to say that an entire database is in normal form n
is to say that all of its tables are in normal form.'very non/prime attribute is non/transitively dependent
on every candidate .ey in the table.
b)Boyce*Co /ormal ;orm)* $ewcomers to database design sometimes suppose that
normalization proceeds in an iterative fashion, i.e. a 1$2 design is first normalized to 4$2, then to 9$2,
and so on. his is not an accurate description of how normalization typically wor.s. A sensibly designed
table is li.ely to be in 9$2 on the first attempt8 furthermore, if it is 9$2, it is overwhelmingly li.ely to
have an 0$2 of <$2. Achieving the KhigherK normal forms +above 9$2, does not usually re!uire an
e%tra e%penditure of effort on the part of the designer, because 9$2 tables usually need no modification
to meet the re!uirements of these higher normal forms. 'very non/trivial functional dependency in
the table is a dependency on a super.ey(
2( Describe t&e t&eory of Discretionary Access control base on granting an re'o5ing
pri'ileges(
Ans)* Discretionary access control is based on the idea of access rights, or privileges,
and mechanisms for giving users such privileges. A privilege allows a user to access
some data object in a certain manner (e.g. to read or modify). A user who creates data
object such as a table or a view automatically gets all applicable privileges on that
object and the user can also propagate privileges using "Grant ption". !he D"#$
subse%uently &eeps trac& of how these privileges are granted to other users, and
possibly revo&ed, and ensures that at all times only users with the necessary
privileges can access an object.
$'( $ynta)
$'( supports discretionary access control through the G*A+! and *,-., commands.
L
!he G*A+! command gives users privileges to base tables and views.
!he *,-., command cancels uses/ privileges.
;or e%ample) G*A+! privilege0, privilege1, ... *-., privilege0, privilege1, ...
+ object2name + object2name
! user0, user1, ... 3 4*# user0, user1, ... 3

G*A+! $,(,5!, A(!,* *-., $,(,5!, A!(,*
+ student + student
! db1206 4*# db1206
<( 6rite about $ncryption an 3ublic 4ey .nfrastructures(
Ans)* Encryption Algorithm6/
&nput6 encryption .ey M +one .ey for the entire database,, a
page of plainte%t values +- bytes,, and a random
permutation +function, associated with the page +one for
each page, perm 6A1,.., -CA1,.., -C.
1utput6 a page of cipherte%t values.
"e consider and encrypt each byte of the page separately6
2or i = 1to -,
+1, *et d perm+i, mod B M B i = which is clearly in the range
of HN, BMB/1I.
-ublic Mey &nfrastructure +-M&, is a set of hardware, software, people, policies, and procedures needed
to create, manage, distribute, use, store, and revo.e digital certificates.
H1I
&n cryptography, a -M& is an
arrangement that binds public .eys with respective user identities by means of a certificate authority
+3A,. he user identity must be uni!ue within each 3A domain. he binding is established through the
registration and issuance process, which, depending on the level of assurance the binding has, may be
carried out by software at a 3A, or under human supervision. he -M& role that assures this binding is
called the (egistration Authority +(A,. 2or each user, the user identity, the public .ey, their binding,
validity conditions and other attributes are made unforgettable in public .ey certificates issued by the
3A.
he term trusted third party +-, may also be used for certificate authority +3A,. he term -M& is
sometimes erroneously used to denote public .ey algorithms, which do not re!uire the use of a 3A.
=( Describe t&e categories of .nformi% 1ni'ersal Ser'er(
Ans)* his used to be where &#d let off steam after uncovering a nasty bug in the &llustra obDect/
relational database management system. And, in fact, sometimes & reached such poetic heights
O
of vitriol that &#m leaving the old stuff at the bottom +also, it might be useful if you are still
running &llustra for some reason,.
0owever, there really aren#t any good reasons to pic. on &llustra anymore. he company was
bought by &nformi%, one of the Kbig threeK traditional (DBMS vendors +1racle and Sybase
being the other two,. &nformi% basically folded the interesting features of the old &llustra system
into their industrial/strength enterprise/scale (DBMS and calls the result K&nformi% :niversal
ServerK +&:S,. o the e%tent that &:S is based on old code, it is based on &nformi%#s tried and
true 1nline Server, which has been .eeping ban.s and insurance companies with thousands of
simultaneous users up and running for many years.
& plan to be e%perimenting with &:S in some heavily accessed sites during the latter portion of
1OOG. &#m going to record my e%periences here and hope to have lots of tips and source code to
distribute.
>( Describe t&e follo,ing concepts in t&e conte%t of ?oins)
a( 4eys )* A .ey is an attribute +also .nown as column or field, or a combination of attribute that is
used to identify records. he purpose of the .ey is to bind data together across tables without repeating
all of the data in every table.
(I) Super Key An attribute or a combination of attribute that is used to identify the records uni!uely is
.nown as Super Mey. A table can have many Super Meys.
(II) Candidate Key &t can be defined as minimal Super Mey or irreducible Super Mey. &n other words an
attribute or a combination of attribute that identifies the record uni!uely but none of its proper subsets can identify
the records uni!uely.
(III) rimary Key A 3andidate Mey that is used by the database designer for uni!ue identification of each
row in a table is .nown as -rimary Mey. A -rimary Mey can consist of one or more attributes of a table.
(I!) "oreign Key A foreign .ey is an attribute or combination of attribute in one base table that points to the
candidate .ey +generally it is the primary .ey, of another table. he purpose of the foreign .ey is to ensure
referential integrity of the data i.e. only values that are supposed to appear in the database are permitted.
(!) Composite Key &f we use multiple attributes to create a -rimary Mey then that -rimary Mey is called
3omposite Mey.
(!I) Alternate Key Alternate Mey can be any of the 3andidate Meys e%cept for the -rimary Mey.
(!II) Secondary Key he attributes that are not even the Super Mey but can be still used for identification
of records +not uni!ue, are .nown as Secondary Mey.
b( 3erforming a ?oin )* A S>* 6ON clause combines records from two or more tables in a
database.
H1I
&t creates a set that can be saved as a table or used as is. A 6ON is a means for combining
1N
fields from two tables by using values common to each. A$S& standard S>* specifies four types of
6ONs6 NN"$, OUT"$, L"(T, and $).T. &n special cases, a table +base table, view, or Doined table,
can 6ON to itself in a self/Doin.A programmer writes a 6ON predicate to identify the records for
Doining. &f the evaluated predicate is true, the combined record is then produced in the e%pected format,
a record set or a temporary table.
All subse!uent e%planations on Doin types in this article ma.e use of the following two tables. he rows
in these tables serve to illustrate the effect of different types of Doins and Doin/predicates. &n the
following tables the ,epartment, column of the ,epartment table +which can be designated as
,epartment;,epartment,, is the primary .ey, while "mployee;,epartment, is a
foreign .ey.
c( Distinct an $liminating Duplicates)* every field in one record is identical to every field in a
different record, i.e. a duplicate is where there is no way of telling two or more records apart. &f you Dust
need to remove records which are similar +i.e. one or more fields are identical but there are one or more
fields which are different, then instead refer to how to delete similar records.
o chec. that you have duplicate records in your table do the following6
select count1<3 from MyTable
and
select distinct < from MyTable
:nfortunately there is no way in S>* to delete one of these duplicates without deleting all of them.
hey are identical after all, so there is no S>* !uery that you could put together which could distinguish
between them.
"hat you can do is to copy all the distinct records into a new table6
select distinct <
into NewTable
from MyTable
his !uery will create a new table +$ewable in my e%ample, containing all the records in the original
table but without any records being duplicated. &t will therefore preserve a single copy of those records
which were duplicated.
6( $%plain t&e $*0 to relational mapping ,it& a suitable e%ample(
Ans)* 2or each regular entity type ' in the '( schema,
P create a relation ( that includes all the simple attributes
of '
P include only simple component attributes of composite
attribute
P choose one of the .ey attributes of ' as primary .ey
for (
Q '%. 'mployee, Department, -roDect relations
P primary .ey 6
11
Q 'mployee+SS$,, Department+D$:MB'(,,
-roDect+-$:MB'(.
:pon completion of this module, you will be introduced to the following
he use of high/level conceptual data models to support database design.
he basic concepts associated with the 'ntityP(elationship +'(, model, a high/level
conceptual data model.
A diagrammatic techni!ue for displaying an '( model.
0ow to identify problems called connection traps, which may occur when creating an
'( model.
he limitations of the basic '( modeling concepts and the re!uirements to model more
comple% applications using enhanced data modeling concepts.
he main concepts associated with the 'nhanced 'ntityP(elationship +''(, model
called specializationRgeneralization and categorization.
7( Describe t&e Concurrency Control -ec&ni+ues in a DBMS(
Ans)* 3oncurrency control in Database management systems +DBMS8 Bernstein et al. 1OLG, "ei.um
and Jossen 4NN1,, other transactional obDects, and related distributed applications +e.g., Frid computing
and 3loud computing, ensures that database transactions are performed concurrently without violating
the data integrity of the respective databases. hus concurrency control is an essential element for
correctness in any system where two database transactions or more, e%ecuted with time overlap, can
access the same data, e.g., virtually in any general/purpose database system. A well established
concurrency control theory e%ists for database systems6 serializability theory, which allows to
effectively design and analyze concurrency control methods and mechanisms.
o ensure correctness, A DBMS usually guarantees that only serializable transaction schedules are
generated, unless serializability is intentionally rela%ed. 2or maintaining correctness in cases of failed
+aborted, transactions +which can always happen for many reasons, schedules also need to have the
recoverability property. A DBMS also guarantees that no effect of committed transactions is lost, and no
effect of aborted +rolled bac., transactions remains in the related database. 1verall transaction
characterization is usually summarized by the following A3&D rules.
9( $%plain t&e follo,ing ,it& respect to files)
a) Sorte ;iles)* Many alternatives exist, each with its strengths
and weaknesses:
Heap (random order) files: Suitale when typical
access is a file scan retrieving all records!
Sorted "iles: #est if records must e retrieved in
some order, or only a $range% of records is needed!
&ndexes: 'ata structures to organi(e records via
trees or hashing!
)ike sorted files, they speed up searches for a suset of
records, ased on values in certain (*search key+) fields
,pdates are much faster than in sorted files!
14
b) @eap ;iles)* (ows are simply appended to the end of the file as they are inserted. 0ence
the file is unordered.
Deleted rows will create gaps in file. 2ile then must be periodically compacted to recover
space.
Heap File Performance:-
.nserting a ro,)
Access path is to append to the end
(etrieve and store one page
1pating a ro,)
Access path is to scan whole file
Avg. F/2 page transfers if row already e%ists
F1 page transfers if row does not already e%ist
Deleting a ro,)
Access path is scan
Avg. F/21 page transfers if row e%ists
F page transfers if row does not e%ist
19

Você também pode gostar