{"id":467,"date":"2024-02-20T13:46:48","date_gmt":"2024-02-20T12:46:48","guid":{"rendered":"https:\/\/bitwise.exposed\/?p=467"},"modified":"2026-03-16T09:38:47","modified_gmt":"2026-03-16T08:38:47","slug":"populate-a-fact-table-with-surrogate-keys-from-dimensions","status":"publish","type":"post","link":"https:\/\/bitwise.exposed\/index.php\/2024\/02\/20\/populate-a-fact-table-with-surrogate-keys-from-dimensions\/","title":{"rendered":"Populate a fact table with surrogate keys from dimensions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Populating a fact table with <a href=\"https:\/\/bitwise.exposed\/index.php\/2023\/11\/24\/facts-and-dimensions\/#surrogatekeysintro\" data-type=\"post\" data-id=\"275\">surrogate keys<\/a> from dimension tables involves connecting the dimension tables to the fact table through foreign key relationships and inserting the corresponding surrogate keys into the fact table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start with some constraints:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#f2f2f2;color:#0d0d0d\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"CREATE TABLE Dim.Customer (\n    DimCustomer_SK INT IDENTITY(1,1) NOT NULL PRIMARY KEY,\n    DimCustomer_BK INT NOT NULL UNIQUE, -- e.g. CustomerNumber\n    CustomerName VARCHAR(255)\n);\n\n&quot;&quot;&quot;\nNotes about: UNIQUE\n\nEnforcing a UNIQUE constraint on our BusinessKey (=BK) not only to ensure that we have a unique key.\n\nThe SQL engine will also create a unique index, this can speed up queries.\n\nI omit that for our SurrogateKey (=SK), assuming that this will be an auto-increment field, then it is implicitly unique, because auto-increment fields generate a unique value for every record. In such a case, explictly addind UNIQUE would be redundant.\n&quot;&quot;&quot;\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">CREATE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">TABLE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">Dim<\/span><span style=\"color: #000000\">.Customer (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_SK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">IDENTITY<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">) <\/span><span style=\"color: #0000FF\">NOT NULL<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">PRIMARY KEY<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_BK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">NOT NULL<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">UNIQUE<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #008000\">-- e.g. CustomerNumber<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    CustomerName <\/span><span style=\"color: #0000FF\">VARCHAR<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #098658\">255<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">Notes about: UNIQUE<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">Enforcing a UNIQUE constraint on our BusinessKey (=BK) not only to ensure that we have a unique key.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">The SQL engine will also create a unique index, this can speed up queries.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">I omit that for our SurrogateKey (=SK), assuming that this will be an auto-increment field, then it is implicitly unique, because auto-increment fields generate a unique value for every record. In such a case, explictly addind UNIQUE would be redundant.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">&quot;&quot;&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Reinforce the relationships between the tables:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#f2f2f2;color:#0d0d0d\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"CREATE TABLE Dim.Customer (\n    DimCustomer_SK INT IDENTITY(1,1) NOT NULL PRIMARY KEY,\n    DimCustomer_BK INT NOT NULL UNIQUE, -- e.g. CustomerNumber\n    CustomerName VARCHAR(255)\n);\n\nCREATE TABLE Fact.Sales (\n    DimCustomer_SK INT REFERENCES Dim.Customer(DimCustomer_SK),\n    DimCustomer_BK INT, -- e.g. CustomerNumber\n    Amount DECIMAL,\n    Quantity INT\n);\n\n&quot;&quot;&quot;\nDimCustomer_SK INT REFERENCES Dim.Customer(DimCustomer_SK) \n\nenforces that the values in Fact.Sales.DimCustomer_SK must match values in Dim.Customer.DimCustomer_SK. \n\nThis means that for any value entered in Fact.Sales.DimCustomer_SK, there must be a corresponding value in the Dim.Customer.DimCustomer_SK.\n\nThis is used for ensuring validity of the data in the Fact.Sales.DimCustomer_SK column as it guarantees that an actual corresponding record exists in the Dim.Customer table. \n\nIf you try to enter a DimCustomer_SK in Fact.Sales that does not exist in Dim.Customer.DimCustomer_SK, the DBMS would throw an error.\n&quot;&quot;&quot;\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">CREATE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">TABLE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">Dim<\/span><span style=\"color: #000000\">.Customer (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_SK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">IDENTITY<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">) <\/span><span style=\"color: #0000FF\">NOT NULL<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">PRIMARY KEY<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_BK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">NOT NULL<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">UNIQUE<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #008000\">-- e.g. CustomerNumber<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    CustomerName <\/span><span style=\"color: #0000FF\">VARCHAR<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #098658\">255<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">CREATE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">TABLE<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">Fact<\/span><span style=\"color: #000000\">.Sales (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_SK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">REFERENCES<\/span><span style=\"color: #000000\"> Dim.Customer(DimCustomer_SK),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DimCustomer_BK <\/span><span style=\"color: #0000FF\">INT<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #008000\">-- e.g. CustomerNumber<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    Amount <\/span><span style=\"color: #0000FF\">DECIMAL<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    Quantity <\/span><span style=\"color: #0000FF\">INT<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">DimCustomer_SK INT REFERENCES Dim.Customer(DimCustomer_SK) <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">enforces that the values in Fact.Sales.DimCustomer_SK must match values in Dim.Customer.DimCustomer_SK. <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">This means that for any value entered in Fact.Sales.DimCustomer_SK, there must be a corresponding value in the Dim.Customer.DimCustomer_SK.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">This is used for ensuring validity of the data in the Fact.Sales.DimCustomer_SK column as it guarantees that an actual corresponding record exists in the Dim.Customer table. <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">If you try to enter a DimCustomer_SK in Fact.Sales that does not exist in Dim.Customer.DimCustomer_SK, the DBMS would throw an error.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #A31515\">&quot;&quot;&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Load DimTable:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#f2f2f2;color:#0d0d0d\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"INSERT INTO Dim.Customer (DimCustomer_BK, CustomerName)\nSELECT \n    CI.CustomerNumber,   -- Assuming CustomerNumber is unique \n    CI.CustomerName      \nFROM \n    CustomerInfo CI      -- Table from source system\nWHERE \n    NOT EXISTS (         -- Check for duplicate\n        SELECT 1\n        FROM Dim.Customer DC\n        WHERE DC.DimCustomer_BK = CI.CustomerNumber\n    );\n\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">INSERT INTO<\/span><span style=\"color: #000000\"> Dim.Customer (DimCustomer_BK, CustomerName)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">SELECT<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    CI.CustomerNumber,   <\/span><span style=\"color: #008000\">-- Assuming CustomerNumber is unique <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    CI.CustomerName      <\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">FROM<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    CustomerInfo CI      <\/span><span style=\"color: #008000\">-- Table from source system<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">WHERE<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">NOT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">EXISTS<\/span><span style=\"color: #000000\"> (         <\/span><span style=\"color: #008000\">-- Check for duplicate<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">SELECT<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">FROM<\/span><span style=\"color: #000000\"> Dim.Customer DC<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">WHERE<\/span><span style=\"color: #000000\"> DC.DimCustomer_BK = CI.CustomerNumber<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    );<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note:<br><strong><code>NOT EXISTS<\/code> Subquery<\/strong>: This condition is crucial for dimension tables to avoid inserting duplicate entries. It checks if the customer already exists in the dimension table based on the business key (<code>CustomerNumber<\/code>). If not, it proceeds with the insert. This helps maintain the uniqueness of entries in the dimension table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Load FactTable:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#f2f2f2;color:#0d0d0d\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"INSERT INTO Fact.Sales (DimCustomer_SK, DimCustomer_BK, Amount, Quantity)\nSELECT \n    DC.DimCustomer_SK,   -- Surrogate key from dimension table\n    T.CustomerNumber,    -- Business key from transactional data\n    T.SaleAmount,        -- Sale amount from transactional data\n    T.SaleQuantity       -- Sale quantity from transactional data\nFROM \n    Transactions T\nJOIN \n    Dim.Customer DC \nON \n    T.CustomerNumber = DC.DimCustomer_BK;\n\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">INSERT INTO<\/span><span style=\"color: #000000\"> Fact.Sales (DimCustomer_SK, DimCustomer_BK, Amount, Quantity)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">SELECT<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    DC.DimCustomer_SK,   <\/span><span style=\"color: #008000\">-- Surrogate key from dimension table<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    T.CustomerNumber,    <\/span><span style=\"color: #008000\">-- Business key from transactional data<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    T.SaleAmount,        <\/span><span style=\"color: #008000\">-- Sale amount from transactional data<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    T.SaleQuantity       <\/span><span style=\"color: #008000\">-- Sale quantity from transactional data<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">FROM<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    Transactions T<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">JOIN<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    Dim.Customer DC <\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">ON<\/span><span style=\"color: #000000\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    T.CustomerNumber = DC.DimCustomer_BK;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Populating a fact table with surrogate keys from dimension tables involves connecting the dimension tables to the fact table through foreign key relationships and inserting the corresponding surrogate keys into the fact table. Let&#8217;s start with some constraints: Reinforce the relationships between the tables: Load DimTable: Note:NOT EXISTS Subquery: This condition is crucial for dimension [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":476,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/comments?post=467"}],"version-history":[{"count":11,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/467\/revisions"}],"predecessor-version":[{"id":632,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/467\/revisions\/632"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/media\/476"}],"wp:attachment":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/media?parent=467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/categories?post=467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/tags?post=467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}