{"id":465,"date":"2023-01-25T13:39:50","date_gmt":"2023-01-25T13:39:50","guid":{"rendered":"http:\/\/learnlearn.uk\/ibcs\/?page_id=465"},"modified":"2023-01-25T13:39:50","modified_gmt":"2023-01-25T13:39:50","slug":"referential-integrity","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/","title":{"rendered":"Referential Integrity"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Referential Integrity<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Referential Integrity<\/h3>\n<p>With a relational database tables are linked together with relationships. This means that if you alter the contents or structure of a table (such as removing an entry or changing a column\u00a0 name) this can have an effect on other tables. If this happens then steps must be taken\u00a0 to maintain referential integrity.<\/p>\n\n<\/div><h2 class=\"tabtitle\">Example<\/h2>\n<div class=\"tabcontent\">\n\n<h4>Example &#8211; Pupil and Class table<\/h4>\n<p>In the example below we have 2 tables. Each pupil is a member of a class the classID in the pupil table is a foreign key from the class table. This means that the integrity of the pupil table is dependent on the class table.<\/p>\n<p><a href=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-example-9618.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1825\" src=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-example-9618.png\" alt=\"\" width=\"538\" height=\"613\" \/><\/a><\/p>\n\n<\/div><h2 class=\"tabtitle\">Integrity Compromised<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Referential Integrity compromised<\/strong><\/p>\n<p>If you alter the contents or structure of the class table then steps must be taken to maintain the referential integrity in the pupil table.<\/p>\n<div id=\"attachment_1826\" style=\"width: 556px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/removed-tuple-in-the-class-table-affects-that-referential-integrity-of-the-pupil-table.png\"><img aria-describedby=\"caption-attachment-1826\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1826\" src=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/removed-tuple-in-the-class-table-affects-that-referential-integrity-of-the-pupil-table.png\" alt=\"\" width=\"546\" height=\"604\" \/><\/a><p id=\"caption-attachment-1826\" class=\"wp-caption-text\">Here class 2 has been removed which has had an effect on the pupil table<\/p><\/div>\n\n<\/div><h2 class=\"tabtitle\">Maintain Integrity<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Maintaining Integrity<\/h3>\n<p>&nbsp;<\/p>\n<p><strong>Option 1\u00a0 &#8211;\u00a0 Use a null value<\/strong><\/p>\n<div id=\"attachment_1827\" style=\"width: 550px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-restored-by-setting-class-to-Null.png\"><img aria-describedby=\"caption-attachment-1827\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1827\" src=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-restored-by-setting-class-to-Null.png\" alt=\"\" width=\"540\" height=\"550\" \/><\/a><p id=\"caption-attachment-1827\" class=\"wp-caption-text\">Here the referential integrity has been restored by setting the class to a null value<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><strong>Option 2 &#8211; Change the ClassID to a valid class<\/strong><\/p>\n<p><a href=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-restored-by-changing-classID-to-a-valid-class.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1828\" src=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-restored-by-changing-classID-to-a-valid-class.png\" alt=\"\" width=\"537\" height=\"546\" \/><\/a><\/p>\n\n<\/div><h2 class=\"tabtitle\">Resources<\/h2>\n<div class=\"tabcontent\">\n\n<p><a href=\"https:\/\/docs.google.com\/presentation\/d\/1Id3WHU5XX4VK784xeoX_Cvj_CS2DCF5AOBSDBJe5CTs\/edit?usp=sharing\">Teacher Presentation<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Referential Integrity With a relational database tables are linked together with relationships. This means that if you alter the contents or structure of a table (such as removing an entry or changing a column\u00a0 name) this can have an effect on other tables. If this happens then steps must be taken\u00a0 to maintain referential integrity.&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Referential Integrity<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":70,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Referential Integrity - IB Computer Science<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Referential Integrity - IB Computer Science\" \/>\n<meta property=\"og:description\" content=\"Referential Integrity With a relational database tables are linked together with relationships. This means that if you alter the contents or structure of a table (such as removing an entry or changing a column\u00a0 name) this can have an effect on other tables. If this happens then steps must be taken\u00a0 to maintain referential integrity.&hellip;&nbsp;Read More &raquo;Referential Integrity\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\" \/>\n<meta property=\"og:site_name\" content=\"IB Computer Science\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-example-9618.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\",\"name\":\"Referential Integrity - IB Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#website\"},\"datePublished\":\"2023-01-25T13:39:50+00:00\",\"dateModified\":\"2023-01-25T13:39:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"IB Computer Science\",\"item\":\"https:\/\/learnlearn.uk\/ibcs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Referential Integrity\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#website\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/\",\"name\":\"IB Computer Science\",\"description\":\"- learnlearn..uk\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/ibcs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#organization\",\"name\":\"IB Computer Science\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png\",\"width\":300,\"height\":41,\"caption\":\"IB Computer Science\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Referential Integrity - IB Computer Science","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/","og_locale":"en_GB","og_type":"article","og_title":"Referential Integrity - IB Computer Science","og_description":"Referential Integrity With a relational database tables are linked together with relationships. This means that if you alter the contents or structure of a table (such as removing an entry or changing a column\u00a0 name) this can have an effect on other tables. If this happens then steps must be taken\u00a0 to maintain referential integrity.&hellip;&nbsp;Read More &raquo;Referential Integrity","og_url":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/","og_site_name":"IB Computer Science","og_image":[{"url":"https:\/\/learnlearn.uk\/alevelcs\/wp-content\/uploads\/sites\/20\/2021\/03\/referential-integrity-example-9618.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/","url":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/","name":"Referential Integrity - IB Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#website"},"datePublished":"2023-01-25T13:39:50+00:00","dateModified":"2023-01-25T13:39:50+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/ibcs\/referential-integrity\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"IB Computer Science","item":"https:\/\/learnlearn.uk\/ibcs\/"},{"@type":"ListItem","position":2,"name":"Referential Integrity"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/ibcs\/#website","url":"https:\/\/learnlearn.uk\/ibcs\/","name":"IB Computer Science","description":"- learnlearn..uk","publisher":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/ibcs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/ibcs\/#organization","name":"IB Computer Science","url":"https:\/\/learnlearn.uk\/ibcs\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png","contentUrl":"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png","width":300,"height":41,"caption":"IB Computer Science"},"image":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/ibcs\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Referential Integrity With a relational database tables are linked together with relationships. This means that if you alter the contents or structure of a table (such as removing an entry or changing a column\u00a0 name) this can have an effect on other tables. If this happens then steps must be taken\u00a0 to maintain referential integrity.&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/465"}],"collection":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/comments?post=465"}],"version-history":[{"count":1,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/465\/revisions"}],"predecessor-version":[{"id":466,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/465\/revisions\/466"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/media?parent=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}