Introducing a Database © EIT, Author Gay Robertson, 2017
A Database is a secure tool for storing and organising facts
For example – some common databases are … … a set of customer records … when stored on a computer easy to access and edit
For example – some common databases are … This database is also produced on paper – your phone book … lists of telephone numbers … when stored on a computer easy to find and edit
For example – some common databases are … This database could also be produced as a card file at your local library … books in a library when stored on a computer easy to find by name or author
Why ….. It’s faster than a card file … … it’s more powerful than a reference book … … it’s more efficient than a filing cabinet
Why ….. Once your facts are in the database you can … locate facts instantly … update facts instantly … add new facts instantly … sort facts instantly … query the facts instantly Find a customer Change PhoneNo Add Cell Phone Sort Customers into alpha order Find all Customers who live in Auckland
How does a database store the facts?
A database file is like a filing cabinet Inside the cabinet are folders
These folders are like database tables which are inside the file Tables are where data is stored Tables are the core of the database Table design is very important
A table is made up of fields Each field contains an individual data item such as Name, Address, etc FirstName LastName Address 1 Suburb City Phone
A collection of related fields is stored as a record FirstName: Jo LastName: Bloggs Address 1 5 Short St Suburb Tamatea City: Napier Phone: 123 4567 DOB: 7/1/1973 Gender: M Record 1 A collection of related fields is stored as a record Each record stores the individual facts about a person, a product or a thing FirstName: Fred LastName: Green Address 1 9 Close Rd Suburb Mayfair City: Hastings Phone: 789 6789 DOB: 22/11/1989 Gender: M Record 2
Got that? Files are made up of tables. Tables are made up of fields. Fields are individual facts. Records are made up of groups of related fields
Let’s take a look at the different types of databases that we could use
Flatfile database A flatfile database has only one table containing all the fields and records required The database has no relationships A database of CD’s would need to include the following fields Cd name Cd date Music type (genre) Tracks Artist/band name Band members Recording label
Each time you bought a new CD all the fields would need to be filled in If you bought a Beatles CD you would have to key the name of the new CD, and then fill all the fields eg the names of all the Beatles, the band name, the recording label, the music type, etc If you bought another Beatles CD, most of the data would be identical, yet you would have to key ALL the data in again
Relational database A relational database has multiple data tables which are related in some way A database of CD’s would need to include the following fields Cd name Cd date Music type (genre) Tracks Artist/band name (unique data – no bands or artists have the same name) Band members Recording label These fields could be divided into two tables CD table (name, date, type, tracks, band name) Artist table (band name, members, recording label)
Each time you bought a new CD the fields in the CD table would need to be filled in (name, date, type, tracks, band name) As soon as you entered the band name, the data from the Artist table (band name, members, recording label) would become available to you because you would have linked the artist/cd tables through the band name field. This link is known as “defining a relationship”.
Okay – a flatfile database is limited and I would have to key data over and over – a relational database means my keying would be minimised!!
Now we need to look at how to protect our data and make sure that it is secure and that it is not garbage!
data is the lifeblood of business What is Data Integrity? Data integrity is the CORRECTNESS of data data is the lifeblood of business if garbage goes in then garbage comes out!
Ensuring Data Integrity C A R Consistent Accurate Reliable Did you key the data consistently eg Rd, St, upper case where necessary? Did you key the data accurately and then proofread compared to your source data? Did you get the data from a reliable source and does your business actually need to hold this data?
who is allowed access to the data (eg confidential data) what safeguards do you have in place to ensure no unauthorised employee has access to the data
How to check the integrity of your data - Compare your data to the original source after keying, check that data has been keyed correctly data has been keyed consistently data has been keyed using UPPER CASE where required
Audit your formulae – after keying formula (calculation), check that formula has been keyed correctly by manually working out what the answer should be on one record or key figures into appropriate fields and see if the answer is correct
Got that? Data has to be correct. Data has to be accurate. Data has to be reliable. Data has to be necessary. Data has to be kept secure.
Database summary What is a database? A database is a secure tool for storing and organising facts
Database summary Why use a database? A database is fast, powerful and efficient A database can locate and update facts easily A database can query specific facts easily A database can group and total facts easily
Database summary How does a database store the data? A database stores facts as fields A database stores a collection of fields as a record A database stores a collection of records as a file A database must contain correct data which is secure and has integrity