Databases & The Internet Book 1 - Database Basics

download Databases & The Internet Book 1 - Database Basics

of 20

Transcript of Databases & The Internet Book 1 - Database Basics

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    1/20

    DatabasesandTheInternet

    Book1DatabaseBasics

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    2/20

    S4 Computing Databases & The Internet

    1

    Manual Databases

    Data and Information

    Remember that any fact or figure that is not organised or has no apparent meaning is known as data.

    For example the number 393823 could be

    A phone number

    A map reference

    A bank account number

    An identification number

    A code for a padlock

    Once data has been processed it becomes information. E.g. Phone number: 393823.

    This can be shown as:

    What is a database?

    A database is a collection of data about a single subject that is stored in a file. Data can either be stored

    on paper or on a computer. A database that is stored on paper is known as a manual database.

    Examples of manual databases:

    Telephone directory

    Pupil records stored on paper

    The electoral roll

    A database is made up of the following components:

    File a collection of records about one topic

    Record all the information about an item

    Field a single piece of information about an item

    Raw Data Processing Information

    record

    field

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    3/20

    S4 Computing Databases & The Internet

    2

    What is an information system?

    Just as information is defined as data which has been processed, an information system can be

    described as a database or number of databases which are used be a company or individual to help

    them make decisions. An information system that is stored on paper or card is known as a manual

    information system.

    Examples of manual information systems:

    Newspapers or magazines focussing on a particular topic e.g. stock markets

    Telephone directories of potential customers

    Address books with staff contact details

    Timetables for train routes in Scotland

    Advantages of manual information systems:

    You can carry the information with you

    You dont need any expertise to use the system

    A disadvantage of a manual information system is that it can be slow to find the information.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    4/20

    S4 Computing Databases & The Internet

    3

    Flat File Databases

    What is a flat file database?

    A database which is on a computer system is an electronic database. Simple electronic databases which

    only contain one table in a single file are called flat file databases.

    Examples of electronic databases:

    Online telephone directory e.g.http://www.bt.com

    School administration system Online property search engine e.g.

    http://www.aspc.co.uk

    What is an electronic information system?

    An electronic information system is on a computer and stored on a backing storage device. People

    need to be able to use the computer system to access the information.

    Examples of electronic information systems:

    Internal company directory of email addresses Regional library catalogue and booking system

    Key advantages of electronic information systems:

    It is quicker to search and therefore more efficient to use than a manual system You can store more information in a smaller physical space

    Key disadvantages of electronic information systems:

    You need to know how to use the computer system that contains the information You need to have a computer system

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    5/20

    S4 Computing Databases & The Internet

    4

    Further advantages / disadvantages of electronic information systems

    Computerised databases have fundamentally changed the way in which many organisations work.

    Businesses or individuals now need to make use of a number of electronic databases to be able to:

    compete in any business field perform medical research book a flight or a holiday get an MOT for your car send promotional material to potential customers order your grocery shopping online

    The databases which support these electronic information systems are usually very large.

    e.g. The information system used by the Driver and Vehicle Licensing Agency (DVLA) stores records

    on around 40 million drivers and 30 million vehicles in the UK.

    In the past manual databases worked well when the amount of data to be stored was small. Severe

    problems arose when users needed to cross reference files. Electronic information systems solve these

    problems.

    Comparison: Grocery Shopping

    Manual Online

    You go to a supermarket with a list of items to buy.If the item is not in stock you might decide to go to

    another supermarket or shop later to buy it. You

    are responsible for taking the items off the

    shelves, paying for them and delivering the items

    to your home.

    In this example the amount of data to be stored is

    small. The stock levels in the supermarket could be

    written down on a checklist.

    5/8 6/8 7/8

    Milk 16 12 4

    Cheese 7 5 3

    OJ 4 1 0

    A problem with this system is that managers could

    not easily see which customer bought which item,

    so could not send them money off coupons for

    items they regularly buy.

    You visit the supermarkets website and choosefrom a database of available items. You then

    enter your payment details and finally your

    delivery address.

    In this example the amount of data to be stored

    is very large. This is due to the number of

    customers and orders that are stored in the

    electronic information system.

    A manager can easily cross reference the files to

    find out which customers buy the same item

    regularly, if they pay in cash or by credit card,

    etc. This information is very useful.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    6/20

    S4 Computing Databases & The Internet

    5

    Additional advantages of using electronic information systems are:

    you can locate items of data quickly, cross referencing files you can make amendments easily, all occurrences can be changed at once data retrieved can be sorted into order quickly data analysis can be carried out automatically on search results computer reports containing calculations and summaries are produced quickly

    Creating an electronic database

    It is much easier to create a manual database as you do not have to worry about choosing field types. A

    field type is the classification of a single piece of information in a record. As each character of text in acomputer system generally takes up 1 byte of storage space, field types are used to ensure that memory

    is not wasted when storing other types of information such as numbers or images.

    The key field types you should consider when creating your electronic database are:

    Text Numeric Date Time

    Graphic Calculated

    Below is an example of a manual database record ... and the corresponding design

    There are also more advanced field types which can be used:

    Object - Suitable for all types of media including sound files, video and graphics Link Suitable for storing hyperlinks or URLs (web site addresses) up to 64000 characters long Boolean Holds the value true or false only

    Field Name Field Type

    Name Text

    Age Numeric

    Date Joined Date

    Photo Graphic

    Monthly Fee Numeric

    Total Paid Calculated

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    7/20

    S4 Computing Databases & The Internet

    6

    Databases and the Law

    All data stored in an electronic database is automatically protected by the following laws:

    Data Protection Act Computer Misuse Act Copyright, Design and Patents Act

    Data Protection Act

    If you are storing details about a person (or they are storing your details) then you need to be aware of

    the Data Protection Act.

    Data user the person or company storing the data e.g. the school office

    Data subject the person who the data is about e.g. a pupil who has just joined the school

    The data user must ensure they:

    A data subject has the right to:

    Computer Misuse Act

    This act covers the use of computers to commit a crime, unauthorised access to computer material and

    spreading viruses over the computer.

    The following acts are an offence under the Computer Misuse Act:

    Gaining unauthorised access to a computer system Making unauthorised changes to a computer system

    are registered to hold data collect and use data legally only hold data for the purpose

    required

    keep data up to date

    dont keep data longer than necessary give data subjects access to the

    information stored about them

    keep data secure

    see the data stored about them (if they pay a fee) have incorrect data changed

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    8/20

    S4 Computing Databases & The Internet

    7

    The act states that unauthorised changes to computer material includes:

    Interfering with a computer system so it does not run properly e.g. changing hardware settings Making changes to the system to prevent others accessing it e.g. changing a password Making changes to the software stored on a computer system e.g. removing a program

    Examples of computer misuse include:

    Hacking This involves gaining access to computers which you should not have access to andthen changing, deleting or just looking at their files

    Viruses creating and sending viruses Electronic Fraud This could involve using the computer to transfer money from a bank account

    into your own account

    With regard to electronic databases, hacking into a computer system to see or alter information or

    transmitting a virus to destroy data would be an offence under the Computer Misuse Act.

    Copyright, Designs and Patents Act

    This act was introduced to try and protect companies and individuals whose work was being copied.

    This work includes text, graphics, video and sound files.

    The also covers computer software, it means that it is i llegal to copy software until 50 years after the

    software was published.

    It makes is illegal to attempt to:

    Copy or steal software and software manuals Run software on your computer that does not have a license Use the Internet to upload or download software which you do not own

    If found guilty of an offence under the Copyright, Designs and Patents Act:

    that person can be sent to prison the owner of the software/material can sue for compensation

    It is not just games and software packages that are protected by this law. If a database is stolen, copied

    or uploaded to the Internet without permission from the copyright owner (the person who created the

    database) that would be an offence under the Copyright, Design and Patents Act.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    9/20

    S4 Computing Databases & The Internet

    8

    Public / Private Information Systems

    Private Information Systems

    These are information systems that are not for public use.

    For example:

    Police National Database UK Government Tax Office DVLA (Driver and Vehicle Licensing Centre) Businesses (Tesco, Marks and Spencer, Topshop, Starbucks)

    Public Information Systems

    These are systems created for the public to help them find useful information.

    For example:

    Library Catalogue Newspapers Telephone Directories Train, Bus and Airline Timetables Media (teletext, news websites)

    The key difference between private and public systems is everyone can access public systems whereas

    access to private systems is limited. This is because if some of the information from a private system was

    available to everyone it might be a threat to local or national security, or to a business profits.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    10/20

    S4Computing Databases&TheInternet

    11

    FormsInbusinessnearlyalldataentry,editinganddeletingoperationsarecarriedoutviaforms.

    Aformallowsyoutoviewandeditdatafromyourdatabaseinaslightlydifferentformat. Formsare

    morepleasingtolookatandeasiertouse.

    Theeasieritistoenterdataintoadatabase,thelesslikelyitismistakeswillbemade.

    Aformnormallydisplaysonerecordonscreenatatime.

    Levelsofaccesscanbeassignedtoaforme.g.thewholeformcanbemadereadonlyoronlycertain

    textboxescanbemadereadonly. Thiswillstopdatabeingchangedbypeoplewhoarenotauthorised

    toeditthedatabase.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    11/20

    S4Computing Databases&TheInternet

    12

    GoodFormDesignTipsTomakeyourdatabaseformsasuserfriendlyaspossibleyoushouldapplyasmanyofthetipslisted

    belowtoyourformdesign.

    F KeepfontsandcoloursconsistentO PlacethefieldsinalogicalorderR OnlyincluderelevantfieldsthatyouwanttheusertocompleteM MeaningfulinstructionsontheformhelpsyourusersS Usewhitespacetomakeiteasytounderstandandnavigate

    Goodformdesignwillreducethenumber

    ofproblemsdatabaseusershaveadjusting

    fromamanualdatabasesystemtoan

    electronicdatabasesystem.

    Itenhancestheuserexperience.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    12/20

    S4Computing Databases&TheInternet

    11

    SearchingSimplesearchvsComplexsearchSearchingorQueryingthedatabaseisusedtofindinformation. Therearetwotypesofsearching:

    SimpleSearch ComplexSearchThereisonecriteria/searchterme.g.Carterinthesurnamefield Thereistwoormorecriteria/searchtermse.g.Carterinthesurnamefieldand26intheagefield

    OperatorsOperatorsthatcanbeusedforsearching:Operator Meaning Example Result> Greaterthan Fieldage>14 Findalltherecordsthathaveanagemore

    than14

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    13/20

    S4Computing Databases&TheInternet

    12

    QueriesWhen

    you

    need

    to

    find

    aparticular

    piece

    of

    data

    in

    your

    database

    you

    have

    to

    create

    aQuery.

    You

    must

    enterkeywordsintothequerywindow,andthenthedatabasesoftwarewillSEARCHyourdatabaseto

    findthedataaskedfor.

    e.g.WhatisthephonenumberfortheSmashHittersVolleyballteam?

    SearchonTeamNameforthedata=SmashHitters

    Theresultofthesearchisthendisplayedinananswertable.

    Thisis

    an

    example

    of

    asimple

    query,

    since

    we

    are

    using

    only

    one

    field

    in

    the

    search.

    Acomplexquerywouldrequireinputundermorethanonefieldheading,andcouldalsousemorethan

    onetableinadatabase.

    e.g. Howmanyredfordcarsarethereinstock?

    Search on field Colour =Red AND

    Search on field Make =Ford

    e.g. Howmanygirlsinsixthyear?

    Search on field Gender =F AND

    Search on field Year =6

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    14/20

    S4Computing Databases&TheInternet

    13

    WildcardsAwildcardisasymbolwhichisusedtostandforoneormorecharacterinthesearchcondition. Thisis

    usefulifthewordsyouarelookingformightbeinthemiddleofalist,oryouarenotsureoftheexact

    spellingofasurname. Youdonotusethe=signinthesearchcriteriaunlessyouknowexactlywhatyou

    aresearchingfor.

    Character Description Example Result* matchesanynumberof

    characters

    likewh*

    like*beach*

    what,where,when,white, etc

    sandybeach,beachnearby, etc

    ? matches any single

    character

    b?ll bill,ball,bull,bell

    [] matches any single

    characterwithinthe[]

    b[ae]ll ball,bell (notbillorbull)

    ! matches any single

    characternotinthe[]

    b[!ae]ll bill,bull

    matches any one of a

    rangeofcharacters

    b[ac]d bad,bbd,bcd

    ~ matches any single

    numericcharacter

    1#3 103,113,123,133, etc

    Anexampleofacomplexsearchusingwildcardswouldbe:HowmanyredFordcarswhichhavetheregistrationletterLarethere?

    Search on field Colour =Red AND

    Search on field Make =Ford AND

    Search on field Registration like L*

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    15/20

    S4Computing Databases&TheInternet

    14

    SortingSimplesortvComplexsortTherearetwotypesofsortinadatabase:

    SimpleSortdatainthedatabaseissortedononefield.

    (intheexampleabovesortedbyage)Complex

    Sort

    the

    data

    in

    the

    database

    is

    sorted

    ontwoormorefields.

    (intheexampleabovesortedbysurname,thenage)

    Onceyouhavesuccessfullyqueriedthedatabaseitisoftenusefultoarrangetheinformationinsomekindoforder. Asortingoperationisperformedtoachievethis.

    AscendingOrderAscendingorderiswhentheinformationissortedfromsmallesttobiggest,inthecaseofnumbers,orfromletterAtoletterZ.

    DescendingOrderDescendingorderiswhentheinformationissortedfrombiggesttosmallest,inthe

    caseofnumbers,orfromletterZtoletterA.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    16/20

    S4Computing Databases&TheInternet

    15

    Sorting:ExamplesForename Surname YearBilly McPherson 1David Farquhar 1Billy Irvine 1Ian Benholm 1Ian Shepherd 1

    1.Sorttheabovelistoffirstyearpupilsalphabetically.

    Sort on field Surname ascending

    Forename Surname Exam %Billy Irvine 95Andrew McKenzie 87George Law 86Ian Benholm 84David Farquhar 77Scott Simpson 76

    2.Sorttheabovelistofexamgradestoshowhighestmarksfirst.

    Sort on field Exam % descending

    Forename Surname Exam %Ian Shepherd 76Scott Simpson 76Jennifer Mackie 73Gary Kemp 67Suzanne McGregor 67Keith Gregory 64

    3.Sorttheabovelistofexamgradestoshowhighestmarksfirst.Ifpupilshavethesamemarkthentheyshouldbeinalphabeticalorder.

    Sort on field Exam % descending AND

    Sort on field Surname ascending

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    17/20

    S4Computing Databases&TheInternet

    16

    ReportsTypesofreportReportsarethenusedtodisplaytablesorresultsfromqueriesinamoreattractivemanner.Thetwomainreporttypesare:CARDFORMAT

    Singlerecordpersection/page Lookslikeadatabaseform

    LISTFORMAT

    Multiplerecordspersection/page Lookslikeadatabasetable

    Areportislikeaqueryinthatitcansummarisethedatainadatabase.Thekeydifferenceisthatreportsareusedtoproduceprintedoutput,notjustfindtheanswer.

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    18/20

    S4Computing Databases&TheInternet

    17

    CreatingsimplereportsTheMicrosoftAccessreportgeneratorallowscontroloverlayout,shadings,fonts,styles,sizesandpagebreaks. Youcanalso:

    Organiseandpresentyourdataingroups Calculaterunningtotals,grouptotalsandpercentagesoftotals Includesubreportsandgraphs Designanattractivepresentationformatwithpictures,linesandspecialfonts.

    Areportismadeupofvarioussections,witheachonehavingaspecificpurpose.

    Eachreportsectioncanberesizedasnecessary. Youshouldalwaystakecaretoensurethattitleanddataboxesareinline.

    Reportheader/footer:containsinformationsuchasthetitle,authorand

    Detailsection: containsthemainbodyofthereport

    Pageheader/footer:containsinformationsuchascolumnheadingsand

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    19/20

    S4Computing Databases&TheInternet

    18

    KeysIfdatabaseshavenotbeensetupcorrectlyproblemscanoccurlaterdowntheline.Takethisclassdatabaseforexample:

    Forename Surname YearBilly McPherson 1David Farquhar 1Billy Irvine 1Ian Benholm 1Ian Shepherd 1

    Ifanewpupil,alsocalledBillyIrvine,joinstheclassthiscouldcauseproblemswithexistingqueriesandreports.

    PrimaryKeyWhendesigningyourdatabaseitiseasiertofindrecordsifyouuseaprimarykey.Theseareuniquevaluesthatidentifyeachindividualrecord.

    Pupil ID Forename Surname Year001 Billy McPherson 1021 David Farquhar 1291 Billy Irvine 1054 Ian Benholm 1199 Ian Shepherd 1

    Youdonotalwayshavetocreateanewdatabasefield,youcanuseexistingfieldsasprimarykeystoo.

    Numeric IDs

    are the best choice of keys

  • 8/8/2019 Databases & The Internet Book 1 - Database Basics

    20/20

    S4Computing Databases&TheInternet

    19

    ValidationValidationchecksareusedtotryandensurethatonlysuitabledataisenteredintothedatabase.Therearethreetypesofvalidationcheck:

    PresenceCheck RangeCheck RestrictedChoice

    PresenceCheckPresencecheckvalidationsetswhetherornotafieldcanbeleftblankornot.Forexample:PupilsregisteredwiththeSQAtosittheirexamsallmusthaveaScottishCandidateNumber.IfapresencecheckissetonthisfieldanyattempttoleavetheSCNentryblankwillcauseanerrormessagetoappear.

    RestrictedChoiceRestrictedchoicevalidationlimitsthedatathatcanbeenteredintoafieldtoalistofvalues.Whendesigningthisyoumustlisttheacceptablevalues.(e.g.Computing,English,Maths)Forexample:PupilschoosingsubjectsforcolumnEwillonlyhaveacertainlistofsubjectoptions.Ifauserattemptstoenteranyothersubjectnameanerrormessagewillusuallyappear(althoughadvanceddatabaseuserscanchangethissetting).

    RangeCheckRangecheckvalidationensuresthatthenumericdataenterediswithinacertainrangeofvalues.Whendesigningthisyoumuststatetheacceptablerangeofvalues.(e.g.>=12and