Академический Документы
Профессиональный Документы
Культура Документы
CSI21322012
DGD1: Introduction
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
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
10
20/01/2012
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
13
14
20/01/2012
15
WhenNottoUseaDBMS
Moredesirabletouseregularfilesfor:
Simple,welldefineddatabaseapplicationsnot expectedtochangeatall Stringent,realtimerequirementsthatmaynotbe metbecauseofDBMSoverhead Embeddedsystemswithlimitedstoragecapacity Nomultipleuseraccesstodata
20/01/2012
Recall:AdvantagesofUsingtheDBMS Approach
Controllingredundancy Restrictingunauthorizedaccess
Securityandauthorizationsubsystem Privilegedsoftware
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