Presentation is loading. Please wait.

Presentation is loading. Please wait.

Access Primer Africamuseum 5 June 2013. MS Access  Relational Database Management System Data/information resides in series of related tables Principle.

Similar presentations


Presentation on theme: "Access Primer Africamuseum 5 June 2013. MS Access  Relational Database Management System Data/information resides in series of related tables Principle."— Presentation transcript:

1 Access Primer Africamuseum 5 June 2013

2 MS Access  Relational Database Management System Data/information resides in series of related tables Principle of normalisation  Often ‘client-server’ End-user interface independent from ‘engine’

3

4

5 Access elements  Tables: to store data  Queries: to ask questions from database  Forms: to create a user interface  Macros: to automate repetitive tasks  Modules: create non-standard functionality, using Visual Basic

6

7 Tables  Must be defined before they can be used  Vaguely resemble Excel sheets but: Unit of information is a ‘record’ (line) Saved automatically as soon as one moves to another record Consists of ‘fields’ Type must be chosen All fields of a record remain together No restriction on the number of lines Excel: 64,000 lines Order of records is not fixed!

8

9 Types of fields  Text (length; max = 255)  Memo  Integer (normal or long) Autonumber  Real (single or double)  Date  Boolean (yes/no)

10 Indices  Facilitate sorting and selective extraction of records  Special index: primary key unique identifier for a record often ‘autonumber’  Other indices: Unique or not Slow data entry down

11

12 Hands-on  Create table to store names and addresses of students  Experiment with field types  ‘Populate’ table – create records and provide input  Play with facilities to display table Filter, sort

13 Import text (or other) files  Download data from for example data.gbif.org Don’t select too many data!  Check data through text editor  Then we’ll import the data in our database

14

15

16

17

18

19 Hands-on  Download data from for example data.gbif.org Don’t select too many data!  Check data through text editor  Play with filter, sort…

20

21 Normalisation  All data should be in the database once and only once Repeated data go to separate table Relationships between the tables are part of the ‘model’ of the database Link between tables defined on pair of fields, one in each table, that are of same type Records of the two tables are ‘related’ if value in the link fields is the same  Later more!!

22 Non-normalised Table Species# legs# eyesplaceCountrydate Asterias rubens50OostendeBelgium12/3/2004 Asterias rubens50ZeebruggeBelgium13/3/2005 Asterias rubens50ZeebruggeBelgium14/3/2005 Cancer pagurus102De PanneBelgium12/3/2004 Cancer pagurus102OostendeBelgium12/3/2004 Cancer pagurus102ZeebruggeBelgium14/3/2004 Asterias rubens50WimereuxFrance13/3/2005 Asterias rubens50WimereuxFrance14/3/2005 Cancer pagurus102WimereuxFrance12/3/2004

23 Normalisation  Table with morphological characters fields: species, number of legs, number of eyes  Table with distribution records fields: species, place, date  The field ‘Species’ is common to the two tables, and makes it possible to link records between two tables

24 Creating relations  ‘one to many’ relations  Defined on fields of the same type In case of text fields: same length  On the many side: primary key  Helps in maintaining the integrity of the data Enforce presence of a ‘related record’ in the ‘related table’ Avoid spelling variations (Oostende, Ostend, Ostende…)

25

26

27

28 Relations  Best on fields that do not carry any real-world information Autonumber  In the example: add field autonumber in the species table, and use this as a code in the distributions table; make autonumber field the primary key  Also best to add Autonumber as primary key in distributions table

29

30 And more Relations…  Also the locality of the species distribution record should be in a separate table With fields for position, country…

31

32 Hands-on  Refine the data model by creating an extra table for the countries Create extra table with id and countryname Make id the primary key in countries table Change places table, change country to country_id, and update field type Create relationship between places and countries

33 Queries  Select and sort records of a table  Pull together information from related tables  Simple statistics  In principle: SQL But access interface hides SQL from the user  For now: query grid Define which tables will be used, fields that have to be shown, criteria for selection and sorting…

34

35

36 SQL statement SELECT species.speciesname, distrecords.observationdate, places.placename, places.country FROM species INNER JOIN (places INNER JOIN distrecords ON places.id = distrecords.place_id) ON species.id = distrecords.species_id WHERE (((places.country)="Belgium")) ORDER by speciesname, observationdate;

37

38 Statistics query  Count the number of records in the database given criteria in a ‘Group By’ clause

39

40

41 Cross-tab query  Not standard SQL, specific for Access  Create table, with one column header and one or more row headers, and a value for the cells

42

43

44 Hands-on  How many different species do you have in your download from GBIF?  How many with latitude & longitude?  Check the ‘country’ field Why do we need normalisation & standard vocabularies?

45 Access Wizard

46 Forms  Create an interface for the users  Hide codes/autonumbers (combobox)  Elements of the form are linked to fields in the tables Can show single records at a time, or ‘repeated forms’ Entries/changes to the form are written automatically to the table

47

48

49

50 ComboBox  Limit possible entries into a field  Hide codes/autonumbers from users  Two different representations of the same information are combined Code, to be entered into the table Full text equivalent, for the benefit of the user

51

52

53

54 Subforms  To display the content of a many-to-many relationship We don’t know how many related records there will be, so impossible to solve with static, predefined structure A form can be repeated, showing multiple lines Number of lines is not limited  First create the subform

55

56

57 Subforms  And then the main form

58

59

60 And now…  How to decide on the structure of a database? Which information do we want to store? Which tables do we need? Relationships between them? Which indices (primary and others) do we need?  Start from an analysis of user needs  In principle also, decide on a platform

61 Task  Create ‘model’ for biodiversity/biogeography database Which standard vocabularies to use? What are important elements of information? Sources Biology  Classification, synonymy Geography


Download ppt "Access Primer Africamuseum 5 June 2013. MS Access  Relational Database Management System Data/information resides in series of related tables Principle."

Similar presentations


Ads by Google