You are on page 1of 9
Different Data Types Before we enter data ito a computer system, we usually need to tell he ‘computer what type of data is. This is because he computer stores and processes diferent ypes of data in diferent ways. Numeric Data Numeric data simply means numbers. 814, just fo complicate things for ‘you, numbers come na vaney of iferent types. Integers. {An integer is a whole number - i has no decimal or fractional pars, Integers can be either postive or negative, 2 4 1214 ‘000900 2 5725 Real Numbers ‘ny urbe that ou col place ona marber ine sa el ube. Rel numbers lise whole numbers (cepts) and. numbers wh Clcimaltacional par Realrubers can be pealive or negate, a ‘Some computer softvare used 1 strange names for real data 14504 9485 You might see this data type refered ans: {028 ‘single’, ‘double’ or oat. 3.142 Currency Currency refers to real numbers that are formatted in a soectic way. Usvally cureney is shown with a eurreney symbol and (usualy) two decimal places, = 21245 + £001 Examples Examples Examples 29800 95500 Alphanumeric (Text) Data ‘Alphanumeric (often simply called Yet) data refers to data made up of letters (alohabet) and numbers (numeric) Usually symbols ($%'+@, fc) and spaces ate also alowed Dos “lite mouse’ agci23 ‘enquiies@bbe co.uk Exemples Date and Time Data Date (and time) data is usualy formatted in a specifc way. The format ‘epencs upon the setup of the computer, the sofware in use and the User's preferences 2e07007 Date Examples = = 12 Mar 2008 + 10.08.08 Time Examples + ita + 1500 = 3:00pm + 17.0545 Boolean (Logical) Data Boolean data is sometimes called logical data (or in some sofware, "yesino' data). Boolean data cen ony have wo values: TRUE or FALSE + TRUE + YES + ON Examples + FALSE + NO + OFF abc Text daa soften input fo 2 computer uth speech marks ("around i “MONKEY” These tel the compute that his is {ont data and not some special command. 23/09/78 8:49am Wit inoutng dates particular care has tobe taken the data contains “American siyle dates and the ‘computer's setup to expect Intemational sive dates (or vice- versa) ‘The date 06/09/08 refers fo 6h ‘September 2008 nthe nterational ‘system, bul woul be Sth June 2008 inAmenca! Check your computer's setings. TRUE FALSE "Note that TRUE and FALSE can also be shown as YES/NO, ON/OFF. or ‘even graphically as tek boxes (ioked /unticked) Ele Melcer Uitte) (hn organised set of data is usually referredto as a database, Databases can be found atthe heart of almost every computer system Databases can be a Ite dffeut to understand, so My te ilustrate the + Databases of users concept witha few diagrams. op Dearest uaa + Databases of webpages We wil use some student data as an example * Databases of bog entres * Databases of photos Here are our students + Databases of products Databases are everywhere! @©® 10 O©@ t tf tf fT 'D No. 386 ID Na 412 ID No. 489 ID No. 602 Name: Jess Name: Hamad Name. Sita ame. Hamad Do.B. 3 Mar 1998 Dab. 12Nov 1998 DB. 9 Jan 1994 DoB. Mar 1995 Phone: 7884986 Phone: 7466846 Phone: 6535634 Phone: 6884846 (Class: 8B (lass: 8B ‘Class: 6Y (Class: 6B Tutor Mr Noggin Tutor: Mr Noggin Tutor Mis Take Tutor: Mr Noggin Room 88 Room 86 Room 18, Room 88 ‘You'l see that each stucent has some data associted with them (name, dob etc) We want to store this data is ‘an organised way so that we can easy access t inthe faure We wart to create a student database, ‘So, how should we organise ths data? What is a Record? ‘The set of data associzted with 2 single object or person isknown asa record In the example of our students, the data associatad with each students 3 record Hete fs Jess's record. Each student has ther own record just ike Jess's but wth ferent dat ‘The data in each record is different, but each record has the same structure. (each ane hes a name, 6.0. phone, ete.) We say tht each record contains the same fields. "A database isa colection of records, You can imagine a single record being a card wih one the deta of ‘one person/object writen on ‘A detabese would be @ boxfu ofthese What is a Field, and What is a Field Name? Youll see that each of cur student's records contain the same tems. Each of eur student records conlains These fers ae noun a els seven fis. ach feishas ated name (eg Dee efit) ed 5 Dateorain ach feld i contain torent data in cach ofthe records (eg. Jess's | © Prone Number record the Phone fell contans 755935, btn S's record he Phone | © Close field contains 565634 - same field, different data values) = Tutor 1 oom It can be 2 bit confusing - what's the dfference betwaen the fel the fl fame, andthe data inthe fil?! Imagine that you were marualy filing in a record card for Jess. The card ‘would nave various labels and boxes to wrte in The data in the field D.o.B. | 3 Mar 1995 The field name The field + The fleld isthe box that you would write in + The fleld name isthe label next 9 the box +The data is wnat you would write in tre box What is a Key Field / Primary Key? It is very important that every recerd in a database can be individually identified. We need to be sure that when we access a record, we are accessing the correct one. Take a look at our students - what item of data identifies then from all of the other students? Name? No - we have two Hamads Date of Birth? No - Jess and Hamad share the same birthday * Phone? No - tvo or more students may live at the same address + Class / Tutor / Room? No - each class has many students Because all of these fields might contain the same data for more than one record, we can't use them to identify each record So... we have given each student an ID number. We can guarantee that this number will be unique for every student. The ID number is the ideal field to use to uniquely Identify each individual record. We call this field the Key Field, or Primary Key. Database Viewed as a Table lets qute common to view the contents of a databace as atable instead of [The tabular view ofa database Ss onerecord at atime. Atabular view is eompact and allows youto see alot exactly he view that you see when of records in one ga working wih your dafabase software (eg Microsoft Access). (Our student database woud look tke this, 1D No. | Name D.0B. Phone | Class [Tutor | Room 366 | Jess 3Mar 1995| 7564356 | 58 |MrNoggin | 56 412 |Hamad | 12Nov 1994) 7465846 | 58 |MrNoggin | 56 469 | sita 9 Jan 1994| 9665634 | 6Y | Ms Take 8 502 |Hamad | 3Mar1995| 6554546 | 5B |MrNoggin | 56 Each row of the table comesponds to database record, 1D No. | Name | DoB Phone | Glass | Tutor | Room 356 _| Jess 3Mar 1995| 7564356 | 5B |MrNoggin | 56 412 |Hamad | 12Nov 1994| 7465846 | 5B | MrNoggin | 56 75” | Sta Tan? 5 iS Take 502 [Hamad |f 3Mar 1995| 6554546 | 58 | MrNoggin | 56 One Record ‘The column headings correspond tothe database feld names. IDNo. | Name | 0.0. Phone | Glass | Tutor | Room jess ar irNogain 412 | Hamad || 12Nov 1994] 7485846 | 58 | MrNoggin | 56 459 | sita @Jan 1904] 9565634 | 6Y | Ms Take 18 502 |Hamad || 3Mar 1995] 6554546 | 58 | MrNoggin | 56 Field Names Each eel ofthe table corespands toa feld and contains an tem of data 1D No. | Name D.oB. Phone | Class Tutor | Room 356 | Jess 3 Mar 1995] 7564356 | 5B | MrNoggin | 56 412 | Hamad || 12 Nov 1994||7465846 | 5B |MrNoggin | 56 459 | Sita OTan 1604] 8565634 | GY | Ms Take 18 502 | Hamad 3Mar 1995] 6554546 | 5B |MrNoggin | 56 The D.o.B. Field for Student 412 Types of Database Flat-File Databases [A Mlatlle' database fs one thal only contains a single table of data [ie database work that you have fo] do forthe practical exam alvays ‘Af the dats in the database is stored in this one place The student | uses fatfie databases ‘database example that we oaked atin the previous section was aflavlie database, 356 | Jess 3Mar 1995| 7564356 | 5B |MrNoggin | 56 412 |Hamad | 12Nov 1994] 7488846 | 5B |MrNoggin | 56 459 | Sita gan 1904] a5e56a4 | Gy | Ms Take 18 502 |Hamad | 3Mar 1995] 6554546 | 5B | MrNoggin | 56 Relational Databases A relational database is one that contains two oF more tables of data, | You have to understand the ‘connected by links called relationships concept of elaianal databases, but ‘you mil nt be requred fo use/create them in the practical exam! ‘Why would you want to have more than one database table? ‘Take a look atthe student databace example |#|2|8/ 8 Notice tha the table contains several tems of data that are repeated over and over again: + Class (6B) + Tutor (ar noggin) + Room (58) Infact, every studert in class 55 willhave these lems of data. Repeated datain a database is generally considered a bad thing + twastes space inthe database +I takes time to input, typing the Same data over and ever (and ‘mistakes may be made) + [5 a pain to update (7 class 58 gets @ new tutor, we have to find every Mr Noggin’ and change it tothe new name) So how do we avoid repeated data? Multiple Tables “The solution isto spl the data. The repeating deta is removed from the main table, and placed in table of ts own. Student Table Class Table 356 | Jess 3 Mar 1995] 7564356 5B |MeNogoin| 56 gz MsTake | 18 5B 412 [Hamad | 12Nov 1994] 746546 | 58 459 | Sita Jan 1904) 9565634 | 6Y 502 | Hamad | 3Mar 1995| sss4s46 | 5B Note: we need fo leave the Class feld inthe main table as we stil need fo ‘know which class each student belongs fo, but the data relating fo each ‘lass (Tutor, Room) can be removed ‘So, now the main Student table just contains dats directly related to ‘students, whist the new Class table conlans data directly related to classes Note that both ables are independent, and each one has ts own Ke field | primary key + Student table key field is student ID number + Class table Key field is class code ‘Ok... so we've solved the repeatng-cata problem, but we seem to have created 2 new problem: how do we know the name ofeach student's tutor 4 no longer inthe Student table? Linking Tables - Relationships We need to link the table together so that we can connect a studen to 2 specific tutor and room. ‘The common feld in both tales isthe Class fel We use this field to create a relationship (Ink) between the two tables. Student Table Class Table 356 | Jess 3 Mar 1995 | 7564366 412 | Hamad | 12Nov 1994) 7465846 459 | sita Jan 1994 | 8565634 502 [Hamad | 9Mar 1995| 6554546 The Class field acts as a relationship (link) between the tables Note that to create the relationship, vie are using the key field (primary | Database design is very complex key) from one table to linkitto acter business. fsa career for some ope ‘When a key fled from one table appears in a aliferent fable (e the ‘lass field in te Stunt tbl), we cal this a foreign key. ereecke anar aal Shes a hat relavonstios ae required. Student Table Class Table 356 | Jess 3 Mar 1996 | 7564356]| 5B Noggin | 56 412 [Hamad | 12Nov 1994] 7465646|| 5B ey Take | 18 459 | Sita Jan 1994 | a565634]| 6Y 502 [Hamad | 3 Mar 1995| 6554546]| 5B In the Class table, the Class field In the Student table, the Mieley eld Class field is a Foreign Key

You might also like