SQL数据库英文文献及翻译ThefactthatyouarereadingabookonSQLindicatesthatyou,somehow,needtointeractwithdatabases.SQLisalanguageusedtodojustthis,sobeforelookingatSQLitself,itisimportantthatyouunderstandsomebasicconceptsaboutdatabasesanddatabasetechnologies.Whetheryouareawareofitornot,youusedatabasesallthetime.Eachtimeyouselectanamefromyouremailaddressbook,youareusingadatabase.IfyouconductasearchonanInternetsearchsite,youareusingadatabase.Whenyoulogintoyournetworkatwork,youarevalidatingyournameandpasswordagainstadatabase.EvenwhenyouuseyourATMcardatacashmachine,youareusingdatabasesforPINnumberverificationandbalancechecking.Buteventhoughweallusedatabasesallthetime,thereremainsmuchconfusionoverwhatexactlyadatabaseis.Thisisespeciallytruebecausedifferentpeopleusethesamedatabasetermstomeandifferentthings.Therefore,agoodplacetostartourstudyiswithalistandexplanationofthemostimportantdatabaseterms.ReviewingBasicConceptsWhatfollowsisaverybriefoverviewofsomebasicdatabaseconcepts.Itisintendedtoeitherjoltyourmemoryifyoualreadyhavesomedatabaseexperience,ortoprovideyouwiththeabsolutebasics,ifyouarenewtodatabases.UnderstandingdatabasesisanimportantpartofmasteringSQL,andyoumightwanttofindagoodbookondatabasefundamentalstobrushuponthesubjectifneeded.WhatIsaDatabase?Thetermdatabaseisusedinmanyorganizedfashion.Thesimplestwaytothinkofitistoimagineadatabaseasafilingcabinet.Thefilingcabinetissimplyaphysicallocationtostoredata,regardlessofwhatthatdataisorhowitisorganizedDatabaseAcontainer(usuallyafileorsetoffiles)tostoreorganizeddata.MisuseCausesConfusionPeopleoftenusethetermdatabasetorefertothedatabasesoftwaretheyarerunning.Thisisincorrect,anditisasourceofmuchconfusion.DatabasesoftwareisactuallycalledtheDatabaseManagementSystem(orDBMS).ThedatabaseisthecontainercreatedandmanipulatedviatheDBMS.Adatabasemightbeafilestoredonaharddrive,butitmightnot.Andforthemostpartthisisnotevensignificantasyouneveraccessadatabasedirectlyanyway;youalwaysusetheDBMSanditaccessesthedatabaseforyou.TablesWhenyoustoreinformationinyourfilingcabinetyoudon'tjusttossitinadrawer.Rather,youcreatefileswithinthefilingcabinet,andthenyoufilerelateddatainspecificfiles.Inthedatabaseworld,thatfileiscalledatable.Atableisastructuredfilethatcanstoredataofaspecifictype.Atablemightcontainalistofcustomers,aproductcatalog,oranyotherlistofinformation.TableAstructuredlistofdataofaspecifictype.Thekeyhereisthatthedatastoredinthetableisonetypeofdataoronelist.Youwouldneverstorealistofcustomersandalistofordersinthesamedatabasetable.Doingsowouldmakesubsequentretrievalandaccessdifficult.Rather,you'dcreatetwotables,oneforeachlist.Everytableinadatabasehasanamethatidentifiesit.Thatnameisalwaysunique—meaningnoothertableinthatdatabasecanhavethesamename.TableNamesWhatmakesatablenameuniqueisactuallyacombinationofseveralthingsincludingthedatabasenameandtablename.Somedatabasesalsousethenameofthedatabaseowneraspartoftheuniquename.Thismeansthatwhileyoucannotusethesametablenametwiceinthesamedatabase,youdefinitelycanreusetablenamesindifferentdatabases.Tableshavecharacteristicsandpropertiesthatdefinehowdataisstoredinthem.Theseincludeinformationaboutwhatdatamaybestored,howitisbrokenup,howindividualpiecesofinformationarenamed,andmuchmore.Thissetofinformationthatdescribesatableisknownasaschema,andschemaareusedtodescribespecifictableswithinadatabase,aswellasentiredatabases(andtherelationshipbetweentablesinthem,ifany).SchemaInformationaboutdatabaseandtablelayoutandproperties.ColumnsandDatatypesTablesaremadeupofcolumns.Acolumncontainsaparticularpieceofinformationwithinatable.ColumnAsinglefieldinatable.Alltablesaremadeupofoneormorecolumns.Thebestwaytounderstandthisistoenvisiondatabasetablesasgrids,somewhatlikespreadsheets.Eachcolumninthegridcontainsaparticularpieceofinformation.Inacustomertable,forexample,onecolumncontainsthecustomernumber,anothercontainsthecustomername,andtheaddress,city,state,andzipareallstoredintheirowncolumnsBreakingUpDataItisextremelyimportanttobreakdataintomultiplecolumnscorrectly.Forexample,city,state,andzipshouldalwaysbeseparatecolumns.Bybreakingtheseout,itbecomespossibletosortorfilterdatabyspecificcolumns(forexample,tofindallcustomersinaparticularstateorinaparticularcity).Ifcityandstatearecombinedintoonecolumn,itwouldbeextremelydifficulttosortorfilterbystate.1657Eachcolumninadatabasehasanassociateddatatype.Adatatypedefineswhattypeofdatathecolumncancontain.Forexample,ifthecolumnistocontainanumber(perhapsthenumberofitemsinanorder),thedatatypewouldbeanumericdatatype.Ifthecolumnweretocontaindates,text,notes,currencyamounts,andsoon,theappropriatedatatypewouldbeusedtospecifythis.DatatypeAtypeofalloweddata.Everytablecolumnhasanassociateddatatypethatrestricts(orallows)specificdatainthatcolumn.Datatypesrestrictthetypeofdatathatcanbestoredinacolumn(forexample,preventingtheentryofalphabeticalcharactersintoanumericfield).Datatypesalsohelpsortdatacorrectly,andplayanimportantroleinoptimizingdiskusage.Assuch,specialattentionmustbegiventopickingtherightdatatypewhentablesarecreated.DatatypeCompatibilityDatatypes