0% found this document useful (0 votes)
153 views

IB Textbook - Option A - Databases Part 1

databases part 1

Uploaded by

Sofia Marino
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
153 views

IB Textbook - Option A - Databases Part 1

databases part 1

Uploaded by

Sofia Marino
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
INTERNATIONAL BACCALAUREATE COMPUTER SCIENCE HL & SL _ ie ie OPTION A: DATABASES PART | BASIG GCONGEPRIS H S SHAKIBI PHD International Baccalaureate Computer Science HL & SL Option A: Databases Part I: Basic Concepts Important note to the reader: The specication polts for Option A Databases as they appear inthe 8 Specification document are nota out ia logical order. itis very important forthe student to lean and understand the base concept of database before far example understanding the relationship or eference between databases and Information Management systems. Similac the notion of database transotios, which appeers under the‘AL Base Concepts iin fact, ‘te an advanced topic which can only be stdied once Information Management systems have been eaent Therefore in Part we nly look at those specification points taken fom across sections At and A2 which are considered as tue basicconcepts. ‘The spect used hore I 1 of defining concepts NOT in numerical order simply to preserve th in n dealt with together simply becouse belong together ‘The remind ofthe speciation points ae deat within Part Contents A Base conces, 4 ‘9.1.1 OUTLINE THE DIFFERENCES BETWEEN DATA AND INFORMATION. a ‘A.3 Dscuss the ne TOF d8aDASEScnnnnnnneann ii 5 ‘A The relational data model Poletti) ‘4.2.9 Define the following database terms: table, record, fold, primary key, secondary key, foreign key, candidate key, composite primary ey, Join. 7 ne) ‘A210 identify thedltferent types of relationships within stabs one-to-one, one-to-many many tO-MANY wonomnnnnnnnnnn |A2A1 Outline the isues caused by redundant data panda) 15 ‘4213 Describe tho differences between 1s ormal Form IN 2nd Normal Form (2 and 3rd Normal a z a ene ‘A218 Dexeribe the characteristics of 2 normalized database. 1 |A2..7 Construct relational database to NF sing object such tables, queries forms reports and macros, see ao 19 A 26 utline the natureof heat dictionsry caren) FORMS... 7 Eee . D5 QUERIES mene —_ ne) 1A2.19 Deserve the atference between smpleand complex query. 2s 425,20 Outline the different methods that can be used to const-uct QUERY. ov ennnsnennnnnnn 2S ‘QUERY ay EXAMPLE, 25 A246 Constructan entity relationship élagram G20 foraglven scenario. 29 Al Basic concepts ‘A.L.A OUTLINE THE DIFFERENCES BETWEEN DATA AND INFORMATION To see the diference between deta and information consider the fellowing example: ‘as they stand these numbers are completely meaningless! They represent some data ~ as yet we do not know about what. In order to get any kind of meaning out ofa collection of data we need to process It. This processing s usually dane using some kind of application software eg a spreadsheet or a database tool. Butt is perfectly possible to process data without using software tools, with pen and paper \f we now plot this data on two axes, ican look ike tis: itis now procested data information, but we are stil ot sure what it all means. Now if we aed labels tothe x-and y-axes could look ike this eee a Sowithout any context or procesing, data is mesningless. hod wn szeneseenuraementcanenoveaninotne tts ‘A.1.3 Discuss the need for databases ‘Access data, search data, share data transfer data, migrate data \weerout databases much ofthe Westarn world economies would probably callpse overnight. The buge amount of data processed by comparies,orgeisatons, GOs 3: walle schools, hori, banks, businesses, shops and athe agencies can only be dane using powerful databases and Information Marogement Sytem But just What isa rabase? Watch this short clip and answer the questions ~ you may have to wath it twice, httosi//www.voutube.com/watch?v=t8ieX1f8kcA Use the numbers to stop the clip at the required points to fil in your answers. (0:05 Why don't we ever see databases? (0:15 Where do FB, Tumbler and Twitter put their data? 0:27 Where are the contacts in your mobile phone stored? 0:36 Isa database just a random collection of stuff all squeezed in together? 0:42 Databases have a fits into this. 0:50 Very simple databases are called .........-flles. of and 0:57 They store .. 4:13 What are four things about his friends that Bob stores in his address book? pene 1:24 Now write 5 things that Bob wishes to store about Megan: 1:31 The details that Bob writes down are book database. «in his database file, 1:54 Each row is called a Source: pina 2 et camnn raccoon ‘The most important frontend serves that a database can provide on daly basis include: | Access data: Data is inserted int tables of» detabases, Ech table, in a wel designed cb ‘usualy olds data about one object/person/transaction. This data needs to be accessible by suthorized users, By accesible we mean that authorized vewers shouldbe ableto ‘ew /edt/nodty or report on ths data easy 1. Search data: Ona daly basi, we search online for akmost anything! Imagine not having the ‘Search facity on Google, © on any af the ther apps you use dal. ‘Share data: ust asin the pevicu pont, we hare data around te globe ona daly bas Every clip which is uploaded, every picture, every fle which we share uss the share access fights granted tothe users ofa database og Facebook fr this purpose. 15 HoT BORING up HERE = You GET To Lobk "THROUGH EVERYONE'S, Datal eet cong Sowanane cdl ‘Teansfer data: without the abit to transfer data from one table to anche, from one database to another or from one cloud to another much of our transactions on 8 daly basis would become inva, How woula yu pay for your anne purchases? Hew would you book anything enline? caver way of moving fle?” asmncoronset coisraconielutanaase Migrate data: without the ability to migrate an organisation’ data from one databace or ‘management system to another the oxspnsation would have ta re-invent the wheel every time they upgrade systems o decided to move toa new system. Deta migrations avery Gelicate sue, taught wth roblemsin most reali instances. Typical, the problem ‘comes from the misratch of data types from the oto the new or In 2 transfer fom one ‘organisation to another (se TL process inthe HL Extension | ‘As long as the new system does exactly ‘a ‘whatour current system does we're ready to move in. We have a problem, ( iencearnincon/e mentary ‘We now goto Section A2 to continue the basic concepts: A.2 The relational data model A.29 Define the following database torms: table, record, field, primary key secondary key, foreign key, candidate key, composite primary key, oi Dernition table = 22 dimensional array or grid with rows and columns iat Riine | Tat ase “aii [RRkay | Rowse 325 ary Way | Raa lata Cane ea eae — ana Ta Wa Pade [Osa [Daa 555 uve Soeet Pale Bunny [7a Sueet [Rasa ‘apie 99 ae ny npn cat] Worn | 2 rater | ata [Tey [met atta Definition 2: Feld ~an atomic pce of data abouta person or object How many fills can you seein this table? Dettnition 3: Record ~3 row ina table comprising of one or more fields How many record cn you seein this table? a i seers — rr Definition 4 Primary Key A field which uniquely identities the records of agivan table. To understand the meaning of Candidate Key wo also need the definition af a Super Key. ‘Super Keyor Composite Key: One or more which collectively entify a recordin tebe. web | aaace ae ene 36 — ae ham ‘Sampling Iicay re my nt ae han oe copy of en tok, How do we erp tack of : ten opt ha ok ha been rove by whom? Wecan este a compote ey mae ap the egal a eee secondary Key BeaD" | Capa | — ook te | — nator ~~ are Definition 5:A fli database which on be uted for searching ~ Ris cae ndere’. Taare [ase Ta oe Weordetand For example we can index the File ld above so hat we can un searches Woking for five tr Ste, Toot eae Temper] ates Preto Shakespeare \ ) Dafition 6: Forsin Key- Aprimary key which has ben imported into another table. composte tay Fl rectors sin ‘TABLE DIRECTORS ‘The ide fin comes from the intersection of sets in nave set theory an Venn Diagrams Diecon[Suane | fst ame ] 100i —[Splaterg [steven 1002, [serie arin | A B Director Is the primary key for Table DIRECTORS ‘TABLE FILMS ANB Fiiib® | DiretoriO* | Fite ating | Genre on [Toor Sartre | a sai as ior heute ——[o cours Inthe thoy of databases aol refers olinking of two or more tables ung inary kaye wich maymay not Merl becomposte in nature. Director isnow a foreign key in this table INNER JOIN ‘The inner join ensures that the string which denotes 3 field in one table matches that same key in ‘another table: (this dea is explained in much more detal in the werked example atthe end of tis booklet) ‘A210 identify the different types of relationships within databases: one-to-one, one- ‘to-many, many-to-many. ‘Toundertand the ides of relationships in database theory we an consider this example: ‘One cil en only have one olga mother but one bicloglal mother can have many children. tents QQ + Slot Metver nut 1 Silogcal MoE «Many iron Some more examples Husband jones: One, Wife One-to-Many Footballteem [—————-<| Footballer Manysto-Many student >———<] subject ‘ove adn hae tn eee eee eee eee ee In good database design we never allow many to many relationships. These must be broken into two separate one ‘many relationships. an you break the many to maay relationship in the last example above to make it tomany? ‘82.1 Outline the issues caused by redundant dats, (Orhan data] Using the example of child and its biological mother orphan data would refer oa child whose biological mother cannot be found or traced, Rogue fields of data in a table which have no source oF ign ar referred to as orphan or redundent date [A233 Describe the differences between 1st Normal Form (INF), 2nd Normal Form (2NF) and 3rd Normal Form (3NF) 2.14 Describe the characteristics of a normallied database. "These two specication points canbe deat with int. We first ook t what makes a database be in 1", 203 Normal Form. By locking atthe criteria which are required for each NF we ae infact \oserbing the characteristics oF normalized databsze. First Normal Fores (INF) ‘The rules foe NF: + Each data tem cannot be broken down any further Le tis Exch row/recordis unique and has a primary key ‘There ae no records with repeating data ach flld should be unaue WORKED EXAMPLES: ‘Atomic data ‘State whether the following exemples are atomic ornon atomic ‘Rule 2: Each rowirecordis unique and has primary key ona ‘a on a ‘Miss Jane Fields ‘Non atomic CustomeriD® | Title | FirstName | Surname ‘DOB TORO nen Ton atone er CC ‘Student “Atomic. ‘002 Miss Emma White 2/78 oie aE ‘amie a ag Gree Sao Overt Ton tome fle: rere are no recone epeting ta Sopeie pene7on' ia Ton tam Look athe abe below and answer the questions: Tobie ‘hans the flonng examples of on stomic dts inte atomic dts i] Tie Sumams | Telephone no "Non Atomic ‘Atomic ‘ooL Miss ‘Smith (01234 567890 ae Sly odin Fateane wor fae wae one wo suman: oon Pies Tamer oa TE ares 9 aK Crier Wood OR | SRT Fan wor Seen aa aD Tow Postcode ‘ctitabein ame? (Ter) No Tine Georee W San Overt wer feaan: Theres no repeing dts Town fue Ech eld name should be ongue ary Pater 2A in Lookst the tables below ad anaver the questions: fat: Tobles: | voewason bate carina [ 10" |e [ Sumame | Telephone Modet: 7 ‘aor pe Smath —[orass——[orase—Yonase sorsso | ranizs | sasere or [as | Wate [ora39 [oraz Fora |e same [pate Reason: Not all ofthe fel names inthe record are unique, telephone repeats tres times Redesign this database so that it isin 2NF How can tise hed? ants by creating Tat, Te and Tea and 3 ifferent elds containing telephone numbers, “aRTISTIO™ aiee Sie second Normal Form (2NF) [The ries for 2 + Taetable must be in ANF + Non-key atrbutes must depend on every pat ofthe primary key ‘concert: Coneario™ | aris Date “Atiendance | raf Venue Tanise® [ste | Attendance | Profit | Style | Thesarbean | BoC eb 2017 | 3000 25000 | ciassica Symphony rchests ‘Third Normal Form (NF wigmore Hat | nttsuko | starch | 1500 $5000 | Female “Te rulesicharacteristis for NF schida | 2017 soloist +The able must bein 2NF There ate no non-keyatibutas that depend on another non hy attribute entity the ke attouesin this table: Sans nat ‘A 2.1.7 Construct a relational database to 3NF using objects such as tables, queries, entity the non-key atibutes in thistle forms reportsand macros. ‘Atendance, Profit Stl, Date ‘The Driving School Database Model oes every non-key attribute depend on every key attoute? \We use the following record card from a driving school which plans to create a software No system to look after its business. The fat ile database consists of paper cards which are used to book lessons for each customer. Ht your answer above was no, ths table in 1NF/2HE? The stakeholders in this business would normally be identified by the people who run and Neither ‘maintain this business and its related database. why Answer: [EK Lid curenty use a paper based systam. When a cstomrbo0ks a son, the eear card atthe cng school is updotod. An oxampo of a rovord cad is chown in tele 41 ey arose 2 aetna cet soos 298198 wn Date Paend Tart | te: a Lees Beane oath PeseedThvory: Yeo/Mo fino Uewatnsctor: hn necdoaet Manestawtomste: | baw Ingiuctor Wabi ce ats “Table 41 ~riving Senoo! Record Card For each of the fel in this at ile database identify the ‘lel’. Be careful -not all ofthe fields are atomic! Splitthe non atomic elds into stomic and determine 3 data type for each: (some ‘examples are done below, do the rest Feld Rome? Data Tipe ‘Name ‘ion atomic Spinto surname Text/aipnanumenc Fest Name ‘Date Passed Test Romie Dateline Pree Rone Currency oF Real anvai/automate Romie User defined Passed Theory Bionic Boolean aes Tian atone Spin ‘abcess 1 text ireres) | postcode ! for the scenario of the driving school given inthe previous section we will now look at ‘normalizing the tables by separating the fields into logical tables. Four tables wl be needed In order to put this database in 3" Normal Farm (3NF). They wl be 2s follows: customer 10 ‘AutoNumer| Customer Surname text Customer FirstName Text Address. 2 Text address? Text Postcode Text ate ot sien bate/time Mobile Number Tent Usual instructor Text email Text jvisional Ucense Number Text Date Passed Theory Test Date/Time | Passed Theory ‘Yes/No Dsta Type » “Autonumbor Instructrsumacne Text InstrctrristNeme Text bess 1 Text dees 2 Text ost ode ext email Text Prone Text Date ofith Dateyrine Ni Number Text ender sent Ost oines Date/Time ployment History Meme Dawe futeNumber Registration 10 Make Models ‘Year of Manufacture “Transmission History Colour Customer 10 Instructor 10 Vehicle 10 Date of esson ‘Time oftasson Price of Lesson ais Length (hours) Text Text Text Text Meme Datatype ‘autoNumber ‘Number ‘Number ‘Number Date/Time Date/Time Yes/tio Text 'A2.6 Outline the nature ofthe data dictionary. In order to create our database for the crving school, we fist need to create what \scalled a Data Dictionary. Thisisa table containing ‘meta-data ie data about data, In this table we simply Iistthe elds as wells thelr data types and length of each fil Customer 1D Surname | Fiesttvame ‘Telephone passed Theory Test ‘Mobile Number Date of birth ‘Address Address? Provisional license Number Postcode Date Passed Theory Test | dd/mm/vyyy * Usual instructor | Text Tivand hac suitable el let forthese fs: tes rimary Key Tenath of Fea waaay wai ‘Autonumber or Alphanumeric instructor 10 imac enath oi 7 GustomertD Foreign Ke | Autonumber or Text = aa Mlefemsie " oviean instructor 10 Feveign Key Mobi Vehicle Ferien Key mail Date oftesson aefnnlvove Sumame Time ofesson Rhemm | Fest ame Unt fess Tes) | tease ‘address rice Garreney Karen i Yeslvo ootesn) osteode Tree Empioyer story ‘emo | rons Date joined ac tablein he database can be used to creat elated form, Why shuld we do hs? Because Lo forms make easier forthe vero secs th databare tout having eg it the back nd | Witmer Loos. good pracce facto hide’ the bck en ales from the ses of xtabase ands low thant se the fos or cate ety Foumscan be created using a wizard, the Customer Form Customers et ‘tea ‘Yu can make similar forms for the oer 3 tables ofthis database In under S minutes using the ‘Wns ton Access. ‘queries ‘82.19 Describe the difference between a simple and complex query Students willbe expected to be able to: + use Boolean operators such as AND, 03, NOT + reateparameter queries + create derived fel, |A2.1.20 Outline the different methods that can be sed to construct 2 query. Speciation ports A298 2.1.29 willbe eat with together: Defiiton 7 ‘Simple Query -A query which ely we ne eeron/psrametrto search Forecamplein the Driving School Database it you were st okngtosee tow many + casomes have therane Smt” estos have ad 1 our esos + aston ave ad sos wth Taman sons have been onthe of Febuary 2017 and soon, (QUERY BY EXAMPLE ‘The way to set up a query by example isto select the fields required forthe query and then to put one criterion down: custometd | surname Fist Name Lesson LengthofLesson — lesson ——SSSS*~*«~d uO S* Instructor) Truman? { tessonto DateOflesson | 15/02/2017 Definition 8: ‘Complex Query ~@ query which uses more than one criterion ané these are joined with an ‘operator such as AND, OR, NOT. ‘example 1: AND QUERY Find all customers whose surname Is ‘Smith’ AND whose instructor surname is Truman’ ‘Note that f your criterion is text based then it needs to be shown asa string between ‘quotes’. It's 2 number then it ean ga in withaut quotes: | customer Testructoro ‘Customer Surname | Instrictor mame — | Smith | Struman Example 2: AND QUERY Find all lessons on 15°F 2017 AND which have lasted for 1 hour only: Tasseni0 ‘Date Reson 15/02/2017 TengihOflesson = ‘Bample3: OF Query Find ll lessons which have been takon on 17°Jan 2047 OR 18° Jan 2017: TessoniD Dateoitesson =iryeapaai 8/02/2017 Example 4: NOT Query Find alleustomars whore surname i NOT Smith ‘CustomeriD Surname [NOT ‘Sith? ‘ofcourse, very lrge databases use the Structured Query Language (Ql) to run queries. SQL isa ery user rend language. To have 2 feck at how queries can he bull using SQL eather than QE have alook at tiideo: ‘tai shanacademorglcomputing/computer-programming/sal/sa-basis/a/auerving-the: table ‘A216 Construct an entity-relationship diagram (=D) for a given scenario, ‘Students willbe expected to construct entity-telationship lagramsin 3NF forarelational abate, Those tables are inked as shown in the aigram Below. The ifnity’ symbol means many 20 the ‘elationshios that you an seein the diagram below are all to many. foreample 1 customer can take many leszons | Instrctor can teach many lessons 1 vobiele ean be ed for many lessons nd of Part DATABASES ARE SUCH A FUN- DAMENTAL PART OF OUR DAILY LIVES! IN THIS BOOKLET IT HAS BEEN MY AIM TO BRING TOGETHER RELEVANT SPECIFICATION POINTS FROM PARTS Al AND A2 OF THE IB COMPUTER SCIENCE SYLLABUS. IT IS ONLY AFTER THE BASIC CONCEPTS OF DATABASE STRUC- TURE AND DESIGN HAVE BEEN MASTERED THAT ONE CAN MOVE ON TO MORE ADVANCED TOPICS SUCH AS MANAGEMENT INFOR- MATION SYSTEMS, STAKEHOLDERS AND VARIOUS VIEWS OF A DATA- BASE. 7088 ‘90000 > 1457 088

You might also like