Tải bản đầy đủ - 0 (trang)
Chapter 11. Developing for Multiuser Deployment

Chapter 11. Developing for Multiuser Deployment

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

DevelopingforMultipleUsers

Someofthebest,mostlovinglydevelopedFileMakerPro

systemsareonlyeverusedbyasingleperson.Acertain

author'smotherisaprimeexample:Herentireinsurancesales

practiceisdrivenbyaFileMakerProdatabase.Itisamature

system,builtsothat"someone'smom"canuseit,andlives

withoutanyexpectationofbeingextendedtoincludeother

users.

Thentherearetherestofthedatabasesoutthere.FileMaker

Proenjoysagracefulgrowthcurvefromsingle-userapplications

tosystemsthatsupportenterprise-levelworkgroupsand

operationsofhundredsofusers.

Thisgracefultransitionfromsingle-usertomultiuserthankfully

meansthatissuestotakeintoconsiderationwhenbuilding

multiusersystemsarereasonablymodest.Muchofwhatyou

alreadyknowaboutbuildingFileMakerProsystemsregardlessof

yourplanneddeploymentalsoappliesdirectlytobuildinga

multiuserapplication.

We'llcovertwoprimarytopics:howtheFileMakerengine

handlesmultipleusers,anddevelopmenttechniquesyouneed

toconsiderwhenbuildingmultiuserapplications.Asathird

discussion,wealsogointosomedepthaboutaudittrails,given

thattheyoftenareusedtohelpensuredataintegrityin

systemsusedbylargerorganizationsandareusedspecifically

totrackmultiple-userscenarios.

Werecommendthatanyoneintendingtodeployasystemto

multipleusersreadthischapter.Someoftheissueswediscuss

becomenecessaryconsiderationsonlyinsystemsthatare

gettingheavyusefrommultipleusers,butthey'regoodtohave

inmindnonetheless.



ThischapterisagoodcompaniontoChapter24"Deployingand

ExtendingFileMaker,"p.755.



TograsptheITinfrastructurallogisticsofhostingaFileMakerPro

solution,readChapter25"FileMakerServerandServerAdvanced",p.

779.



"Sessions"inFileMakerPro

FileMakerProisaclient/serverapplication(atleastwhenfiles

arebeinghostedbyanindividualuserorbyFileMakerServer).

EachtimesomeoneusingFileMakerPro(aclient)connectsto

FileMakerServerandopensaninstanceofthefileshosted

there,hecreatesasession.

Inpracticalterms,thismeansthatoneofyouruserscanbeon

layout#10whileyouyourselfareworkingwithlayout#2.You

canrunascriptandnothingwillnecessarilyhappenonanother

user'scomputer;likewise,someoneelsecanexportdataonher

machine,whileyou'reperformingafindrequestinthevery

samedatabasetableonyours.Youeachhaveaseparate

connectiontothedatabase,withitsownuniqueenvironment.

Whileworkingwiththesamedata,allyouruserscanbe

performingseparate,distincttasksinyoursystem.Eachuser

canhaveaseparateviewofthedatabase,withdifferentactive

windows,activetables,oractivefoundsets,amongother

things.

Generally,theseindividualusersessionsdon'tinterferewith

eachotheratall;however,therearecasesinwhichtheycan

conflictforexample,whentwouserstrytoeditthesamerecord

atthesametime.Wewillcoverthroughoutthischaptervarious

techniquesforidentifyingandcopingwithsuchissues.

Theonethingthatisconsistentacrossallusersessionsisthe

actualdatainthedatabase.Changesyoumaketorecordsyou

areeditingareimmediatelyvisibletootherusersinthesystem,

andviceversa.Ourdiscussionofsessionspertainsonlyto

globalfieldsandvariables,windowstates,andlayouts.Actual

dataisstoredanddisplayedconsistentlyforeveryone.

Beforeapproachinghowtomanagesessionsandpotential

conflicts,itisimportanttounderstandwhatasessionisand



howFileMakerPromanagesmultipleusers.InFileMakerPro,

sessionsareimplicitandenjoyastateful,persistent,always-on

connectiontotheserver.Thesystempreservesandisolates

eachuserexperienceintheFileMakerProclient.Keepinmind

thatafterthesessionisover(anindividualuserclosesthe

database),allinformationaboutthatsessionwhatlayoutwasin

use,wherewindowswerepositioned,whatthefoundsetwasis

discarded.Thenexttimethatuseropensthedatabasein

question,itopensinitsdefaultstate,withnopreservationof

howtheuserlastleftthesystem.

YoumighthaveheardthetermsessionasappliedtotheWeb.

FileMakerProisquitedifferent.OntheWeb,connectionsare

statelessbydefaulttheyhavenomemory.Thewebserverdoes

notmaintainaconnectiontoauser;theeffectofapersistent

sessionisapproximatedbytheexplicitcreationofanidentifier

foragivenuserwhenshelogsintoasystem.Thatidentifieris

thenpassed(andoftenstored/retrievedviaacookie)through

allthepagerequestsapersonmaymakeinagiventime

period.Webdevelopersneedtoexplicitlycreatethemechanics

ofasessiontopreserveauser'sexperiencefrompagetopage.

WheneveryoubuyabookfromAmazon,thedevelopersthere

havenodoubtlaboredtomakesurethateachpageyouvisit

trackssensiblyyouruseofthesiteespeciallywhenitcomesto

themultipageshoppingcartexperience.FileMaker,bycontrast,

providespersistentdatabasesessionswithnoadditionaleffort

byyou,thedeveloper.



Session-SpecificElements

FileMakerPro'ssessionsmaintainaconsistentuserexperience

untiltheapplicationitselfisclosed.Thisexperienceincludes

yourloginaccount(unlessyouspecificallylogoutandlogback

in),thepositionandnumberofwindowsyouhaveopen,which

layoutsyou'reon,yourcurrentfoundset,yourcurrentsort

order,andportalscrollpositions.Onthedevelopmentsideof



things,customcolorsyou'vestoredinthelayouttoolsare,

unfortunately,lostattheendofasessionaswell.



GlobalBehavior

Globals(fieldsspecifiedashavingglobalstorage,aswellas

globalscriptvariables)aresession-specificandrequire

additionaldiscussion.Inamultiuserclientsession,theyutilize

andholdvaluesuniquetoonespecificuser'ssession.This

enablesyouasadevelopertodependonglobalsstoring

differentinformationforeachuser.Asimpleexampleisa

displayedaccountnameatthetopofeachlayoutsetatthe

timeoflogin.

Formoredetailsonglobalfieldstorage,see"StorageandIndexing,"p.

86.



Atthestartofasession,eachglobalfieldisinitializedtothe

lastvalueithadinsingle-usermode.Ifyouruninsingle-user

modeonly,thismakestheglobalfieldvalueappeartopersist

acrosssessions,butit'smisleadingtoinferthatthereare

multiuserandsingle-usertypesofsessions.Storinginformation

inglobalfieldsforsingleusersisahandywaytoleavethings

thewaytheywere,butitalsoallowsdeveloperstocreatea

defaultstateforglobalfields.

Globalfieldsareusedforarangeoffunctionsinmultiuser

databases:Theyoftenholdimagesfornavigationanduser

interfacepurposesandtheysometimesholdsessioninformation

suchasthecurrentdateortheactive,logged-inuser.Itmakes

sense,then,thatthey'dbespecifictoagivenuser'sexperience.

Ifyourglobalfieldssuddenlyseemtobeholdingwrongdata,referto

"UnpredictableGlobalDefaultValues"inthe"Troubleshooting"sectionat



theendofthischapter.



Globalvariables,ontheotherhand,donothavestoredvalues

fromsessiontosessioninsingleormultiusermode.Asa

developeryouwillneedtoexplicitlyinitializethevariablesyou

intendtohavethesystemutilize,ideallyatthebeginningof

eachsession.

Foracompletediscussionofscriptvariables,see"ScriptVariables,"p.

448.



UserAccountsandSessionData

Onecommonuseofglobalbehaviorinamultiuserenvironment

istosetaglobalfieldwithyourcurrentlylogged-inaccount.

Thisenablesyoutoalwayshaveacentralstoredvaluethat's

easytouseincalculationformulasandscripts.Onecouldargue

thatsimplyusingtheGet(AccountName)functionwherever

necessarywouldaccomplishthesameend,butthere'san

additionaluseforstoringthecurrentaccountnameinaglobal:

YoucandrivearelationshipwithitintoaUsertablebyusing

theaccountnameasauniquematchfield.



Note

Notethataglobalvariable,asopposedtoaglobal

field,cannotdrivearelationship.Thisdifferencecan

playasignificantroleindeterminingwhetherto

storeparticularsessiondatainaglobalfieldora

globalvariable.



Thisenablesyoutotieaccountinformationtodata.Youmight

wanttodothisif,forexample,youneedtostoresomeone's

realname,herpreferencetoalwaysstartonaspecificlayout

whenthesystemopens,or(inaparticularlyabstractexample)

inwhatlanguageshewantstouseyourdatabase.

Alltheseexamplesdependonyourhavingdonesomethingwith

theinformationyoustoreinausertable.It'susefultostore

someone'spreferenceforastartinglayoutonlyifyouthenwrite

therequisitescriptthatusesthisasareference.

Anotherpossibilitylieswithtrackingdatabaseuse.Although

youmightdebatewhetheradatabase(ordatabase

administrator)shouldbelookingoversomeone'sshoulder,you

couldwriteroutinesthatpostrecordstoauserlogtable

wheneveruserslogin,logout,orevenwhentheyperform

certainscriptedactions(deleterecords,createrecords,runan

invoicereport,andsoon).

Onemoreuser-friendlyoptionistoaccommodateuserssimply

byenablingthemtospecifywheretheypreferawindowtobe

positionedandsized.Allthesevariousoptionscanbeenabled

bystoringinformationspecifictoasingleperson'ssessionin

globalfields.



Concurrency

Youmighthaveheardthetermconcurrencyasitrelatesto

databases.Itreferstothelogicandbehaviorofdatabase

systemswhentwo(ormore)usersattempttointeractwiththe

sameinformation.Asimplemetaphormightbetwopeople

tryingtouseaphonebookordictionaryatoncethey'relikelyto

tripovereachotherabit.Everymultiuserdatabaseplatform

hastoaddressthisissue.

Certainlyit'dbeeasiesttosimplyrestrictusingthedatabaseto

oneuserorfunctionatatime,butclearlythat'sanunrealistic

solution.



TheACIDTest

Toaddressissuesofconcurrencyandtransactionintegrity,

databaseengineershavedevelopedwhathascometobe

knownastheACIDtest.Databasesoftwareneedstopassthis

testtocompletelymanageconcurrencyissues.ACIDstandsfor

atomicity,consistency,isolation,anddurability;thesefour

termsdescribethefeaturesandrequirementsforprocessing

transactionsinadatabasesystem.Ifasystemdoesnotmeet

theserequirements,theintegrityofthedatabaseandits

datacannotbeperfectlyguaranteed.

Inthecontextofdatabases,thetermtransactionrelatestoa

singlelogicaloperationcomprisingoneormorestepsthat

resultsindatabeingpostedtothesystem.Examplesmight

includecommittinganewrecordtothedatabase,performinga

scriptthatcalculatessummaryinformation,orinreal-world

terms,completingthemultiplestepsofdebitingonefinancial

accountandcreditinganother.TheACIDtestexiststoensure

suchtransactionsarereliable.



FileMakerProdatabases,unfortunately,donotfullymeetACID

compliance,norisitrealistictodevelopasolutioninFileMaker

thatperfectlydoes.FileMakerProscriptscanbeinterrupted(a

machinecrashoraforce-quitoftheapplication)andassuchit

ispossibletoleaveatransactionhalfcompleted.

We'reincludingthissectionnottopointoutashortcomingof

FileMaker,butrathertoillustratesomeimportantguidelineson

howyoushouldconsiderbuildingsolutionsforcriticalbusiness

systemsorlargeworkgroups.Itispossibletogoalongway

towardACIDcomplianceinaFileMakerProdatabaseifit's

properlyengineered.It'salsoquitepossibletobuildaFileMaker

Prodatabasethatleaveswideopportunityfordataintegrity

problemstocropup(aswithanyotherdatabasetool).

Asconsultants,we'repragmatists.Oftenthecraftsmaninallof

usyearnstobuildtheworld'smostperfectsystem,butin

realitytherearetrade-offsincomplexity,time,andflexibilityto

consider.Weusetheguidelinesthatfollowasjust

thatguidelines.Byidentifyingthecriticalityofcertaindataand

usingsensiblesafeguardstoensureitsintegritytothedegree

possible,weareabletocoverallbutthemostextremecasesof

databasefailures.

AtomicityAtomicityrequiresthattransactionsbe

completedeitherintheirentiretyornotatall.Inother

words,alogicalroutine(say,creditingoneaccountand

debitinganother)cannotbelefthalfdone.InFileMakerPro

terms,dataiseithercommittedornotcommittedtoyour

database,ascriptneedstoreachitslogicalconclusion,and

acalculationfunctionstoresandindexesitsresults

properly.Althoughascriptcanbeinterrupted,itis

importanttoapproachatomicitybywritingscriptsthat

concludewhateverroutinesthey'redesignedfor.

ConsistencyConsistencyensuresthatyourdatabaseisleft

inalegalstateatthebeginningandendofanygiven



transaction.Thismeansthatthetransactionwon'tbreak

anyoftherules,orintegrityconstraints,ofthesystem.This

oftencanencompassbusinesslogic:Anexamplemightbe

thatallfinancialcredittransactionsbepositivenumbers.

IsolationTransactionsinmid-processareneverexposedto

otherprocessesorusers.Inthecredit/debitexample,a

usershouldneverseeacreditappearononeaccount

beforethedebithasbeenposted.Likewise,anaccount

balancereportshouldnotbeallowedtorunwhenacredit

ordebitisinthemidstofbeingadded.

DurabilityAfteratransactionhasbeenperformedand

completed,theinformationresultingfromthatprocess

needstobepersistent.Itshouldbesavedwiththe

database,andifsomeonepullsthatcomputer'splug,the

informationisthenstillpresentinthefile.

ACIDcomplianceisagoalofdevelopmenttoensuredata

integrity.Weencourageyou,especiallywhenwritingscripts,to

focusondeliveringontheseguidelinestoanappropriate

degree,especiallyinamultiuserenvironment.



ScriptLog

Onetechniqueweuseforverifyingprocessesanddebuggingis

ascriptlog.Bybuildingone,youbetterapproachatomicityand

areabletoidentifycaseswhereitfails.

Inlarge,complexsolutionswheretransactionintegrityisvital,

itmaybewarrantedtocreateaprocessthatcausesallscripts

towritelogrecordstoaseparatetable(ofteninaseparatefile

aswell)whentheystartandagainwhentheyaresuccessfully

completed.It'spossibletotrackotherdataaswell:who

initiatedthescript,onwhatlayouttheuserwas,whichinstance



ofawindowwasinuse,timestampdataforstartandend(for

performanceandtroubleshootingpurposes),andpotentiallyany

datathescriptmanipulates.Thisisnottobeconfusedwithan

audittrail,coveredlaterinthechapter.Audittrailsenableyou

torecordalldatatransactionsinadatabase.Ascriptlogisa

meansofconfirmingthatyourfunctionalroutinesarecompleted

properly.

Byaddingascriptlogtoyoursystemandperiodicallychecking

itforincompleteconclusions,youcanidentifycaseswhere

scriptsfailandmanuallyaddresssuchissueswhennecessary.

Bydefinition,ifascriptlogstartentrydoesn'thavea

correspondingcloseentry,itfailedACID'satomicitytestand

possiblytheconsistencytestaswell.



Tip

Onefinalnoteonscriptlogs:Weencourageyouto

createasingleflaginyourdatabasethat,when

turnedoff,disablesallscriptlogginginyoursystem.



CommitVersusCreateandSerialIDs

InFileMaker8,dataiscommitted(saved)afterauserexitsthe

record,eitherbyclickingoutsideafieldorbyperforminga

rangeofotheractionssuchasrunningascript,changing

modes,changinglayouts,orpressinga"record-entry"key.(The

defaultistheEnterkey,butfieldbehaviorscanbechangedto

allowtheReturnorTabkeysaswell.)

Formoredetailsonfieldbehaviors,see"FieldBehavior,"p.120.



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

Chapter 11. Developing for Multiuser Deployment

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

×