资源描述:
《constraints [sqlmysql module]sqlmysql约束[模块]》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、SQL/MySQLModuleFirstdaywalkthemthrough(usuallyafterfinishingupexercise1)·Mysqlwebsite·gettingstarteddocument·tables(mysqltxtfiles,accessfiles)·showhowtoloadtablesandrunqueryThenhavethemworkexercise2for2ndday.WorkQ27andexplainaggregatesinGROUPBYversusSELECT(i.e.inselectifyouuseaggregateoperationyou
2、canonlyuseaggregateoperators;elsewiseyou’llneedtonestseeQ27,oruseaGROUPBY).Work5.2.6,5.2.9(workingexamplesinmynotes).AssignthemExercise2fornexttime.Reviewexercise2.Assignthemtocarefullyreadandworkexamplesinchapter5ofRamakrishnan.Especiallyreviewsection5.5(aggregateoperators,groupby).Workexamplesin
3、class.Importantpointstoreview:·Setcomparisonoperators(5.4.3,p148).oEXISTS,IN,UNIQUE(andnegatedversions,i.e.NOTEXISTS,etc.)oOperatorANY
4、ALLwhereoperatoris{<,<=,=,<>,>=,>}oSOMEistheequivalentofANYoINisequivalentto=ANY;NOTINisequivalentto<>ANY·ExplainQ22,Q23.·Aggregateoperatorsandusesand·WorkQ27andex
5、plainaggregatesinGROUPBYversusSELECT(i.e.inselectifyouuseaggregateoperationyoucanonlyuseaggregateoperators;elsewiseyou’llneedtonestseeQ27,oruseaGROUPBY).·ExtensionsinSQL1999(statisticsetc)askthemtoinvestigate·UseofANY/ALLversusaggregates(p153)·Walkthrough154-157.ExplainQ32.Askthemwhatisthereanydif
6、ferencebetweenusingHAVINGEVERYage<60andage<60intheWHEREclause(showin5.14and5.15).·Q33·Q37;askthemtoworkinMySQLandshowexamplethatworksfromyournotes.4-5thday:StartCONSTRAINTS[SQL/MySQLmodule]on4thdayofmodule.(Betweenexercise2and3).Tellthembeforehandsotheyaresuretohavereadchapterandstartonexercise3be
7、forethisclass.Havethemcompleteexercise3before5thclass.Askthemtolistthewaysyoucanenforceintegrity:(thinkbacktohowyoudidinAccessforideas)·Domain/value(intabledefinitions)·ForeignKeys·Whataboutmanagermustmakemorethanemployeestheysupervise?(integrityconstraints)UnderstandingIntegrityConstraintsexercis
8、e.Divideclassintofourgroups(domain/typeconstraints,tablecheckconstraints,assertions,triggers).Havethemtellhowtheyaredifferent,andgiveexampleofwhereyouwouldusetheirkindofconstraint(SQLpreferably).Thenreviewwithcla