讲关系数据库的结构的计算机英语.docx

上传人:b****7 文档编号:11428045 上传时间:2023-03-01 格式:DOCX 页数:10 大小:21.80KB
下载 相关 举报
讲关系数据库的结构的计算机英语.docx_第1页
第1页 / 共10页
讲关系数据库的结构的计算机英语.docx_第2页
第2页 / 共10页
讲关系数据库的结构的计算机英语.docx_第3页
第3页 / 共10页
讲关系数据库的结构的计算机英语.docx_第4页
第4页 / 共10页
讲关系数据库的结构的计算机英语.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

讲关系数据库的结构的计算机英语.docx

《讲关系数据库的结构的计算机英语.docx》由会员分享,可在线阅读,更多相关《讲关系数据库的结构的计算机英语.docx(10页珍藏版)》请在冰豆网上搜索。

讲关系数据库的结构的计算机英语.docx

讲关系数据库的结构的计算机英语

讲关系数据库的结构的计算机英语

计算机英语

StructureoftheRelationaldatabase

Therelationalmodelisthebasisforanyrelationaldatabasemanagementsystem(RDBMS).Arelationalmodelhasthreecorecomponents:

acollectionofobjectsorrelations,operatorsthatactontheobjectsorrelations,anddataintegritymethods.Inotherwords,ithasaplacetostorethedata,awaytocreateandretrievethedata,andawaytomakesurethatthedataislogicallyconsistent.

Arelationaldatabaseusesrelations,ortwo-dimensionaltables,tostoretheinformationneededtosupportabusiness.Letsgooverthebasiccomponentsofatraditionalrelationaldatabasesystemandlookathowarelationaldatabaseisdesigned.Onceyouhaveasolidunderstandingofwhatrows,columns,tables,andrelationshipsare,youllbewellonyourwaytoleveragingthepowerofarelationaldatabase.

Tables,Row,andColumns

Atableinarelationaldatabase,alternativelyknownasarelation,isatwo-dimensionalstructureusedtoholdrelatedinformation.Adatabaseconsistsofoneormorerelatedtables.

Note:

Dontconfusearelationwithrelationships.Arelationisessentiallyatable,andarelationshipisawaytocorrelate,join,orassociatetwotables.

Arowinatableisacollectionorinstanceofonething,suchasoneemployeeoronelineitemonaninvoice.Acolumncontainsalltheinformationofasingletype,andthepieceofdataattheintersectionofarowandacolumn,afield,isthesmallestpieceofinformationthatcanberetrievedwiththedatabasesquerylanguage.Forexample,atablewithinformationaboutemployeesmighthaveacolumncalledLAST_NAMEthatcontainsalloftheemployeeslastnames.Dataisretrievedfromatablebyfilteringonboththerowandthecolumn.

PrimaryKeys,Datatypes,andForeignKeys

TheexamplesthroughoutthisarticlewillfocusonthehypotheticalworkofScottSmith,databasedeveloperandentrepreneur.HejuststartedanewwidgetcompanyandwantstoimplementafewofthebasicbusinessfunctionsusingtherelationaldatabasetomanagehisHumanResources(HR)department.

Relation:

Atwo-dimensionalstructureusedtoholdrelatedinformation,alsoknownasatable.

Note:

MostofScottsemployeeswerehiredawayfromoneofhispreviousemployers,someofwhomhaveover20yearsofexperienceinthefield.Asahiringincentive,Scotthasagreedtokeepthenewemployeesoriginalhiredateinthenewdatabase.

Row:

Agroupofoneormoredataelementsinadatabasetablethatdescribesaperson,place,orthing.

Column:

Thecomponentofadatabasetablethatcontainsallofthedataofthesamenameandtypeacrossallrows.

Youlllearnaboutdatabasedesigninthefollowingsections,butletsassumeforthemomentthatthemajorityofthedatabasedesigniscompletedandsometablesneedtobeimplemented.ScottcreatestheEMPtabletoholdthebasicemployeeinformation,anditlookssomethinglikethis:

NoticethatsomefieldsintheCommission(COMM)andManager(MGR)columnsdonotcontainavalue;theyareblank.Arelationaldatabasecanenforcetherulethatfieldsinacolumnmayormaynotbeempty.Inthiscase,itmakessenseforanemployeewhoisnotintheSalesdepartmenttohaveablankCommissionfield.ItalsomakessenseforthepresidentofthecompanytohaveablankManagerfield,sincethatemployeedoesntreporttoanyone.

Field:

Thesmallestpieceofinformationthatcanberetrievedbythedatabasequerylanguage.Afieldisfoundattheintersectionofarowandacolumninadatabasetable.

Ontheotherhand,noneofthefieldsintheEmployeeNumber(EMPNO)columnareblank.Thecompanyalwayswantstoassignanemployeenumbertoanemployee,andthatnumbermustbedifferentforeachemployee.Oneofthefeaturesofarelationaldatabaseisthatitcanensurethatavalueisenteredintothiscolumnandthatitisunique.TheEMPNOcolumn,inthiscase,istheprimarykeyofthetable.

PrimaryKey:

Acolumn(orcolumns)inatablethatmakestherowinthetabledistinguishablefromeveryotherrowinthesametable.

NoticethedifferentdatatypesthatarestoredintheEMPtable:

numericvalues,characteroralphabeticvalues,anddatevalues.

Asyoumightsuspect,theDEPTNOcolumncontainsthedepartmentnumberfortheemployee.ButhowdoyouknowwhatdepartmentnameisassociatedwithwhatnumberScottcreatedtheDEPTtabletoholdthedescriptionsforthedepartmentcodesintheEMPtable.

TheDEPTNOcolumnintheEMPtablecontainsthesamevaluesastheDEPTNOcolumnintheDEPTtable.Inthiscase,theDEPTNOcolumnintheEMPtableisconsideredaforeignkeytothesamecolumnintheDEPTtable.

Aforeignkeyenforcestheconceptofreferentialintegrityinarelationaldatabase.TheconceptofreferentialintegritynotonlypreventsaninvaliddepartmentnumberfrombeinginsertedintotheEMPtable,butitalsopreventsarowintheDEPTtablefrombeingdeletedifthereareemployeesstillassignedtothatdepartment.

ForeignKey:

Acolumn(orcolumns)inatablethatdrawsitsvaluesfromaprimaryoruniquekeycolumninanothertable.Aforeignkeyassistsinensuringthedataintegrityofatable.ReferentialIntegrity?

Amethodemployedbyarelationaldatabasesystemthatenforcesone-to-manyrelationshipsbetweentables.

DataModeling

BeforeScottcreatedtheactualtablesinthedatabase,hewentthroughadesignprocessknownasdatamodeling.Inthisprocess,thedeveloperconceptualizesanddocumentsallthetablesforthedatabase.OneofthecommonmethodsformodelingadatabaseiscalledERA,whichstandsforentities,relationships,andattributes.Thedatabasedesignerusesanapplicationthatcanmaintainentities,theirattributes,andtheirrelationships.Ingeneral,anentitycorrespondstoatableinthedatabase,andtheattributesoftheentitycorrespondtocolumnsofthetable.

DataModeling:

Aprocessofdefiningtheentities,attributes,andrelationshipsbetweentheentitiesinpreparationforcreatingthephysicaldatabase.

Thedata-modelingprocessinvolvesdefiningtheentities,definingtherelationshipsbetweenthoseentities,andthendefiningtheattributesforeachoftheentities.Onceacycleiscomplete,itisrepeatedasmanytimesasnecessarytoensurethatthedesigneriscapturingwhatisimportantenoughtogointothedatabase.Letstakeacloserlookateachstepinthedata-modelingprocess.

DefiningtheEntities

First,thedesigneridentifiesalloftheentitieswithinthescopeofthedatabaseapplication.Theentitiesarethepersons,places,orthingsthatareimportanttotheorganizationandneedtobetrackedinthedatabase.Entitieswillmostlikelytranslateneatlytodatabasetables.Forexample,forthefirstversionofScottswidgetcompanydatabase,heidentifiesfourentities:

employees,departments,salarygrades,andbonuses.ThesewillbecometheEMP,DEPT,*****E,andBONUStables.

DefiningtheRelationshipsBetweenEntities

Oncetheentitiesaredefined,thedesignercanproceedwithdefininghoweachoftheentitiesisrelated.Often,thedesignerwillpaireachentitywitheveryotherentityandask,IstherearelationshipbetweenthesetwoentitiesSomerelationshipsareobvious;somearenot.

Inthewidgetcompanydatabase,thereismostlikelyarelationshipbetweenEMPandDEPT,butdependingonthebusinessrules,itisunlikelythattheDEPTand*****Eentitiesarerelated.Ifthebusinessrulesweretorestrictcertainsalarygradestocertaindepartments,therewouldmostlikelybeanewentitythatdefinestherelationshipbetweensalarygradesanddepartments.Thisentitywouldbeknownasanassociativeorintersectiontableandwouldcontainthevalidcombinationsofsalarygradesanddepartments.

AssociativeTable:

Adatabasetablethatstoresthevalidcombinationsofrowsfromtwoothertablesandusuallyenforcesabusinessrule.Anassociativetableresolvesamany-to-manyrelationship.

Ingeneral,therearethreetypesofrelationshipsinarelationaldatabase:

One-to-manyThemostcommontypeofrelationshipisone-to-many.Thismeansthatforeachoccurrenceinagivenentity,theparententity,theremaybeoneormoreoccurrencesinasecondentity,thechildentity,towhichitisrelated.Forexample,inthewidgetcompanydatabase,theDEPTentityisaparententity,andforeachdepartment,therecouldbeoneormoreemployeesassociatedwiththatdepartment.TherelationshipbetweenDEPTandEMPisone-to-many.

One-to-oneInaone-to-onerelationship,arowinatableisrelatedtoonlyoneornoneoftherowsinasecondtable.Thisrelationshiptypeisoftenusedforsubtyping.Forexample,an*****Etablemayholdtheinformationcommontoallemployees,whilethe*****E,*****E,and*****TORtablesholdinformationuniquetofull-timeemployees,part-timeemployees,andcontractors,respectively.Theseentitieswouldbeconsideredsubtypesofan*****Eandmaintainaone-to-onerelationshipwiththe*****Etable.Theserelationshipsarenotascommonasone-to-manyrelationships,becauseifoneentityhasanoccurrenceforacorrespondingrowinanotherentity,inmostcases,theattributesfrombothentitiesshouldbeinasingleentity.

Many-to-manyInamany-to-manyrelationship,onerowofatablemayberelatedtomanyrowsofanothertable,andviceversa.Usually,whenthisrelationshipisimplementedinthedatabase,athirdentityisdefinedasanintersectiontabletocontaintheassociationsbetweenthetwoentitiesintherelationship.Forexample,inadatabaseusedforschoolclassenrollment,the*****tablehasamany-to-manyrelationshipwiththeCLASStableonestudentmaytakeoneormoreclasses,andagivenclassmayhaveoneormore

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1