Tải bản đầy đủ - 0 (trang)
Hack 10. Find Database Objects in a Snap

Hack 10. Find Database Objects in a Snap

Tải bản đầy đủ - 0trang

Figure1-21.Crypticformnamesthatcanstumpa

user



Figure1-22.Enteringadescription



Aneatthingaboutthisapproachisthatyoucanevenusea

warningmessagesothatusersknownottoopenanobject.

Thisisparticularlyhelpfulinthecaseofsubforms.Users

shouldn'topensubformsdirectlybecausetheyappearinside

otherforms.Thedescriptiontellsusersnottoopenthem.



Figure1-23.Selectingaformbyitsdescription



KirkLamb



Hack11.UseaJunctionTable



Correctlymodelamany-to-manyrelationship.

It'seasytofallintothetrapofassumingallrelationshipsareof

theone-to-manytype.It'struethatmanydatarelationshipsdo

followtheone-to-manyparadigm.Forexample,onepersonhas

zeroormoretelephonenumbers.However,notalldatais

meanttobemodeledinthisway.

Aperfectexampleofdatathatappearstofittheone-to-many

model,butdoesn't,istherelationshipbetweeninstructorsand

students.Ontheonehand,oneinstructordoeshavemany

students,therebyprovingaone-to-manyrelationshipexists.On

theotherhand,onestudenthasmanyinstructorswhichisalsoa

one-to-manyrelationship.So,whatistheproblem?

Figure1-24showsonewaytomodelinstructorsandstudents.

Theinstructortableoccupiestheonespotandthestudenttable

occupiesthemanyspot.Instructorsandstudentsgettogether

forappointments.Thismodelworksbutemphasizesthat

instructorsareofadifferentlevelthanstudents,whichmight

notbetrue.



Figure1-24.Aninefficientone-to-many

relationship



InFigure1-24,thestudenttableisalsorequiredtohavethe

instructorIDastheforeignkey.Thisisacceptable,butnow

lookattheappointmentstable;itconsidersappointmentsas

belongingtostudents,butappointmentsbelongtoboth

instructorsandstudents.

Figure1-25showshowtoresolvethedilemmainthedata

model.Becauseappointmentsbelongtobothinstructorsand

students,thatishowthemodelshouldlook.Theappointments

tableservesasajunctiontablebetweeninstructorsand

students.

Ajunctiontablebecomesthemanytablefortwoormoreother

tables.Allthekeyfieldsoftheonetablesbecomeforeignkeys

inthejunctiontable.Anyotherpertinentfieldsareincludedin

thejunctiontable.Inthisexample,thejunctiontablehasfields

forthedateandtimetheinstructorandstudentwillmeet.Also,

thestudenttablenolongerhastheinstructorIDasaforeign

key.Inthisexample,instructorsandstudentshaveno

hierarchy;therefore,itmakessensethatonedoesn'tserveasa

manytotheother.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 10. Find Database Objects in a Snap

Tải bản đầy đủ ngay(0 tr)

×