Databases with Microsoft Access
Total Page:16
File Type:pdf, Size:1020Kb
DatabasesDatabases withwith MicrosoftMicrosoft AccessAccess UsingUsing AccessAccess toto createcreate DatabasesDatabases JanJan--FebFeb 20032003 WhatWhat isis aa Database?Database? •• AnAn OrganizedOrganized collectioncollection ofof informationinformation aboutabout aa subject.subject. •• Examples:Examples: –– AddressAddress BookBook –– TelephoneTelephone BookBook –– FilingFiling CabinetCabinet fullfull ofof documentsdocuments –– PrePre--existingexisting formsforms (hard(hard copy)copy) –– EmployeeEmployee informationinformation cardscards WhatWhat isis Access?Access? •• AA databasedatabase managementmanagement systemsystem allowingallowing usersusers toto input,input, edit,edit, andand verifyverify data.data. •• ItIt isis aa partpart ofof thethe OfficeOffice 20002000 suitesuite •• IconIcon isis aa purplepurple keykey WhatWhat makesmakes upup aa Database?Database? •• RecordsRecords oror RecordRecord SetSet •• AA setset ofof detailsdetails aboutabout aa specificspecific item.item. •• ExampleExample –– NameName –– AddressAddress –– PhonePhone NumberNumber WhatWhat makesmakes upup aa Record?Record? •• FieldsFields •• ProvideProvide thethe categoriescategories forfor thethe detailsdetails describingdescribing eacheach record.record. •• FieldsFields areare defineddefined byby datadata typestypes •• TheThe specificspecific fieldfield datadata withinwithin aa recordrecord isis thethe fieldfield contentscontents InIn aa NutshellNutshell •• DatabaseDatabase == collectioncollection ofof informationinformation •• DatabaseDatabase isis mademade upup ofof recordsrecords •• RecordsRecords areare mademade upup ofof fieldsfields •• FieldsFields areare defineddefined withwith datadata typestypes thatthat becomebecome fieldfield contents.contents. TheThe DatabaseDatabase WindowWindow •• TableTable •• FormForm •• QueryQuery •• ReportReport •• MacroMacro (not(not coveredcovered inin thisthis class)class) •• ModuleModule (not(not coveredcovered inin thisthis class)class) •• PagePage (if(if timetime andand pertinent)pertinent) TablesTables •• AllAll AccessAccess databasedatabase informationinformation isis storedstored inin tables.tables. •• EachEach rowrow ofof anan AccessAccess TableTable isis aa recordrecord •• EachEach columncolumn ofof anan AccessAccess TableTable isis aa fieldfield •• EachEach columncolumn isis headedheaded byby aa fieldfield namename •• TheThe fieldfield contentscontents isis thethe specificspecific fieldfield datadata withinwithin aa recordrecord FormForm •• AA windowwindow forfor viewingviewing thethe datadata inin oneone oror moremore tables.tables. •• MakesMakes itit easyeasy toto view,view, input,input, andand editedit datadata onon aa singlesingle page.page. •• AnotherAnother wayway toto havehave usersusers inputinput data.data. •• TheThe otherother wayway isis thethe datasheetdatasheet view.view. QueryQuery •• AA wayway toto askask questionsquestions ofof thethe datadata •• AllowsAllows youyou toto seesee oror workwork withwith aa portionportion ofof aa tabletable byby limitinglimiting thethe numbernumber ofof fieldsfields andand byby selectingselecting specificspecific records.records. •• AA wayway toto filterfilter informationinformation ReportReport •• FormattedFormatted informationinformation fromfrom aa tabletable oror queryquery thatthat youyou cancan sendsend toto aa printer.printer. •• YouYou cancan createcreate labelslabels viavia thethe ReportReport Object.Object. PagePage •• AllowsAllows youyou toto createcreate WebWeb--basedbased formsforms thatthat allowallow usersusers toto inputinput andand readread datadata fromfrom youryour database.database. FieldField DataData TypesTypes •• TextText •• MemoMemo •• NumberNumber •• Date/TimeDate/Time •• CurrencyCurrency •• AutoNumberAutoNumber •• Yes/NoYes/No •• OLEOLE ObjectObject •• HyperlinkHyperlink •• LookupLookup WizardWizard TextText •• TextText oror combinationscombinations ofof texttext andand numbers,numbers, suchsuch asas addresses.addresses. AlsoAlso numbersnumbers thatthat dodo notnot requirerequire calculations,calculations, suchsuch asas phonephone numbers,numbers, partpart numbers,numbers, oror postalpostal codescodes •• SizeSize ofof fieldfield == upup toto 255255 characterscharacters MemoMemo •• LengthyLengthy texttext andand numbers,numbers, suchsuch asas notesnotes oror descriptionsdescriptions •• SizeSize == upup toto 64,00064,000 characterscharacters NumberNumber •• NumericNumeric datadata toto bebe usedused forfor mathematicalmathematical calculations,calculations, exceptexcept calculationscalculations involvinginvolving money.money. •• SizeSize == 1,2,4,1,2,4, oror 88 bytesbytes Date/TimeDate/Time •• DatesDates andand TimeTime •• SizeSize == 8bytes8bytes CurrencyCurrency •• CurrencyCurrency values.values. UseUse thethe CurrencyCurrency datadata typetype toto preventprevent roundingrounding offoff duringduring calculations.calculations. AccurateAccurate toto 1515 digitsdigits toto thethe leftleft ofof thethe decimaldecimal pointpoint andand 44 digitsdigits toto thethe right.right. •• SizeSize == 88 bytesbytes AutoNumberAutoNumber •• UniqueUnique sequentialsequential (incrementing(incrementing byby 1)1) oror randomrandom numbersnumbers automaticallyautomatically insertedinserted whenwhen aa recordrecord isis added.added. •• SizeSize == 44 bytesbytes Yes/NoYes/No •• FieldsFields thatthat willwill containcontain onlyonly oneone ofof twotwo values,values, suchsuch asas Yes/No,Yes/No, True/False,True/False, On/Off.On/Off. •• SizeSize == 11 bitbit OLEOLE ObjectObject •• ObjectsObjects (such(such asas MicrosoftMicrosoft WordWord documents,documents, ExcelExcel spreadsheets,spreadsheets, pictures,pictures, sounds,sounds, oror otherother binarybinary data),data), createdcreated inin otherother programsprograms usingusing thethe OLEOLE protocol,protocol, thatthat cancan bebe linkedlinked toto oror embeddedembedded inin anan AccessAccess tabletable •• SizeSize == upup toto 11 gigabytegigabyte (limited(limited byby diskdisk space)space) HyperlinkHyperlink •• FieldField thatthat willwill storestore hyperlinks.hyperlinks. AA hyperlinkhyperlink cancan bebe aa UNCUNC pathpath oror aa URL.URL. •• SizeSize == upup toto 64,00064,000 characters.characters. LookupLookup WizardWizard •• CreatesCreates aa fieldfield thatthat allowsallows youyou toto choosechoose aa valuevalue fromfrom anotheranother tabletable oror fromfrom aa listlist ofof valuesvalues usingusing aa combocombo box.box. ChoosingChoosing thisthis optionoption inin thethe datadata typetype listlist startsstarts aa wizardwizard toto definedefine thisthis forfor you.you. •• SizeSize == typicallytypically 44 bytesbytes PrimaryPrimary KeyKey • The power of a relational database system such as Microsoft Access comes from its ability to quickly find and bring together information stored in separate tables using queries, forms, and reports. In order to do this, each table should include a field or set of fields that uniquely identifies each record stored in the table. This information is called the primary key of the table. Once you designate a primary key for a table, to ensure uniqueness, Microsoft Access will prevent any duplicate or Null values from being entered in the primary key fields. SoSo shouldshould II setset aa PrimaryPrimary Key?Key? •• II wouldwould justjust toto bebe safe.safe. •• ItIt createscreates anan AutoNumberAutoNumber fieldfield automaticallyautomatically •• YouYou mightmight relaterelate tablestables togethertogether inin thethe future.future. InputInput MaskMask •• ThisThis controlscontrols howhow thethe datadata isis enteredentered intointo aa fieldfield inin aa tabletable oror aa form.form. •• CommonCommon InputInput MasksMasks areare SocialSocial SecuritySecurity Number,Number, Date/Time,Date/Time, PhonePhone number,number, ZipZip code,code, Extension,Extension, Password.Password. •• YouYou cancan createcreate youryour ownown InputInput MaskMask.