{"id":2631,"date":"2018-01-12T10:25:30","date_gmt":"2018-01-12T10:25:30","guid":{"rendered":"https:\/\/old.staging-teachcomputerscienceuk.kinsta.cloud\/?p=285"},"modified":"2024-07-24T11:24:57","modified_gmt":"2024-07-24T11:24:57","slug":"database-data-types","status":"publish","type":"post","link":"https:\/\/teachcomputerscience.com\/database-data-types\/","title":{"rendered":"Database Data Types"},"content":{"rendered":"<div class=\"gb-container gb-container-ccedabfa upsell-block\"><div class=\"gb-inside-container\">\n<div class=\"gb-grid-wrapper gb-grid-wrapper-0d3a2f1f\">\n<div class=\"gb-grid-column gb-grid-column-97ed4359\"><div class=\"gb-container gb-container-97ed4359\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-80bc7320 gb-headline-text\">KS3 Databases Resources (14-16 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-51f16acd\">\n\n<a class=\"gb-button gb-button-beea72c7 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/ks3\/databases\/\">View KS3 Databases Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n\n<div class=\"gb-grid-column gb-grid-column-e4509e67\"><div class=\"gb-container gb-container-e4509e67\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-eaf3e317 gb-headline-text\">A-Level Introduction to Databases (16-18 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-db775f58\">\n\n<a class=\"gb-button gb-button-dfb8a333 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/a-level\/exchanging-data\/introduction-to-databases\/\">View A-Level Introduction to Databases Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Database data types<\/strong> refer to the format of data storage that can hold a distinct type or range of values.\u00a0 When computer programs store data in variables, each variable must be designated a distinct data type.\u00a0 Some common data types are as follows: integers, characters, strings, floating-point numbers and arrays.\u00a0 More specific data types are as follows: varchar (variable character) formats, Boolean values, dates and timestamps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are programming languages that require the programmer to determine the data type of a variable before attaching a value to it.&nbsp; While some <a class=\"wpil_internal_link\" style=\"display: inline !important; width: auto !important;\" rel=\"noopener noreferrer\" data-wpil-post-to-id=\"328\" href=\"http:\/\/teachcomputerscience.com\/programming-language-quiz\/\" target=\"_blank\">programming languages<\/a> can automatically attach a data type to a variable based on the initial data assigned to the variable.&nbsp; For example, a variable is assigned with the value \u201c3.75\u201d, then the data type that will be attached to the variable is floating point.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the programming languages enable each variable to store only a single data type.&nbsp; For example, if the data type attached to the variable is integer, when you assign a string data to the variable, the string data will be converted to an integer format.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Database applications<\/strong> use data types.&nbsp; <a class=\"wpil_internal_link\" style=\"display: inline !important; width: auto !important;\" rel=\"noopener noreferrer\" data-wpil-post-to-id=\"2637\" href=\"http:\/\/teachcomputerscience.com\/database-fields\/\" target=\"_blank\">Database fields<\/a> require distinct type of data to be entered.&nbsp; For example, school record for a student may use a string data type for student\u2019s first and last name.&nbsp; The student\u2019s date of birth would be stored in a date format and the student\u2019s GPA can be stored as decimal.&nbsp; By ensuring that the data types are consistent across multiple records, database applications can easily perform calculations, comparisons, searching and sorting of fields in different records.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Database Data Types<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Integer<\/strong> \u2013 is a whole number that can have a positive, negative or zero value. It cannot be a fraction nor can have decimal places.&nbsp; It is commonly used in programming especially for increasing values.&nbsp; Addition, subtraction and multiplication of two integers results to an integer.&nbsp; But division of two integers may result to an integer or a decimal.&nbsp; The resulting decimal can be rounded off or truncated to produce an integer.<\/li><li><strong>Character<\/strong> \u2013 refers to any number, letter, space or symbol that can be entered in a computer. Each character occupies one byte of space.<\/li><li><strong>String<\/strong> \u2013 is used to represent text. It is composed of a <a class=\"wpil_internal_link\" style=\"display: inline !important; width: auto !important;\" href=\"http:\/\/teachcomputerscience.com\/character-sets\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-wpil-post-to-id=\"2663\">set of characters<\/a> that can have spaces and numbers.&nbsp; Strings are enclosed in quotation marks to identify the data as string and not a variable name nor a number.<\/li><li><strong>Floating Point Number<\/strong> \u2013 is a number that contains decimals. Numbers that contain fractions are also considered as floating point numbers.<\/li><li><strong>Array<\/strong> \u2013 contains a group of elements which can be of the same data type like an integer or string. It is used to organise data for easier sorting and searching of related set of values.<\/li><li><strong>Varchar<\/strong> &#8211; as the name implies is variable character as the memory storage has variable length.&nbsp; Each character occupies one byte of space plus 2 bytes for length information.<em>Note: Use Character for data entries with fixed length, like phone number.&nbsp; Use Varchar for data entries with variable length, like address.<\/em><\/li><li><strong>Boolean<\/strong> \u2013 is used for creating true or false statements. To compare values the following operators are being used: AND, OR, XOR, and NOT.<br>\n<table class=\"rcp-table\">\n<tbody>\n<tr>\n<th><strong>Boolean Operator<\/strong><\/th>\n<th><strong>Result<\/strong><\/th>\n<th><strong>Condition<\/strong><\/th>\n<\/tr>\n<tr>\n<td>x AND y<\/td>\n<td>True<\/td>\n<td>If both x and y are True<\/td>\n<\/tr>\n<tr>\n<td>x AND y<\/td>\n<td>False<\/td>\n<td>If either x or y is False<\/td>\n<\/tr>\n<tr>\n<td>x OR y<\/td>\n<td>True<\/td>\n<td>If either x or y, or both x and y are True<\/td>\n<\/tr>\n<tr>\n<td>x OR y<\/td>\n<td>False<\/td>\n<td>If both x and y are False<\/td>\n<\/tr>\n<tr>\n<td>x XOR y<\/td>\n<td>True<\/td>\n<td>If only x or y is True<\/td>\n<\/tr>\n<tr>\n<td>x XOR y<\/td>\n<td>False<\/td>\n<td>If x and y are both True or both False<\/td>\n<\/tr>\n<tr>\n<td>NOT x<\/td>\n<td>True<\/td>\n<td>If x is False<\/td>\n<\/tr>\n<tr>\n<td>NOT x<\/td>\n<td>False<\/td>\n<td>If x is True<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li><li><strong>Date, Time and Timestamp<\/strong> \u2013 these data types are used to work with data containing dates and times.<\/li><\/ul>\n\n\n\n<h3 class=\"gb-headline gb-headline-7a0f9f6d gb-headline-text\">Further Readings:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Data_type\" target=\"_blank\" rel=\"noopener\">Data type<\/a><\/li><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Database\" target=\"_blank\" rel=\"noopener\">Database<\/a><\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/032-data.png\" alt=\"Database data types refer to the format of data storage that can hold a distinct type or range of values.\" class=\"wp-image-5956\" width=\"301\" height=\"301\" title=\"\" srcset=\"https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/032-data.png 512w, https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/032-data-150x150.png 150w, https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/032-data-300x300.png 300w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Database data types refer to the format of data storage that can hold a distinct type or range of values.\u00a0 When computer programs store data in variables, each variable must be designated a distinct data type.\u00a0 Some common data types are as follows: integers, characters, strings, floating-point numbers and arrays.\u00a0 More specific data types are &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Database Data Types\" class=\"read-more button\" href=\"https:\/\/teachcomputerscience.com\/database-data-types\/\" aria-label=\"Read more about Database Data Types\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[12],"tags":[204,47],"class_list":["post-2631","post","type-post","status-publish","format-standard","hentry","category-databases","tag-article","tag-hide-old-upsell","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"acf":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/comments?post=2631"}],"version-history":[{"count":3,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2631\/revisions"}],"predecessor-version":[{"id":607163,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2631\/revisions\/607163"}],"wp:attachment":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/media?parent=2631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/categories?post=2631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/tags?post=2631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}