{"id":4794,"date":"2020-04-19T18:24:29","date_gmt":"2020-04-19T18:24:29","guid":{"rendered":"https:\/\/www.testpreptraining.com\/tutorial\/?page_id=4794"},"modified":"2020-04-19T18:24:29","modified_gmt":"2020-04-19T18:24:29","slug":"schema-and-data-model-google-professional-data-engineer-gcp","status":"publish","type":"page","link":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/","title":{"rendered":"Schema and data model Google Professional Data Engineer GCP"},"content":{"rendered":"<ul>\n<li>Can contain one or more tables<\/li>\n<li>Tables look like relational database tables<\/li>\n<li>Table structured with rows, columns, and values<\/li>\n<li>table have primary keys.<\/li>\n<li>Data is strongly typed<\/li>\n<li>must define a schema for each database and specify the data types of each column.<\/li>\n<li>Allowable data types include scalar and array types<\/li>\n<li>Avoid hot spotting like bigtable<\/li>\n<li>Use nested tables with primary keys called interleaving for faster access.<\/li>\n<li>Do not use sequential numbers, timestamps.<\/li>\n<li>If needed, store timestamps in descending order.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Parent-child table relationships<\/strong><\/p>\n<ul>\n<li>Two ways to define parent-child relationships &#8211; table interleaving and foreign keys.<\/li>\n<li>Table interleaving is good if child table&#8217;s primary key includes the parent table&#8217;s primary key columns.<\/li>\n<li>Foreign keys\n<ul>\n<li>are not limited to primary key columns<\/li>\n<li>tables can have multiple foreign key relationships<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Primary keys<\/strong><\/p>\n<ul>\n<li>Every table must have a primary key<\/li>\n<li>primary key can be composed of zero or more columns of that table.<\/li>\n<li>For child, the primary key column(s) of the parent table must be the prefix of the primary key of the child table.<\/li>\n<li>Spanner stores rows in sorted order by primary key values<\/li>\n<li>child rows also inserted between parent rows that share the same primary key prefix.<\/li>\n<li>Spanner can physically co-locate rows of related tables.<\/li>\n<\/ul>\n<p>.<\/p>\n<p><strong>Choosing a primary key<\/strong><\/p>\n<ul>\n<li>primary key uniquely identifies each row in a table.<\/li>\n<li>Options for primary key\n<ul>\n<li>Hash the key and store it in a column.<\/li>\n<li>Use a Universally Unique Identifier (UUID).<\/li>\n<li>Bit-reverse sequential values.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Database splits<\/strong><\/p>\n<ul>\n<li>can define hierarchies of parent-child relationships between tables up to seven layers deep<\/li>\n<li>Spanner divides data into chunks called &#8220;splits&#8221;<\/li>\n<li>individual splits can move independently from each other and assigned to different servers<\/li>\n<li>A split is a range of rows in a top-level (in other words, non-interleaved) table, where the rows are ordered by primary key.<\/li>\n<li>The start and end keys of this range are called &#8220;split boundaries&#8221;.<\/li>\n<li>Spanner automatically adds and removes split boundaries<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Key columns<\/strong><\/p>\n<ul>\n<li>The keys of a table can&#8217;t change<\/li>\n<li>can&#8217;t add a key column to an existing table<\/li>\n<li>cannot remove a key column from an existing table.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Storing NULLs<\/strong><\/p>\n<ul>\n<li>Primary key columns can be defined to store NULLs.<\/li>\n<li>to store NULLs in a primary key column, omit the NOT NULL clause<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Disallowed types<\/strong><\/p>\n<p>These cannot be of type ARRAY:<\/p>\n<ul>\n<li>A table&#8217;s key columns.<\/li>\n<li>An index&#8217;s key columns.<\/li>\n<li><\/li>\n<\/ul>\n<p><strong>Replication<\/strong><\/p>\n<ul>\n<li>Spanner automatically gets replication at the byte level<\/li>\n<li>Spanner writes database mutations to files in this filesystem<\/li>\n<li>Spanner creates replicas of each database split<\/li>\n<li>3 types of replicas: read-write replicas, read-only replicas, and witness replicas.<\/li>\n<li>Single-region instances use only read-write replicas,<\/li>\n<li>multi-region instance configurations use a combination of all three types<\/li>\n<\/ul>\n<p>For multi-region<\/p>\n<table>\n<thead>\n<tr>\n<td><strong>Replica type<\/strong><\/td>\n<td><strong>Can vote<\/strong><\/td>\n<td><strong>Can become leader<\/strong><\/td>\n<td><strong>Can serve reads<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>Read-write<\/strong><\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<\/tr>\n<tr>\n<td><strong>Read-only<\/strong><\/td>\n<td>no<\/td>\n<td>no<\/td>\n<td>yes<\/td>\n<\/tr>\n<tr>\n<td><strong>Witness<\/strong><\/td>\n<td>yes<\/td>\n<td>no<\/td>\n<td>no<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>Schema Design Best Practices<\/h3>\n<ul>\n<li>Design a schema that prevents hotspots and other performance issues.<\/li>\n<li>Place compute resources for write-heavy workloads within or close to the default leader region for optimal write latency<\/li>\n<li>Use staleness of at least 15 seconds for optimal read performance outside of the default leader region<\/li>\n<li>place critical compute resources in at least two regions to avoid single-region dependency<\/li>\n<li>keep high priority total CPU utilization under 45% in each region.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Can contain one or more tables Tables look like relational database tables Table structured with rows, columns, and values table have primary keys. Data is strongly typed must define a schema for each database and specify the data types of each column. Allowable data types include scalar and array types Avoid hot spotting like bigtable&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"categories":[617],"tags":[684,687,619,623,622,618,621],"class_list":["post-4794","page","type-page","status-publish","hentry","category-google-gcp","tag-cloud-spanner","tag-cloud-spanner-schema-and-data-model","tag-data-engineer","tag-gcp","tag-google-certification","tag-google-cloud","tag-professional-data-engineer"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials<\/title>\n<meta name=\"description\" content=\"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials\" \/>\n<meta property=\"og:description\" content=\"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/\" \/>\n<meta property=\"og:site_name\" content=\"Testprep Training Tutorials\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/\",\"name\":\"Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\"},\"datePublished\":\"2020-04-19T18:24:29+00:00\",\"dateModified\":\"2020-04-19T18:24:29+00:00\",\"description\":\"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model\",\"breadcrumb\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Schema and data model Google Professional Data Engineer GCP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"name\":\"Testprep Training Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\",\"name\":\"Testprep Training\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"contentUrl\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"width\":583,\"height\":153,\"caption\":\"Testprep Training\"},\"image\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials","description":"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model","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:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/","og_locale":"en_US","og_type":"article","og_title":"Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials","og_description":"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model","og_url":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/","og_site_name":"Testprep Training Tutorials","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/","url":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/","name":"Schema and data model Google Professional Data Engineer GCP - Testprep Training Tutorials","isPartOf":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website"},"datePublished":"2020-04-19T18:24:29+00:00","dateModified":"2020-04-19T18:24:29+00:00","description":"Google Cloud Certified Professional Data Engineer Tutorial, dumps, brief notes on Schema and data model","breadcrumb":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/schema-and-data-model-google-professional-data-engineer-gcp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.testpreptraining.ai\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Schema and data model Google Professional Data Engineer GCP"}]},{"@type":"WebSite","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","name":"Testprep Training Tutorials","description":"","publisher":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization","name":"Testprep Training","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","contentUrl":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","width":583,"height":153,"caption":"Testprep Training"},"image":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/4794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/comments?post=4794"}],"version-history":[{"count":1,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/4794\/revisions"}],"predecessor-version":[{"id":4804,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/4794\/revisions\/4804"}],"wp:attachment":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/media?parent=4794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/categories?post=4794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/tags?post=4794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}