180 likes | 351 Views
Databases. A technical example of a two table relational database. A quick review :. The simplest databases are the electronic equivalent to a shoebox the shoebox itself is a TABLE each card is a RECORD on each card : specific data item containers are FIELDS (filled in with data).
E N D
Databases A technical example of a two table relational database AC 2002 - 2003
A quick review : • The simplest databases are the electronic equivalent to a shoebox • the shoebox itself is a TABLE • each card is a RECORD • on each card : specific data item containers are FIELDS (filled in with data) AC 2002 - 2003
Let’s construct an example : • A database of Water Treatment Stations • plants outside cities where used domestic waters are cleaned up • What is the set of Water Treatment Stations that we shall consider ? • It will concern France. • What information do we want to gather on each station ? AC 2002 - 2003
What information do we want to gather on each station ? • The name • The location (which city it serves) • Its capacity • Its production • The technology used • The operator • The number of stations run by the operator • Financial figures about the operator • The type of franchise AC 2002 - 2003
Money • Time used to be money • Now : information is money AC 2002 - 2003
An example : • Gather information on 200 domestic waste treatment plants in France • It takes 15 days of a free trainee on the phone • Then sell the study to many clients • cities that intend to build a plant • operators • suppliers, etc. • eg : 1000 €/ study x 50 clients = 50 000 € AC 2002 - 2003
Another example • Innovative buildings • select 500 innovative buildings in France • gather information on the architects, the techniques, the materials, the builder, the suppliers, etc. • there are thousands of potential clients (all architects, all suppliers, etc.) • we can sell the study 1000 € to say 1000 clients • NOTE : for each of them, to reproduce the work would cost more than 1000 €… An architect is in the business of drawing bldgs, not creating and selling information • 1000 x 1000 € = ? AC 2002 - 2003
Back to technicalities : • Access is THE king information mgt software of the MS Office Suite • It offers, like any other DB software, several VIEWS for the data : • the simplest : the TABLE presentation ; we see all the information at a glance • the most intuitive : the FORM presentation ; each record appears as ONE CARD AC 2002 - 2003
Where IS the information ? • In the TABLE • DON’T delete tables (unless you’re sure of what you’re doing) • Not in the FORM displays • We may delete a form display without much consequences AC 2002 - 2003
One problem : • Access, like any DB, is designed to manage structured information • It puts it into a table (with records, fields, etc.) • It runs into the problem of repetitive information AC 2002 - 2003
Repetitive information : • In our example every time we enter Lyonnaise in the « operator » field, we then have to enter 2500 in the field « number of stations run by the operator » • Time consuming useless repetition • Potential source of data entering mistakes AC 2002 - 2003
Solution : • Create a separate table for « operators » • Enter information specific to operators into this second database • and LINK the operators table to the stations table. • Our database will now be a multiple table database, also called a relational database AC 2002 - 2003
A frequent mistake : • A frequent mistake is to create the second table into a new database • No, no • We must create the new table within the SAME database, • just like we created new sheets within the same excel document (if we wanted to link them…) AC 2002 - 2003
The technique : • We split the one table database into TWO tables • Why ? Because there was repeated information, and we want to avoid that • (There exists a tool that analyses how to split the information, we did not use it) • We are still into ONE database • There remains to link the two tables AC 2002 - 2003
Let’s step back, what do we do ? • We split our initial UNIQUE table into several tables of information • In our example the way to do it was natural and evident : have a main table for Stations and a « subsidiary » table for Operators • In more complex situations there is no unique choice ; it is a matter of database architecture (we have the choice) AC 2002 - 2003
Database architecture • With the same end use, some databases are beautiful, some databases are ugly • It all depends upon the art of the architect • The main database architecture tool is called UML (Uniformed Modelling Language) AC 2002 - 2003
Creating the link • Determine which field in the subsidiary table will be the « handle » of the link with the main table • Make it the primary key of the subsidiary table • Go to the Relations view and « pick and slide »... AC 2002 - 2003
Difficulties FAQ • Cannot create a « 1 to many » link : another person in the room uses the same name, with the same login • Cannot « save as » : normal ACCESS is more complex than Word • Why ? • Because we ACCESS we work on the heart of information not just on displaying it AC 2002 - 2003