41
Chapter7:DatabasesandDataSources
Chapter7:DatabasesandDataSources
VersionsofOpenOffice.orgBasepriorto2.xrequiredaconnectiontoanexternaldata
source.While2.xretainsthisfunctionality,italsointroducestheabilitytocreatean
HSQLDBdatabaseasaninternaldatasource.Nowallthedatatables,forms,queriesand
reportsforadatabasecanresideinone.ODBfile.
ThischapterintroducesbuiltinHSQLDBdatabasesandtouchesonsomeofthefunctionality
stillretainedfromearlierversionsofBase.Theexamplesfoundinthischapteraresomeof
thestepsusedtocreatetheCalendarexampledatabase.
Thelargeamountofpreparatoryworkdonewhenoneisactuallydesigningadatabaseis
beyondthescopeofthischapter.Briefly,thepreparatoryworkforcreatingtheCalendar
databaseinvolvedsketchingoutwhattheuserwantedtoseeastheendresultandworking
fromtheretodesigntablesthatwouldfollowgooddatabasedesigntheoryor,failingthat,at
leastbeeasytoimplementandmaintain.
Creatingadatabasefile
Afterthepreparatorywork,afileorcontainermustbecreatedtoholdallthepartsofthe
database.
IfOpenOffice.orgisalreadyopen,youcanchoose
File>New>Database.Youcan
alsoopenOpenOffice.orgBaseitselfselectingthe
programiconfromthemenuorby
runningsbasefromthecommandline.
TheDatabaseWizardopenstoStep1,Selectdatabase.
1. MakesuretheoptionissettoCreateNewDatabaseandclickNext.
2. InStep2,Saveandproceed,youwillwanttheoptionregardingregisteringthe
database(DoyouwantthewizardtoregisterthedatabaseisOpenOffice.org?)set
toYes,registerthedatabaseforme.
Whenyouregisteradatabase,OpenOffice.orgnowknowswherethedatais
locatedandhowitisorganized.Inspreadsheetsandtextdocuments,youcanuse
View>DataSourcetoconnecttothedata.
3. UnderAfterthedatabasefilehasbeensaved,whatdoyouwanttodo?Makesure
Openthedatabaseforeditingischecked.
TheCreatetablesusingthetablewizardcheckboxopenstheTableWizard.
TheTableWizardoffersasetofsampletablesfromwhichfields,with
correspondingtypesandformats,canbechosentocreateanewtable.Fieldscan
bechosenfrommultipletablestocreatetheparticulartable.
4. ClickFinish.
5. IntheSaveAswindowthatopens,namethedatabaseandselectalocationinwhich
tostoreit.LeavetheSaveastypesettoOpenDocumentDatabase.
OpenOffice.orgUserGuidefor2.x
364