question bank department: cse semester: iv subject … · question bank department: cse semester:...
Post on 30-Jun-2020
3 Views
Preview:
TRANSCRIPT
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
QUESTION BANK
DEPARTMENT: CSE SEMESTER: IV
SUBJECT CODE / Name: CS2255 – DATABASE MANAGEMENT SYSTEM
UNIT – I
PART -A (2 Marks)
1. What is DBMS and what’s the goal of it?
DBMS is a collection of interrelated data and a set of programs to access thatdata. The goal is to provide
the environment that is both convenient andefficient to use in retrieving and storing data base information.
2. What are the advantages of DBMS?(A.U May/June 2007)
• Centralized Control• Data Independence allows dynamic change and growth potential.
• Data Duplication is eliminated with control Redundancy. • Data Quality is enhanced.
3. What are the Disadvantages of DBMS?
• Cost of software, hardware and migration is high. • Complexity of Backup• Problem associated with
centralization.
4. What are the disadvantages of File Systems?
• Data Redundancy and Inconsistency.• Difficulty in accessing data.• Data Isolation
• Integrity problems• Security Problems• Concurrent access anomalies
5. Define Entity, Entity Set, and extensions of entity set. Give one example for each.
• Entity – object or thing in the real world. E.g., each person, book, etc.
• Entity set – set of entities of the same entity that share the same properties or attributes.
E.g., Customer, loan, account, etc
• Extensions of entity set – individual entities that constitute a set. Eg.individual bank customers
6. Define and give examples to illustrate the four types of attributes in database.
• Simple and Composite attribute_ Simple (address)_ Composite (street, city, district)
• Single-valued and multi-valued attribute
Single-valued (roll no)
Multi-valued (colors = {R, B, G})
• Null attribute
No values for attribute
• Derived attribute
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Age derived from Birth date
7. Define relationship and participation.(A.UMay/June 2008)
• Relationship is an association among several entities.
• Association between entity sets is referred as participation.
8. Define mapping cardinality or cardinality ratio.
Mapping cardinality or cardinality ratio is the way to express the number of entities to which another
entity can be associated through a relationship set. These are most useful in describing binary relationship
sets.
9. Explain the four types of mapping cardinality with example.(A.UNov/Dec 2006)
For a binary relationship set R between entity sets A and B, the mapping cardinality must be one of the
following: (Draw the diagrams also)
• One-to-one
An entity in A is associated with at most one entity in B and an entity in B is associated with at most one
entity in A. E.g., Roll no entity in Student info entity set and marks details entity set.
• One-to-many
An entity in A is associated with any number of entities in B. But an entity in B is associated with at most
one entity in A. E.g., one customerwith many loans.
• Many-to-one
An entity in A is associated with at most one entity in B. But anentity in B can be associated with any
number of entities in A. E.g., streetand city associated to a single person.
• Many-to-many
An entity in A is associated with any number of entities in B. Butan entity in B can be associated with any
number of entities in A. E.g.,same loan by several business partners.
10. Differentiate total participation and partial participation. (i.e., write Definition andExample
with illustration)
• Total – participation of an entity set, E in relationship, R is total if everyentity in E participates in at
least one relationship in R. E.g., loan entity set.
• Partial – if only some entities in E participate in R. E.g., payment weakentity set.
11. Define E-R diagram.(A.UNov/Dec 2007)
Overall structure of a database can be expressed graphically by E-Rdiagram for simplicity and clarity.
12. Define weak Entity set. Give an example and explain why it is weak entity set.
• Entity set with no sufficient attributes to form a primary key’s Payment entity set is weak since
duplication exists
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
13. Define discriminator or partial key of a weak entity set. Give example.
Set of attributes that allow distinction to be made among all those entitiesin the entity set that depends on
one particular strong entity. E.g., payment no inpayment entity set. It is also called as partial key.
14. Explain Referential Integrity.(A.UNov/Dec 2008)
Referential Integrity means relationship between tables. Foreign keys areused. Foreign key is the column
whose values are derived from the Primary keyof the same or some other table.
Format for creating a foreign key is given below.Syntax: create table <table name> (column name data
type (size) constraintconstraint name references parent table name);
15. Define Instances and schemas.
Instances: The collection of information stored in the database at a particular momentis called the instance
of the database.
Schemas: The overall design of the database is called the schema of the database.
16. Define and explain the two types of Data Independence.(A.UNov/Dec 2011)
Two types of data independence are
i. Physical data independenceii. Logical data independence
Physical data independence:
The ability to modify the physical schema without causing applicationprograms to be rewritten in the
higher levels. Modifications in physical leveloccur occasionally whenever there is a need to improve
performance.
Logical data independence:
The ability to modify the logical schema without causing applicationprograms to be rewritten in the
higher level (external level). Modifications inphysical level occur frequently more than that in physical
level, whenever there isan alteration in the logical structure of the database.
17. Define transaction.(A.UMay/June 2007)
A transaction is a collection of operations that performs a single logicalfunction in a database application.
Each transaction is a unit of both atomicity andconsistency. Properties of transaction are atomicity,
consistency, isolation, anddurability.
18. Define the type types of DML.(A.UNov/Dec 2010)
Two types:• Procedural DML• Non-procedural DML
Procedural DML:
It requires a user to specify what data are needed and how to get thosedata.
Non-Procedural DML:
It requires a user to specify what data are needed without specifying howto get those data.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
19. List out the functions of DBA.
• Schema definition• Storage structure and access-method definition• Schema and physical modification•
Granting of authorization for data access• Integrity constraint specification
20. What is the need for DBA?
The need of DBA is to have central control of both the data and theprograms that access those data. The
person who has such central controlover the system is called the DataBase Administrator.
21. Explain DML pre-compiler.
DML precompiled converts DML statements embedded in an applicationprogram to normal procedure
calls in the host language. The precompiledmust interact with the DML compiler to generate the
appropriate code.
22. Define file manager and buffer manager.(A.UNov/Dec 2009)
File manager:
File manager manages the allocation of space on disk storage and the datastructures used to represent
information stored on disk.
Buffer manager:
Buffer manager is responsible for fetching data from the disk storage intohis main memory, and deciding
what data to cache in memory.
23. Define Data Dictionary.(A.U May/June 2007)
DDL statements are compiled into a set of tables that is stored in a special file called data dictionary. Data
dictionary contains the meta-data, which in turn isdata about the data.
24. Give the syntax for creating the table with composite primary key.
Multicolumn primary key is called composite primary key.
Syntax: create table <table name>(columnname1 data type (size), columnname2data type (size),
constraint name primary key (columnname1, columnname2));
25. Write a query to display loan number, branch name where loan amount is between
500 and 1000 using comparison operators.
Query: select loan no, branch name from loan where amount>=500 and amount<=1000;
26. Find the names of all branches with customers who have an account in the bank
And who live in the Harrison city using Equip-join.
Query: select branch name from customer, account, depositor wherecust_city='Harrison' and
customer.cust_name=depositor.cust_nameanddepositor.acc_no=account.acc_no;
27. Find the names of all branches with customers who have an account in the bank
And who live in the Harrison city using Sub-Queries.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Query: select branch name from account where acc_no in (select acc_no from depositor where
cust_name in (select cust_name from customer wherecust_city='Harrison'));
PART-B
1. Explain DBMS System Architecture (Apr/May 2011)
DATABASE SYSTEMARCHITECTURE
Adatabasesystemispartitionedintomodulesthatdealwitheachoftheresponsibilitiesofthe
overallsystem. The functional components of adatabasesystem can bebroadlydivided into
StorageManager
QueryProcessor
Thedatabasesystemarchitectureisinfluencedby theunderlyingcomputerarchitecture.Thedatabase
systemcanbecentralizedorclientserver.Database systems arepartitionedintotwoorthree parts.In
twotierarchitecture,theapplicationispartitionedintoa componentthatresidesattheclientmachine and
invokes database functionality at the server machine through query language. Application
programinterface standardslike ODBCandJDBCare usedfor interactionbetweentheclientandthe
server.Inthreetierarchitecture,theclientmachinesactasafrontendanddonotcontainany direct databasecalls.
The clientendcommunicateswiththe applicationservers throughinterface.The applicationserver interacts
with databasesystem to access data. Thebusiness logic of application says what actions to be carried
out underwhat condition.Threetier is more appropriate forlargeapplications.
Two tierarchitecture
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Three tierarchitecture
1 Storage Manager
A storage manager isa programmodule thatprovidesthe interfacebetweenthe lowleveldata
stored in the database and the application programs and queries submitted to the system.
Thestoragemanager is responsible forthe interaction with the filemanager.
ThestoragemanagertranslatesthevariousDML statementsintolow-levelfilesystem
commands.Thus,thestoragemanagerisresponsibleforstoring,retrieving,andupdating datain the
database.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Figure1.5.Database SystemStructure
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Components of thestoragemanager are:
Authorizationandintegritymanager:Ittestsforsatisfactionofvariousintegrityconstraints and
checks the authorityofusers accessingthe data.
Transactionmanager:It ensures that thedatabase remains ina consistentstatedespitesystem
failures, andconcurrent executions proceed without conflicting.
Filemanager:Itmanagestheallocationofspaceondiskstorageandthedatastructuresused to
represent information stored on disk.
Buffermanager:Itisresponsibleforfetchingdatafromdiskstorageintomainmemoryand
todecidewhatdatatocache inmainmemory.Itenablesthedatabasetohandledatasizesthat are
muchlargerthanthesize ofthemainmemory.The storage managerimplementsseveral data
structuresas part ofphysical system implementation.
Data files: which storethe databaseitself.
Datadictionary:Itcontainsmetadatathatisdataaboutdata.Theschemaofatableisan
exampleofmetadata.Adatabasesystemconsultsthedatadictionary before readingand
modifyingactual data.
Indices:Which provide fast access to data items thathold particularvalues.
2 Query Processor
Thequeryprocessorisanimportantpartofthedatabasesystem.Ithelpsthedatabasesystemto
simplifyand facilitate access to data. Thequeryprocessorcomponents include:
DDLinterpreter,whichinterpretsDDLstatementsandrecordsthedefinitionsinthedata dictionary.
DMLcompiler,whichtranslatesDMLstatementsinaquerylanguageintoanevaluationplan
consistingof low-level instructions that thequeryevaluation engine understands.
A querycan betranslatesinto anynumberof evaluations plans that allgivethe same result.
TheDMLcompileralsoperformsqueryoptimization,thatis,itpicksupthelowestcost evaluation plan
fromamongthealternatives.
Query evaluation engine, which executes low-level instructions generated by the DML
compiler.
2. Explain E-R Model in detail with suitable example. (Nov/Dec 2009)
TheE-R data modelconsiders the real world consistingof aset of basicobjects, calledentities,
and relationships among theseobjects.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
TheE-R data modelemploys threebasic notions:
Entitysets
Relationship sets
Attributes
Entity Sets
Anentityis‗thingor‗objectintherealworldthatisdistinguishablefromallother objects.
For example, each person is an entity.
Anentityhasasetofproperties,andthevaluesforsomesetofpropertiesmayuniquely
identifyanentity.
Forexample,acustomerwithcustomer-idpropertywithvalueC101uniquelyidentifies that
person.
Anentitymaybeconcrete,suchaspersonorabook,oritmaybeabstract,suchasaloan, oraholiday.
Anentitysetisasetofentitiesofthesametypethatsharethesameproperties,or attributes.
Forexampleallpersonswhoarecustomersatagivenbankcanbedefinedasentityset customer.
Theproperties that describe an entityare calledattributes.
Relationships andRelationships sets
Relationshipis an association amongseveral entities.
Relationship setis a set of relationshipsof thesametype.
Theassociationbetweenentity setisreferredtoasparticipation.Thatis,theentity setsE1, E2, . .
.,En participate inrelationship set R.
Recursiverelationshipset:Sameentity setparticipating inarelationshipmorethanoncein
adifferent role is calledRecursive relationship set.
The attributes of entitiesin Recursive relationship set is calleddescriptive attributes.
Types ofrelationships
Unaryrelationship:Aunaryrelationshipexistswhenanassociationismaintainedwithin
asingleentity
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Figure1.6.Association betweentwo objects ofthesamelist.
Binary relationship: Abinaryrelationship existswhen two entities are associated.
Figure1.7. Binary Relationshipbetween publisherand book
Ternary relationship: A ternary relationship exists when there are three entities
associated.
Figure1.8.E-R diagramwith Ternary relationship
Quaternaryrelationship:Aquaternaryrelationshipexistswhentherearefourentities
associated.
Figure1.9.E-R diagramwithQuaternary relationship
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Thenumberofentitysetparticipatingina relationship is calleddegreeof the relationship set.
Binaryrelationship set is of degree2; a tertiaryrelationship set is of degree3.
Entityrole:Thefunctionthatanentityplaysinarelationshipiscalledthatentity‘srole.A
roleis one end ofan association.
Figure1.10. Entity roleis Employee
Attributes
Theproperties that describes an entityiscalled attributes.
The attributes of customer entitysetare customer_id, customer_nameandcity.
Eachattributes hasasetofpermitted values called the domain or value set.
Eachentitywillhavevalue forits attributes.
Example:
Customer Name John
CustomerId 321
Attributes are classified as
Simple
Composite
Single-valued
Multi-valued
Derived
Simple attribute:
This typeofattributes cannot be divided into sub parts.
Example:Age, sex, GPA
Compositeattribute:
This typeofattributes Can besubdivided.
Example:Address:street, city, state, zip
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Single-valuedattribute:
This typeofattributes can haveonlyasingle value
Example: Social securitynumber
Multi-valuedattribute:
Multi-valued attributeCan havemanyvalues.
Example: Person mayhaveseveral collegedegrees, phonenumbers
Derived attribute:
Derived attributeCanbecalculated or derivedfrom other relatedattributes or entities.
Example:Agecan bederived from D.O.B.
Storedattributes:
The attributesstoredina database are calledstoredattributes.Anattribute takesa nullvalue whenan
doesnothaveavalueforit.Nullvalues indicatethevaluefortheparticularattribute does not exists or
unknown.
E.g.:Middlenamemaynotbepresentforaperson(nonexistencecase),Apartmentnumber
maybemissingor unknown.
CONSTRAINTS
AnE-Renterpriseschemamaydefinecertainconstraintstowhichthecontentsofadatabase system
must conform.
Threetypes of constraints are
Mappingcardinalities
Keyconstraints
Participation constraints
Mappingcardinalities
Mappingcardinalitiesexpressthenumberofentitiestowhichanotherentitycanbe associated
viaa relationship set
Cardinalityin E-R diagram that is represented bytwo ways:
Directed line( )
Undirected line( )
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
There are4categories ofcardinality.
Onetoone:AnentityinAisassociatedwithatmostoneentityinB,andanentityinBis associated with at
most one entityin A.
Figure1.11. One to one
Example:Acustomerwithsingleaccountatgivenbranchisshownbyone-to-onerelationship as
givenbelow
Figure1.12. One to onerelationship betweencustomerandaccount
One-to-many:AnentityinAisassociatedwithanynumberofentities(zeroormore)inB.
An entityin B, however,can beassociated with atmostoneentityin A.
Figure1.13. Onetomany
Example:Acustomerhavingtwo accountsat agivenbranchisshownbyone-to-many relationship
as given below.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Figure1.14. Onetomany relationshipbetweencustomerandaccount
Many-to-one:AnentityinAisassociatedwithatmostoneentityinB.AnentityinB, however,can
beassociated with anynumber (zero or more) ofentities in A.
Figure1.15.Many to one
Example:Manyemployeesworksforacompany.Thisrelationshipisshownbymany-to-one as
givenbelow.
Keys
Figure1.16.Many to one relationshipbetwennEmployees andCompany
A keyallows us to identifyaset of attributesand thus distinguishes entities from each other.
Keysalsohelpuniquelyidentifyrelationships,andthusdistinguishrelationshipsfromeach other.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Table 3.1 List ofKeys
Key Type Definition
Superkey
Anyattributeorcombinationofattributesthat
uniquelyidentifiesarowinthetable.Example:
Roll_Noattributeoftheentity set‗student‘
distinguishesonestudententity fromanother.
Customer_name, Customer_id togetherisa
Super key
CandiateKey
MinimalSuperkey.Asuperkeythatdoesnot
contain asubset ofattributes that is itself a
superkey.Example: Student_name and
Student_street,aresufficient to uniquely
identify one particularstudent.
PrimaryKey
Thecandidatekey selectedtouniquely identify
all rows. It shouldbe rarely changed and
cannotcontainnullvalues.Example:Roll_No is
aprimaryset of‗student‘ entityset.
Foreign Key
Anattributeinonetablethatmusteithermatch
the primarykeyofanother table orbenull
Example: Consider in the staff relation the
branch_noattributeexiststomatchstafftothe
branchofficetheyworkin.Inthestaff relation,
branch_no is foreign key.
SecondaryKey Anattributeorcombinationofattributesused
tomakedata retrieval moreefficient.
Many-to-many:AnentityinAisassociatedwithanynumber(zeroormore)ofentitiesinB, and an
entityin Bis associated with anynumber (zero ormore) ofentities in A.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Figure1.17.Many to Many
Example:Employeeworks on numberofprojects and project is handledbynumberof
employees.Therefore,therelationshipbetweenemployeeandprojectismany-to-many as shown
below.
Figure1.18.Many to Many relationshipbetweenEmployeeand project
ParticipationConstraint
Participation can bedivided into two types.
Total
Partial
IfeveryentityintheentitysetEparticipatesinatleastonerelationshipinR.Then participation is
called Total Participation
If only some entities in the entity set E participate in relationships in R. Then the
participation is called Partial Participation.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
3. Explain about Entities-Relationship(E-R)Diagrams in details.
E-R diagram can express theoveralllogical structureof adatabasegraphically. E-
R diagramconsistsof the followingmajor components:
E-R diagramNotations.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
E-R Diagramwith composite,multivalued, andderivedattributes
DoublelinesareusedinanE-Rdiagramtoindicatethattheparticipationofanentity setina
relationshipsetistotal; thatis,eachentityintheentitysetoccursinatleastone relationshipin that
relationship set.
ParticipationofanEntity Set in aRelationship Set
Thenumberoftimeanentity participatesinarelationshipcanbespecifiedusingcomplex
cardinalities.Anedgebetweenanentity setandbinaryrelationshipsetcanhaveanassociated
minimum and maximum cardinalityassigned in the form of l andh.
l -Minimum cardinality
h -Maximum cardinality
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
A minimumvalue of1 indicates total participationof the entityset in the relationshipset. A
maximum valueof 1indicates that the entityparticipates in at most onerelationship.
A maximum value* indicates no limit.
A label 1... onan edgeis equivalent to adouble line.
Many to one relationshipbetweeencustomerandloan
Strong andWeakentity sets
Anentitysetmay nothavesufficientattributestoformaprimary key.Suchanentity setis
termedaweakentityset.Anentity setthathasaprimary keyistermedastrongentityset. Weakentity
setisassociatedwithanotherentitysetcalledtheidentifyingorownerentity set.
ie,weakentitysetissaidtobeexistencedependentontheidentifyingentity set.Identifying entity
setissaidtoowntheweakentity set.Therelationshipamongtheweakandidentifying entityset is
called theidentifyingrelationship.
Weakentity set
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Extendede-rfeatures
ERmodelthat issupportedwiththeadditional semanticconceptsiscalledtheextendedentity
relationship model or EER model. EER model deals with
Specialization
Generalization
Aggregation
Specialization
Theprocessofdesignatingsubgroupingswithinanentity setiscalledSpecialization.
Specializationisatop-downprocess.Consideranentity setperson.Apersonmay befurther
classifiedasoneofthefollowing-CustomerandEmployee.Allpersonhasa setofattributesin
commonwithsomeadditionalattributes.Specializationisdepictedby atrianglecomponent
labeledISA.ThelabelISAstandsfor isforexample,thatacustomerisperson.TheISA relationship
mayalso bereferred toas asuperclass-subclass relationship.
Example forspecializationandgeneralization
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Generalization
Generalizationisasimpleinversionofspecialization.Generalizationistheprocessofdefining
amoregeneralentity typefromasetofmorespecializedentitytypes.Generalizationisa bottom-
upapproach.Generalizationresultsinthe identificationofageneralizedsuperclass from theoriginal
subclasses.
AttributeInheritance
Apropertyofthehigher-andlower-levelentitiescreatedbyspecializationandgeneralization
isattributeinheritance.Theattributesofthehigher-levelentity setsaresaidtobeinherited by
thelower-levelentitysets.Forexample, customerandemployeeinherittheattributesof person.
Theoutcomeof attributeinheritanceis:
Ahigher-levelentitysetwithattributesandrelationshipsthatapplytoallofitslower- level
entitysets.
Lower-levelentitysetswithdistinctivefeaturesthatapplyonlywithinaparticular lower-level
entityset
Ifanentitysetisinvolvedasalower-levelentitysetinonly oneISArelationship,then
theentitysethassingleinheritance.Ifanentitysetisinvolvedasalower-levelentity
setinmorethanoneISArelationship,thentheentitysethasmultipleinheritanceand the
resultingstructureissaid to bea lattice.
Constraints on Generalizations
Onetypeofconstraintdeterminingwhichentitiescanbemembersofalower-level entityset.
Such membership maybeoneof thefollowing:
Condition-defined.Incondition-definedthemembersoflower-levelentityset
isevaluatedonthebasisofwhetherornotanentity satisfiesanexplicit condition.
User-defined. User defined constraints aredefined byuser.
Asecondtypeofconstraintrelatestowhetherornotentitiesmaybelongtomorethan onelower-
levelentitysetwithinasinglegeneralization.Thelower-levelentitysets maybeoneof
thefollowing:
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Disjoint. A disjointness constraintrequires that anentitybelongto no more than
onelower-level entityset.
Overlapping.Sameentitymaybelongtomorethanonelower-levelentityset within
asinglegeneralization.
Afinalconstraint,thecompletenessconstraintspecifieswhetherornotanentityinthe higher-
levelentity setmustbelongtoatleastoneofthelower-levelentity sets.This
constraintmaybeoneofthe following:
Totalgeneralizationorspecialization.Eachhigher-levelentitymustbelongtoa lower-
level entityset.It is represented bydouble line.
Partial generalizationor specialization. Some higher-level entities may not
belongto anylower-level entityset.
Aggregation
Onelimitation of theE-R model is that itcannot express relationships amongrelationships.
Considertheternaryrelationshipworks-on,betweenaemployee,branch,andjob.Now,supposewe
wanttorecordmanagersfortasksperformedbyanemployeeatabranch.Thereanotherentityset
manageriscreated.Thebestwaytomodelsuchasituationistouseaggregation.Aggregationisan
abstractionthroughwhichrelationshipsaretreatedashigher-levelentities.Inourexampleworks-on act as
high level entity.
Figure1.25.E-R diagramwith redundant relationships.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Symbols usedinE-R notations
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
E-R diagramwith aggregation
INTRODUCTION TO RELATIONALDATABASES
A relationaldatabase isbasedonthe relationalmodelanduses a collectionof tablestorepresent both
data and the relationship amongthose data.Itincludes DMLand DDL languages.
Tables -Each tablehasmultiple columns and each column has uniquename.
Account table
Arelationalmodelisanexampleofarecordbasedmodel.Recordbasedmodelare structuredin
fixedformatrecordofseveraltypes.Eachtablecontainsrecordofparticulartype.Eachrecord type
definesa fixednumber offieldsorattributes.The columnsofthetable correspondtothe attributeof
record type.
Data ManipulationLanguage (DML)
DMLincludes following commands
INSERT– To insert oneormorenumberof Rows.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
SELECT– To displayoneor more rows.
UPDATE – Used to alterthe column values in a table.
DELETE– Used to delete oneor more rows.
Data DefinitionLanguage (DDL)
DDLincludes following commands
CREATE– Command used forcreatingtables.
DESC– Command used to viewthe table structure.
ALTER– Command used formodifyingtablestructure.
RENAME– usedto changethename ofthetable.
DROP– Command used for removinganexistingtable.
4. Explain about Data Models and its types.
Underlying structureofthedatabaseiscalledasdatamodels.Itisacollectionofconceptual
toolsfordescribing data,datarelationships,datasemantics,andconsistency constraints.Itisa wayto
describethe design ofthe database at physical, logical and view level.
Different Types OfData Models
Entityrelationship model
Relational model
Hierarchical model
Networkmodel
Object Based model
Object Relational model
Semi Structured Data model
Entity relationshipmodel
It is based on acollection ofreal world things orobjects called entities and the
relationshipamongtheseobjects.TheEntityrelationshipmodeliswidely usedindatabase design.
Relational Model
The relational model uses a collection of tables to represent both data and the
relationshipamongthosedata.Eachtablehasmultiplecolumnsandeachcolumnhasaunique
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
name.SoftwaresuchasOracle,MicrosoftSQLServerandSybasearebasedontherelational model.
E.g. RecordBased model.It is based onfixed format records of several types. Hierarchical
Model
Hierarchical databaseorganizedata in to a treedatastructuresuch that eachrecord type
hasonly oneowner.Hierarchicalstructureswerewidely usedinthefirstmainframedatabase
management systems.
Links arepossible verticallybut nothorizontallyordiagonally.
Advantages
High speed of access to largedatasets.
Easeof updates.
Simplicity: the design ofahierarchical databaseis simple.
Datasecurity:Hierarchicalmodelwasthefirstdatabasemodelthatofferedthedatasecurity that is
provided and enforced bythe DBMS.
Efficiency:Thehierarchicaldatabasemodelisavery efficientonewhenthedatabasecontains
alargenumber oftransactions, usingdata whose relationships are fixed.
Disadvantages
Implementation complexity
Databasemanagement problems
Lack of structural independence
NetworkModel
Themodel is based on directedgraph theory.
Thenetworkmodelreplacesthehierarchicaltreewithagraphthusallowingmoregeneral
connections amongthe nodes.
Themaindifferenceofthenetworkmodelfromthehierarchicalmodelisitsabilityto handle
many-to-many(n:n) relationship or in other words, it allows arecord to havemore
than oneparent.Example is, an employeeworking fortwo departments.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Advantages
Conceptual simplicity
Data independence
Disadvantages
Detailed structural knowledgeis required.
Lack of structural independence.
Object-Based Datamodel
Theobject-oriented model is an extension of E-R model.
Theobject-oriented model is based on a collection ofobjects.
An object contains values stored in instancevariables within theobject.
Anobjectalsocontainsbodiesofcodethatoperateintheobjectthesebodiesofcodeare called
methods.
Objectsthatcontainthesametypesofvaluesandmethodsaregroupedtogetherinto classes.
Advantages
Applications requirelesscode.
Codeis easierto maintain
Applications use morenatural datamodel.
Itprovideshigherperformancemanagementofobjectsandcomplexinterrelationships between
objects.
Object-oriented features improveproductivity.Data access is easy.
Object Relational Model
Object-relational data model combines the feature of modern object-oriented
programminglanguageswith relational databasefeatures.
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Someoftheobject-relationalsystemsavailableinthemarketareIBMDB2universal
server,Oracle Corporation‘s oracle 8, Microsoft Corporations SQLserver 7and so on.
Semi StructuredDataModel
Thisdatamodelallowstheindividualdataitemsofsametypetohavedifferentsetsof attributes.
Other data modelallows aparticular typeof dataitem to havesameset of attributes.
ExtensibleMarkupLanguage (XML)is used to represent structured data.
Updateauthorization
Allows modification but notdeletion.
Deleteauthorization
Allows deletion of data.
Theusers maybe assigned with all, none or combinationofthesetypes.
TheDDL gets some input and generates some output.
This output is placed in datadictionarywhichcontains Meta data.
Databasesystem consults the Data Dictionarybeforereadingor modifyingactual data.
Metadata is dataabout data.
DataDictionaryisaspecialtypeoftablewhichcanonlybeaccessedandupdatedby
databasesystem.
Data ManipulationLanguage
Adata-manipulationlanguage(DML)isalanguagethathelpsuserstoaccessormanipulate
data.
A queryis a statementrequestingthe retrieval of information.
Theportion of DMLthatinvolves information retrieval is called as querylanguage.
There arebasicallytwo types of DML:
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
Procedural DMLs
User should specifywhatdata areneeded andhowto get thosedata.
DeclarativeDMLs(nonproceduralDMLs)
Usershouldspecifywhatdataareneededwithoutspecifyinghowtogetthosedata.Thisis
easierto learn and user than procedural DML.
Data manipulation that can beperformed
usingDMLare, The retrieval of information
stored in thedatabase
Theinsertion ofnew information into the database
Thedeletion of information from thedatabase
Themodification ofinformation stored in thedatabase
5. Expalin about Database UsersAndAdministrator in details.
People who work with adatabasecan becategorized as:
DatabaseUsers
Databaseadministrators
1 Database Users
There are fourtypes of databaseusers, differentiated bythewaytheyinteract with the system.
Naiveusers
Naiveusersinteractwiththesystem byinvokingoneoftheapplicationprogramsthathave
been written previously.
Naiveusersare typicalusersofforminterface,wheretheusercanfillinappropriatefields
ofthe form.
Naive users mayalso simplyreadreportsgenerated from thedatabase.
ApplicationProgrammers
Application programmers are computer professionals who write application
programs.
Rapid applicationdevelopment (RAD) tools enable the application programmer to
construct forms andreports withoutwritingaprogram.
Special types of programming languages that combine control structures with data
manipulation language.Theselanguages, sometimes calledfourth-generation
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
languages.
Sophisticated users
Sophisticatedusersinteractwiththesystemwithoutwritingprograms.Instead,theyform
theirrequestsin a databasequerylanguage.
Theysubmit each such queryto aqueryprocessorthat the storagemanagerunderstands.
Onlineanalyticalprocessing(OLAP)toolssimplifyanalysisanddataminingtoolsspec
ify certain kinds of patterns in data.
Specialized users
Specializedusersaresophisticateduserswhowritespecializeddatabaseapplicationsthat
do not fit into the traditional data-processingframework.
Theapplicationsarecomputer-
aideddesignsystems,knowledgebaseandexpertsystems, systems that storedatawith
complexdata types
2 DATABASE ADMINISTRATORS
Apersonwhohassuchcentralcontroloverthesystemiscalledadatabaseadministrator
(DBA).
The functions of aDBA
include:
Schemadefinition.TheDBAcreatestheoriginaldatabaseschemabyexecutingasetofdata
definition statements in the DDL.
Storagestructureand access-method
definition.
Schemaandphysical-organizationmodification.TheDBAcarriesoutchangestotheschema
and physical organization to reflect thechanging needs of theorganization.
Grantingofauthorizationfordataaccess.Bygrantingdifferenttypesofauthorization,the
databaseadministrator can regulatewhich parts ofthe databasevarious users can access.
Authorization information is kept in a special system structure that the database
system consults whenever someone attempts to access thedata in the system.
Routinemaintenance.Examplesofthedatabaseadministrator‘sroutinemaintenanceactivitie
s
R. Loganathan, AP/CSE. Mahalakshmi Engineering College, Trichy
are:
Periodicallybackingup thedatabase
Ensuringthat enoughfreedisk space
Monitoringjobsrunningonthedatabaseandensuringthatperformanceisnotdegradedby
veryexpensive tasks submitted bysomeusers.
Ensuringthatperformanceisnotdegradedbyveryexpensivetaskssubmittedbysome
users.
top related