Вы находитесь на странице: 1из 10

20/01/2012

CSI21322012
DGD1: Introduction

Exercise1:Discussthecapabilitiesthatshould beprovidedbyaDBMS RefertoChapter1,slide16oftheclassnotes.


Uniform U if data d administration. d i i i Reducedapplicationdevelopmenttime. Dataindependence Efficientaccess Dataintegrityandsecurity Concurrentaccess,recoveryfromcrashes. Others Webbasedaccess Distributedaccess

20/01/2012

AUniversityDB

Exercise2:Identifysomequeriesandupdates youwouldrunagainstthisDB.
(a)(Query)Listthenamesofallstudentsmajoringin ComputerScience. (b)(Query)WhataretheprerequisitesoftheDatabase course? (c)(Query)RetrievethetranscriptofSmith.Thisisalistof <CourseName, SectionIdentifier,Semester,Year,Grade>for eachcoursesectionthatSmithhas completed. (d)(Update)Insertanewstudentinthedatabasewhose Name=Jackson, , StudentNumber=23, ,Class=1( (Firsty year), ), andMajor=MATH. (e)(Update)ChangethegradethatSmithreceivedinIntroto ComputerSciencesection 119toB.

20/01/2012

Exercise3:Whatisthedifferencebetween controlledanduncontrolled redundancy?


Redundancyiswhenthesamefactisstoredmultiple timesinseveralplacesinadatabase.
Forexample,saythenameofthestudentwith StudentNumber=8isBrownisstoredmultipletimes.

Redundancyiscontrolled whentheDBMSensuresthat multiplecopiesofthesamedataareconsistent.


Forexample,ifanewrecordwithStudentNumber=8is storedinthedatabase,theDBMSwillensurethatthis recordisforStudentBrown.

IftheDBMShasnocontroloverthis,wehave uncontrolledredundancy.
5

Exercise4:Specifyalltherelationshipsamong therecordsofthedatabaseshowninthefigure.
(a)EachSECTIONrecordisrelatedtoaCOURSErecord. (b)E Each hGRADE_REPORT GRADE REPORTrecord dis i related l t dto t one STUDENTrecordandoneSECTION record. (c)EachPREREQUISITErecordrelatestwoCOURSE records:oneintheroleofacourse andtheotherin theroleofaprerequisitetothatcourse.

20/01/2012

Exercise5:Givesomeexamplesofintegrity constraintsthatcanapplytothedatabase.
(a)TheStudentNumber shouldbeuniqueforeachSTUDENTrecord(key constraint). (b)TheCourseNumber shouldbeuniqueforeachCOURSErecord(key constraint). c)AvalueofCourseNumber inaSECTIONrecordmustalsoexistinsome COURSE record(referentialintegrityconstraint). (d)AvalueofStudentNumber inaGRADE_REPORTrecordmustalsoexistin some STUDENTrecord(referentialintegrityconstraint). (e) ( )ThevalueofGradeinaGRADE_REPORTrecordmustbeoneofthevalues intheset (A,B,C,D,F,I,U,S}(domainconstraint). (f)EveryrecordinCOURSEmusthaveavalueforCourseNumber (entity integrity constraint). (g)ASTUDENTrecordcannothaveavalueofClass=2(sophomore)unlessthe student hascompletedanumberofsectionswhosetotalcourse CreditHours isgreaterthat24 credits(generalsemanticintegrity 7 constraint).

Exercise6a:Whatislogicaldataindependence andwhyisitimportant? Usersareshieldedfromchangesinthe (logical)relation(s)tobestored stored. Forexample,relationStudent(SID,Name, GPA)isreplacedbytworelations: StudentNames(SID,Name)and StudentGPA(SID,GPA) Users U areshielded hi ld dfrom f this thi change h with itha view Student(SID,Name,GPA)andapplication programsarethusunawareofthischange
8

20/01/2012

Exercise6b:WhatisPhysicalDataIndependence? Usersareshieldedfromchangesintheway th tthe that th relation l ti i isstored. t d Forexample,theStudent()relationmaybe storedas


afilesortedonSID,or asaheap(randomorder)file file,or asafilewhichisIndexedonGPA(moreabout indexeslaterinthecourse)
9

SaythenameoftheCS(ComputerScience)Department changestoCSSE(ComputerScienceandSoftwareEngineering) Department. Thecorrespondingprefixforthecoursenumber alsochanges. Exercise7a:Identifythecolumnsinthedatabasethatwould needtobeupdated updated.


The following columns will need to be updated. Table STUDENT COURSE SECTION PREREQUISITE Column(s) Major CourseNumber and Department C CourseNumber N b CourseNumber and PrerequisiteNumber

10

20/01/2012

Exercise7b:RestructurethecolumnsinCOURSE, SECTION,andPREREQUISITEtablessothatonlyone columnwillneedtobeupdated.


Youshouldsplitthefollowingcolumnsintotwocolumns:
Table COURSE SECTION PREREQUISITE PREREQUISITE Column CourseNumber CourseNumber CourseNumber PrerequisiteNumber Columns CourseDept and CourseNum CourseDept and CourseNum CourseDept and CourseNum PreReqDept and PreReqNum

NotethatintheCOURSEtable,thecolumnCourseDept willnotbeneededaftertheabovechange change,sinceitis redundantwiththeDepartmentcolumn

11

Recentchangesinprivacylawshavedisallowed organizationsfromusingSINstoidentifyindividuals unlesscertainrestrictionsaresatisfied. Asaresult,universitiescannotuseSINsasprimarykeys (exceptforfinancialdata). Inpractice,StudentID,auniqueID,auniqueidentifier, assignedtoeverystudent,islikelytobeusedasthe primarykeyratherthanSSNsinceStudentID isusable acrossallaspectsofthesystem. Somed S database t b d designers i arereluctant l t tto t use generatedkeys(alsoknownassurrogate keys)for primarykeys(suchasStudentID)becausetheyare artificial.
12

20/01/2012

Exercise8a:Whataretheadvantagesofusinga surrogatekey(anautomatickeywithno meaning)?


Hasnomeaningandthusnoprivacyviolations Canuseautonumbers,whichisusuallyfast Avoidthatdataisambiguous,duetopotentialreuse ofproductionkeys

13

Exercise8b:Canyouproposeanynaturalchoicesof keysthatcanbeusedtostorethestudentrecordina UNIVERSITYdatabase?


Acombinationoflastname,firstnameandphonenumber(s) maybeused However,whatifthenameand/orphonenumberchanges? Also,ifthestudenthasmorethanonephonenumber,it wouldbebettertocreateaseparaterelationPhone(SIN,type, number)

14

20/01/2012

Exercise9:Giveexamplesofsystemsinwhichitmay makesensetousetraditionalfileprocessinginsteadof adatabaseapproach.


1.Smallinternalutilitytolocatefiles 2. Smallsingleuserapplicationthatdoesnotrequire security(suchasacustomizedcalculatororapersonal addressandphonebook) 3. Realtimenavigationsystem(withheavycomputation andverylittledata)

15

WhenNottoUseaDBMS
Moredesirabletouseregularfilesfor:
Simple,welldefineddatabaseapplicationsnot expectedtochangeatall Stringent,realtimerequirementsthatmaynotbe metbecauseofDBMSoverhead Embeddedsystemswithlimitedstoragecapacity Nomultipleuseraccesstodata

20/01/2012

Recall:AdvantagesofUsingtheDBMS Approach
Controllingredundancy Restrictingunauthorizedaccess
Securityandauthorizationsubsystem Privilegedsoftware

Providingpersistent storageforprogramobjects Providingstoragestructuresandsearch techniquesforefficientquery processing


Indexes Buffering andcaching Queryprocessingandoptimization

Recall:AdvantagesofUsingtheDBMS Approach(cont'd.)
Providingbackupandrecovery
B Backup k and drecoverysubsystem b of fthe h DBMSis i responsibleforrecovery

Providingmultipleuserinterfaces
Graphicaluserinterfaces(GUIs)

Representingcomplexrelationshipsamongdata
Mayincludenumerousvarietiesofdatathatare interrelatedinmanyways

Enforcingintegrityconstraints

20/01/2012

Nexttime
EERdiagrams

19

10

Вам также может понравиться