├── .devcontainer └── devcontainer.json ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── main.yml ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── AdventureWorks Entity Relationship Diagram.pdf ├── AdventureWorks.db ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── create_database.sh ├── create_tables.sql ├── csv ├── DimCurrency.csv ├── DimCustomer.csv ├── DimDate.csv ├── DimDepartmentGroup.csv ├── DimEmployee.csv ├── DimGeography.csv ├── DimOrganization.csv ├── DimProduct.csv ├── DimProductCategory.csv ├── DimProductSubcategory.csv ├── DimPromotion.csv ├── DimReseller.csv ├── DimSalesReason.csv ├── DimSalesTerritory.csv ├── FactCurrencyRate.csv ├── FactInternetSales.csv ├── FactInternetSalesReason.csv ├── FactResellerSales.csv └── FactSurveyResponse.csv ├── help_files ├── Chapter 1 │ └── Chapter1.txt ├── Chapter 2 │ └── Chapter 2.4.1.sql ├── Chapter 3 │ ├── 3.2.2.sql │ └── create_views_ch3.sql └── Chapter 4 │ └── 4.4.1.sql └── solutions ├── Chapter 1 ├── Solution 1.3.txt ├── adventureworks_docs.html ├── adventureworks_docs_v2.html └── create_documentation.sh ├── Chapter 2 ├── Chapter 2.3.2.sql ├── Chapter 2.3.3.sql ├── Chapter 2.3.4.sql ├── Chapter 2.3.5.sql ├── Chapter 2.3.sql └── Chapter 2.6.1.sql ├── Chapter 3 ├── 3.3.1.sql ├── 3.3.2.sql ├── 3.3.3.sql └── 3.5.1.sql ├── Chapter 4 ├── 4.3.1.sql ├── 4.3.2.sql ├── 4.3.3.sql └── 4.5.1.sql └── Chapter 5 └── 5.3.1.sql /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": [ 3 | "GitHub.github-vscode-theme", 4 | "alexcvzz.vscode-sqlite", 5 | "qwtel.sqlite-viewer" 6 | ], 7 | "onCreateCommand" : "echo PS1='\"$ \"' >> ~/.bashrc", //Set Terminal Prompt to $ 8 | } 9 | 10 | // DevContainer Reference: https://code.visualstudio.com/docs/remote/devcontainerjson-reference 11 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) deotes "all files and folders" 3 | # Example: * @producer @instructor 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Issue Overview 9 | 10 | 11 | ## Describe your environment 12 | 13 | 14 | ## Steps to Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 4. 20 | 21 | ## Expected Behavior 22 | 23 | 24 | ## Current Behavior 25 | 26 | 27 | ## Possible Solution 28 | 29 | 30 | ## Screenshots / Video 31 | 32 | 33 | ## Related Issues 34 | 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Copy To Branches 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | copy-to-branches: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | with: 10 | fetch-depth: 0 11 | - name: Copy To Branches Action 12 | uses: planetoftheweb/copy-to-branches@v1.2 13 | env: 14 | key: main 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .tmp 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "qwtel.sqlite-viewer" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.bracketPairColorization.enabled": true, 3 | "editor.cursorBlinking": "solid", 4 | "editor.fontFamily": "ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace", 5 | "editor.fontLigatures": false, 6 | "editor.fontSize": 22, 7 | "editor.formatOnPaste": true, 8 | "editor.formatOnSave": true, 9 | "editor.lineNumbers": "on", 10 | "editor.matchBrackets": "always", 11 | "editor.minimap.enabled": false, 12 | "editor.smoothScrolling": true, 13 | "editor.tabSize": 2, 14 | "editor.useTabStops": true, 15 | "emmet.triggerExpansionOnTab": true, 16 | "explorer.openEditors.visible": 0, 17 | "files.autoSave": "afterDelay", 18 | "screencastMode.onlyKeyboardShortcuts": true, 19 | "terminal.integrated.fontSize": 18, 20 | "window.zoomLevel": 3, 21 | "workbench.activityBar.visible": true, 22 | "workbench.colorTheme": "Visual Studio Dark", 23 | "workbench.fontAliasing": "antialiased", 24 | "workbench.statusBar.visible": true 25 | } 26 | -------------------------------------------------------------------------------- /AdventureWorks Entity Relationship Diagram.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinkedInLearning/practice-it-sql-joins-3085459/3ce611491d7cd83ae5fdf1d917d8ec7dbc43f475/AdventureWorks Entity Relationship Diagram.pdf -------------------------------------------------------------------------------- /AdventureWorks.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinkedInLearning/practice-it-sql-joins-3085459/3ce611491d7cd83ae5fdf1d917d8ec7dbc43f475/AdventureWorks.db -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contribution Agreement 3 | ====================== 4 | 5 | This repository does not accept pull requests (PRs). All pull requests will be closed. 6 | 7 | However, if any contributions (through pull requests, issues, feedback or otherwise) are provided, as a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code (or otherwise providing feedback), you (and, if applicable, your employer) are licensing the submitted code (and/or feedback) to LinkedIn and the open source community subject to the BSD 2-Clause license. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LinkedIn Learning Exercise Files License Agreement 2 | ================================================== 3 | 4 | This License Agreement (the "Agreement") is a binding legal agreement 5 | between you (as an individual or entity, as applicable) and LinkedIn 6 | Corporation (“LinkedIn”). By downloading or using the LinkedIn Learning 7 | exercise files in this repository (“Licensed Materials”), you agree to 8 | be bound by the terms of this Agreement. If you do not agree to these 9 | terms, do not download or use the Licensed Materials. 10 | 11 | 1. License. 12 | - a. Subject to the terms of this Agreement, LinkedIn hereby grants LinkedIn 13 | members during their LinkedIn Learning subscription a non-exclusive, 14 | non-transferable copyright license, for internal use only, to 1) make a 15 | reasonable number of copies of the Licensed Materials, and 2) make 16 | derivative works of the Licensed Materials for the sole purpose of 17 | practicing skills taught in LinkedIn Learning courses. 18 | - b. Distribution. Unless otherwise noted in the Licensed Materials, subject 19 | to the terms of this Agreement, LinkedIn hereby grants LinkedIn members 20 | with a LinkedIn Learning subscription a non-exclusive, non-transferable 21 | copyright license to distribute the Licensed Materials, except the 22 | Licensed Materials may not be included in any product or service (or 23 | otherwise used) to instruct or educate others. 24 | 25 | 2. Restrictions and Intellectual Property. 26 | - a. You may not to use, modify, copy, make derivative works of, publish, 27 | distribute, rent, lease, sell, sublicense, assign or otherwise transfer the 28 | Licensed Materials, except as expressly set forth above in Section 1. 29 | - b. Linkedin (and its licensors) retains its intellectual property rights 30 | in the Licensed Materials. Except as expressly set forth in Section 1, 31 | LinkedIn grants no licenses. 32 | - c. You indemnify LinkedIn and its licensors and affiliates for i) any 33 | alleged infringement or misappropriation of any intellectual property rights 34 | of any third party based on modifications you make to the Licensed Materials, 35 | ii) any claims arising from your use or distribution of all or part of the 36 | Licensed Materials and iii) a breach of this Agreement. You will defend, hold 37 | harmless, and indemnify LinkedIn and its affiliates (and our and their 38 | respective employees, shareholders, and directors) from any claim or action 39 | brought by a third party, including all damages, liabilities, costs and 40 | expenses, including reasonable attorneys’ fees, to the extent resulting from, 41 | alleged to have resulted from, or in connection with: (a) your breach of your 42 | obligations herein; or (b) your use or distribution of any Licensed Materials. 43 | 44 | 3. Open source. This code may include open source software, which may be 45 | subject to other license terms as provided in the files. 46 | 47 | 4. Warranty Disclaimer. LINKEDIN PROVIDES THE LICENSED MATERIALS ON AN “AS IS” 48 | AND “AS AVAILABLE” BASIS. LINKEDIN MAKES NO REPRESENTATION OR WARRANTY, 49 | WHETHER EXPRESS OR IMPLIED, ABOUT THE LICENSED MATERIALS, INCLUDING ANY 50 | REPRESENTATION THAT THE LICENSED MATERIALS WILL BE FREE OF ERRORS, BUGS OR 51 | INTERRUPTIONS, OR THAT THE LICENSED MATERIALS ARE ACCURATE, COMPLETE OR 52 | OTHERWISE VALID. TO THE FULLEST EXTENT PERMITTED BY LAW, LINKEDIN AND ITS 53 | AFFILIATES DISCLAIM ANY IMPLIED OR STATUTORY WARRANTY OR CONDITION, INCLUDING 54 | ANY IMPLIED WARRANTY OR CONDITION OF MERCHANTABILITY OR FITNESS FOR A 55 | PARTICULAR PURPOSE, AVAILABILITY, SECURITY, TITLE AND/OR NON-INFRINGEMENT. 56 | YOUR USE OF THE LICENSED MATERIALS IS AT YOUR OWN DISCRETION AND RISK, AND 57 | YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE THAT RESULTS FROM USE OF THE 58 | LICENSED MATERIALS TO YOUR COMPUTER SYSTEM OR LOSS OF DATA. NO ADVICE OR 59 | INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM US OR THROUGH OR 60 | FROM THE LICENSED MATERIALS WILL CREATE ANY WARRANTY OR CONDITION NOT 61 | EXPRESSLY STATED IN THESE TERMS. 62 | 63 | 5. Limitation of Liability. LINKEDIN SHALL NOT BE LIABLE FOR ANY INDIRECT, 64 | INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING 65 | BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER 66 | INTANGIBLE LOSSES . IN NO EVENT WILL LINKEDIN'S AGGREGATE LIABILITY TO YOU 67 | EXCEED $100. THIS LIMITATION OF LIABILITY SHALL: 68 | - i. APPLY REGARDLESS OF WHETHER (A) YOU BASE YOUR CLAIM ON CONTRACT, TORT, 69 | STATUTE, OR ANY OTHER LEGAL THEORY, (B) WE KNEW OR SHOULD HAVE KNOWN ABOUT 70 | THE POSSIBILITY OF SUCH DAMAGES, OR (C) THE LIMITED REMEDIES PROVIDED IN THIS 71 | SECTION FAIL OF THEIR ESSENTIAL PURPOSE; AND 72 | - ii. NOT APPLY TO ANY DAMAGE THAT LINKEDIN MAY CAUSE YOU INTENTIONALLY OR 73 | KNOWINGLY IN VIOLATION OF THESE TERMS OR APPLICABLE LAW, OR AS OTHERWISE 74 | MANDATED BY APPLICABLE LAW THAT CANNOT BE DISCLAIMED IN THESE TERMS. 75 | 76 | 6. Termination. This Agreement automatically terminates upon your breach of 77 | this Agreement or termination of your LinkedIn Learning subscription. On 78 | termination, all licenses granted under this Agreement will terminate 79 | immediately and you will delete the Licensed Materials. Sections 2-7 of this 80 | Agreement survive any termination of this Agreement. LinkedIn may discontinue 81 | the availability of some or all of the Licensed Materials at any time for any 82 | reason. 83 | 84 | 7. Miscellaneous. This Agreement will be governed by and construed in 85 | accordance with the laws of the State of California without regard to conflict 86 | of laws principles. The exclusive forum for any disputes arising out of or 87 | relating to this Agreement shall be an appropriate federal or state court 88 | sitting in the County of Santa Clara, State of California. If LinkedIn does 89 | not act to enforce a breach of this Agreement, that does not mean that 90 | LinkedIn has waived its right to enforce this Agreement. The Agreement does 91 | not create a partnership, agency relationship, or joint venture between the 92 | parties. Neither party has the power or authority to bind the other or to 93 | create any obligation or responsibility on behalf of the other. You may not, 94 | without LinkedIn’s prior written consent, assign or delegate any rights or 95 | obligations under these terms, including in connection with a change of 96 | control. Any purported assignment and delegation shall be ineffective. The 97 | Agreement shall bind and inure to the benefit of the parties, their respective 98 | successors and permitted assigns. If any provision of the Agreement is 99 | unenforceable, that provision will be modified to render it enforceable to the 100 | extent possible to give effect to the parties’ intentions and the remaining 101 | provisions will not be affected. This Agreement is the only agreement between 102 | you and LinkedIn regarding the Licensed Materials, and supersedes all prior 103 | agreements relating to the Licensed Materials. 104 | 105 | Last Updated: March 2019 106 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2022 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the LinkedIn Learning Exercise File License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | Please note, this project may automatically load third party code from external 8 | repositories (for example, NPM modules, Composer packages, or other dependencies). 9 | If so, such third party code may be subject to other license terms than as set 10 | forth above. In addition, such third party code may also depend on and load 11 | multiple tiers of dependencies. Please review the applicable licenses of the 12 | additional dependencies. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Practice It: SQL Joins 2 | This is the repository for the LinkedIn Learning course Practice It: SQL Joins. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | ![1666987275307](https://user-images.githubusercontent.com/25848438/200747667-d4531a5c-2aef-4690-a1c4-246edbe80bd4.jpeg) 5 | 6 | In this course, instructor Nikiya Simpson guides you through four main types of SQL joins, with plenty of opportunities to try what you’re learning. Nikiya starts with schema description SQL commands, plus table and column description SQL commands. She goes over inner joins, then dives into left joins, self joins, and multiple complex joins. Nikiya also covers right joins, full outer joins, and cross joins.

This course is integrated with GitHub Codespaces, an instant cloud developer environment that offers all the functionality of your favorite IDE without the need for any local machine setup. With GitHub Codespaces, you can get hands-on practice from any machine, at any time—all while using a tool that you’ll likely encounter in the workplace. Check out the [Using GitHub Codespaces with this course][gcs-video-url] video to learn how to get started. 7 | 8 | ## Installing 9 | 1. To use these exercise files, you must have the following installed: 10 | - The following VS Code extensions are used in this course and are helpful with viewing SQL results and PDFs. 11 | * SQLiteViewer 12 | * PDFViewer 13 | * You can install the HTML Preview or Open in Default Browser extensions in VS Code to open your html files to view. 14 | 2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. 15 | 3. To install the AdventureWorks database, open a new terminal session. Run `./create_database.sh` on the command line. 16 | 17 | 4. If you recieve a "Permission denied" error on running any of your shell scripts (.sh files), run the following command on your file name (ex. create_documentation.sh): 18 | `chmod +x create_documentation.sh` 19 | 20 | 5. This course outputs files in HTML format in Chapter 1. You can also use .line or .column formats as well if you are not as familiar with HTML. 21 | 22 | ### Instructor 23 | 24 | Nikiya Simpson 25 | 26 | Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/nikiya-simpson?u=104). 27 | 28 | [lil-course-url]: https://www.linkedin.com/learning/practice-it-sql-joins 29 | [gcs-video-url]: https://www.linkedin.com/learning/practice-it-sql-joins/getting-started-with-github-codespaces 30 | 31 | -------------------------------------------------------------------------------- /create_database.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sqlite3 AdventureWorks.db < B.ProductKey 8 | AND A.ProductSubcategoryKey = B.ProductSubcategoryKey 9 | ORDER BY A.ProductSubcategoryKey; -------------------------------------------------------------------------------- /help_files/Chapter 3/3.2.2.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | select p.ProductKey, sum(s.SalesAmount) as Sum_of_Sales 3 | from DimProduct p 4 | left join FactInternetSales s using(ProductKey) 5 | group by p.ProductKey; -------------------------------------------------------------------------------- /help_files/Chapter 3/create_views_ch3.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | drop view customer_email_a; 3 | create view customer_email_a as 4 | select CustomerKey, EmailAddress from DimCustomer 5 | where EmailAddress like '%a%@adventure-works.com'; 6 | 7 | drop view customer_address_us; 8 | create view customer_address_us as 9 | select CustomerKey, AddressLine1, AddressLine2, C.GeographyKey from DimCustomer C 10 | join DimGeography G ON C.GeographyKey = G.GeographyKey 11 | where CountryRegionCode = 'US'; -------------------------------------------------------------------------------- /help_files/Chapter 4/4.4.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* 3 | FROM 4 | DimCustomer a 5 | LEFT JOIN FactSurveyResponse b 6 | ON a.CustomerKey = b.CustomerKey 7 | UNION 8 | SELECT a.*, b.* 9 | FROM 10 | FactSurveyResponse b 11 | LEFT JOIN DimCustomer a 12 | ON a.CustomerKey = b.CustomerKey; -------------------------------------------------------------------------------- /solutions/Chapter 1/Solution 1.3.txt: -------------------------------------------------------------------------------- 1 | * Script to Run for Solution 2 | .open AdventureWorks.db 3 | .mode html 4 | .output adventureworks_docs.html 5 | .headers on 6 | .tables 7 | SELECT "Number of rows in DimCurrency"; 8 | SELECT count(1) from DimCurrency; 9 | SELECT "Number of rows in DimCustomer"; 10 | SELECT count(1) from DimCustomer; 11 | SELECT "Number of rows in DimDate"; 12 | SELECT count(1) from DimDate; 13 | SELECT "Number of rows in DimDepartmentGroup"; 14 | SELECT count(1) from DimDepartmentGroup; 15 | SELECT "Number of rows in DimEmployee"; 16 | SELECT count(1) from DimEmployee; 17 | SELECT "Number of rows in DimGeography"; 18 | SELECT count(1) from DimGeography; 19 | SELECT "Number of rows in DimOrganization"; 20 | SELECT count(1) from DimOrganization; 21 | SELECT "Number of rows in DimProduct"; 22 | SELECT count(1) from DimProduct; 23 | SELECT "Number of rows in DimProductCategory"; 24 | SELECT count(1) from DimProductCategory; 25 | SELECT "Number of rows in DimProductSubCategory"; 26 | SELECT count(1) from DimProductSubCategory; 27 | SELECT "Number of rows in DimPromotion"; 28 | SELECT count(1) from DimPromotion; 29 | SELECT "Number of rows in DimReseller"; 30 | SELECT count(1) from DimReseller; 31 | SELECT "Number of rows in DimSalesReason"; 32 | SELECT count(1) from DimSalesReason; 33 | SELECT "Number of rows in DimSalesTerritory"; 34 | SELECT count(1) from DimSalesTerritory; 35 | SELECT "Number of rows in FactCurrencyRate"; 36 | SELECT count(1) from FactCurrencyRate; 37 | SELECT "Number of rows in FactInternetSales"; 38 | SELECT count(1) from FactInternetSales; 39 | SELECT "Number of rows in FactInternetSalesReason"; 40 | SELECT count(1) from FactInternetSalesReason; 41 | SELECT "Number of rows in FactResellerSales"; 42 | SELECT count(1) from FactResellerSales; 43 | SELECT "Number of rows in FactSurveyResponse"; 44 | SELECT count(1) from FactSurveyResponse; 45 | 46 | SELECT sql from sqlite_master where name in 47 | ('DimCurrency','DimProductCategory', 'FactInternetSalesReason', 48 | 'DimCustomer','DimProductSubcategory','FactResellerSales', 49 | 'DimDate','DimPromotion','FactSurveyResponse', 50 | 'DimDepartmentGroup','DimReseller', 51 | 'DimEmployee','DimSalesReason', 52 | 'DimGeography','DimSalesTerritory', 53 | 'DimOrganization','FactCurrencyRate', 54 | 'DimProduct','FactInternetSales'); -------------------------------------------------------------------------------- /solutions/Chapter 1/adventureworks_docs.html: -------------------------------------------------------------------------------- 1 | DimCurrency DimProductCategory FactInternetSalesReason 2 | DimCustomer DimProductSubcategory FactResellerSales 3 | DimDate DimPromotion FactSurveyResponse 4 | DimDepartmentGroup DimReseller customer_address_us 5 | DimEmployee DimSalesReason customer_email_a 6 | DimGeography DimSalesTerritory vwCUSTOMER_ADDRESS 7 | DimOrganization FactCurrencyRate vwCUSTOMER_BIRTHDATE 8 | DimProduct FactInternetSales 9 | "Number of rows in DimCurrency" 10 | 11 | Number of rows in DimCurrency 12 | 13 | count(1) 14 | 15 | 105 16 | 17 | "Number of rows in DimCustomer" 18 | 19 | Number of rows in DimCustomer 20 | 21 | count(1) 22 | 23 | 18484 24 | 25 | "Number of rows in DimDate" 26 | 27 | Number of rows in DimDate 28 | 29 | count(1) 30 | 31 | 3652 32 | 33 | "Number of rows in DimDepartmentGroup" 34 | 35 | Number of rows in DimDepartmentGroup 36 | 37 | count(1) 38 | 39 | 7 40 | 41 | "Number of rows in DimEmployee" 42 | 43 | Number of rows in DimEmployee 44 | 45 | count(1) 46 | 47 | 296 48 | 49 | "Number of rows in DimGeography" 50 | 51 | Number of rows in DimGeography 52 | 53 | count(1) 54 | 55 | 655 56 | 57 | "Number of rows in DimOrganization" 58 | 59 | Number of rows in DimOrganization 60 | 61 | count(1) 62 | 63 | 14 64 | 65 | "Number of rows in DimProduct" 66 | 67 | Number of rows in DimProduct 68 | 69 | count(1) 70 | 71 | 606 72 | 73 | "Number of rows in DimProductCategory" 74 | 75 | Number of rows in DimProductCategory 76 | 77 | count(1) 78 | 79 | 4 80 | 81 | "Number of rows in DimProductSubCategory" 82 | 83 | Number of rows in DimProductSubCategory 84 | 85 | count(1) 86 | 87 | 37 88 | 89 | "Number of rows in DimPromotion" 90 | 91 | Number of rows in DimPromotion 92 | 93 | count(1) 94 | 95 | 16 96 | 97 | "Number of rows in DimReseller" 98 | 99 | Number of rows in DimReseller 100 | 101 | count(1) 102 | 103 | 701 104 | 105 | "Number of rows in DimSalesReason" 106 | 107 | Number of rows in DimSalesReason 108 | 109 | count(1) 110 | 111 | 10 112 | 113 | "Number of rows in DimSalesTerritory" 114 | 115 | Number of rows in DimSalesTerritory 116 | 117 | count(1) 118 | 119 | 11 120 | 121 | "Number of rows in FactCurrencyRate" 122 | 123 | Number of rows in FactCurrencyRate 124 | 125 | count(1) 126 | 127 | 14264 128 | 129 | "Number of rows in FactInternetSales" 130 | 131 | Number of rows in FactInternetSales 132 | 133 | count(1) 134 | 135 | 60398 136 | 137 | "Number of rows in FactInternetSalesReason" 138 | 139 | Number of rows in FactInternetSalesReason 140 | 141 | count(1) 142 | 143 | 64515 144 | 145 | "Number of rows in FactResellerSales" 146 | 147 | Number of rows in FactResellerSales 148 | 149 | count(1) 150 | 151 | 58820 152 | 153 | "Number of rows in FactSurveyResponse" 154 | 155 | Number of rows in FactSurveyResponse 156 | 157 | count(1) 158 | 159 | 2727 160 | 161 | sql 162 | 163 | CREATE TABLE DimCurrency( 164 | CurrencyKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 165 | CurrencyAlternateKey nchar(3) NOT NULL, 166 | CurrencyName nvarchar(50) NOT NULL 167 | ) 168 | 169 | CREATE TABLE DimCustomer( 170 | CustomerKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 171 | GeographyKey int NULL, 172 | CustomerAlternateKey nvarchar(15) NOT NULL, 173 | Title nvarchar(8) NULL, 174 | FirstName nvarchar(50) NULL, 175 | MiddleName nvarchar(50) NULL, 176 | LastName nvarchar(50) NULL, 177 | NameStyle bit NULL, 178 | BirthDate date NULL, 179 | MaritalStatus nchar(1) NULL, 180 | Suffix nvarchar(10) NULL, 181 | Gender nvarchar(1) NULL, 182 | EmailAddress nvarchar(50) NULL, 183 | YearlyIncome money NULL, 184 | TotalChildren tinyint NULL, 185 | NumberChildrenAtHome tinyint NULL, 186 | EnglishEducation nvarchar(40) NULL, 187 | SpanishEducation nvarchar(40) NULL, 188 | FrenchEducation nvarchar(40) NULL, 189 | EnglishOccupation nvarchar(100) NULL, 190 | SpanishOccupation nvarchar(100) NULL, 191 | FrenchOccupation nvarchar(100) NULL, 192 | HouseOwnerFlag nchar(1) NULL, 193 | NumberCarsOwned tinyint NULL, 194 | AddressLine1 nvarchar(120) NULL, 195 | AddressLine2 nvarchar(120) NULL, 196 | Phone nvarchar(20) NULL, 197 | DateFirstPurchase date NULL, 198 | CommuteDistance nvarchar(15) NULL, 199 | FOREIGN KEY (GeographyKey) REFERENCES DimGeography(GeographyKey) 200 | ) 201 | 202 | CREATE TABLE DimDate( 203 | DateKey int NOT NULL PRIMARY KEY, 204 | FullDateAlternateKey date NOT NULL, 205 | DayNumberOfWeek tinyint NOT NULL, 206 | EnglishDayNameOfWeek nvarchar(10) NOT NULL, 207 | SpanishDayNameOfWeek nvarchar(10) NOT NULL, 208 | FrenchDayNameOfWeek nvarchar(10) NOT NULL, 209 | DayNumberOfMonth tinyint NOT NULL, 210 | DayNumberOfYear smallint NOT NULL, 211 | WeekNumberOfYear tinyint NOT NULL, 212 | EnglishMonthName nvarchar(10) NOT NULL, 213 | SpanishMonthName nvarchar(10) NOT NULL, 214 | FrenchMonthName nvarchar(10) NOT NULL, 215 | MonthNumberOfYear tinyint NOT NULL, 216 | CalendarQuarter tinyint NOT NULL, 217 | CalendarYear smallint NOT NULL, 218 | CalendarSemester tinyint NOT NULL, 219 | FiscalQuarter tinyint NOT NULL, 220 | FiscalYear smallint NOT NULL, 221 | FiscalSemester tinyint NOT NULL 222 | ) 223 | 224 | CREATE TABLE DimDepartmentGroup( 225 | DepartmentGroupKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 226 | ParentDepartmentGroupKey int NULL, 227 | DepartmentGroupName nvarchar(50) NULL 228 | ) 229 | 230 | CREATE TABLE DimSalesTerritory( 231 | SalesTerritoryKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 232 | SalesTerritoryAlternateKey int NULL, 233 | SalesTerritoryRegion nvarchar(50) NOT NULL, 234 | SalesTerritoryCountry nvarchar(50) NOT NULL, 235 | SalesTerritoryGroup nvarchar(50) NULL, 236 | SalesTerritoryImage varbinary(255) NULL 237 | ) 238 | 239 | CREATE TABLE DimEmployee( 240 | EmployeeKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 241 | ParentEmployeeKey int NULL, 242 | EmployeeNationalIDAlternateKey nvarchar(15) NULL, 243 | ParentEmployeeNationalIDAlternateKey nvarchar(15) NULL, 244 | SalesTerritoryKey int NULL, 245 | FirstName nvarchar(50) NOT NULL, 246 | LastName nvarchar(50) NOT NULL, 247 | MiddleName nvarchar(50) NULL, 248 | NameStyle bit NOT NULL, 249 | Title nvarchar(50) NULL, 250 | HireDate date NULL, 251 | BirthDate date NULL, 252 | LoginID nvarchar(256) NULL, 253 | EmailAddress nvarchar(50) NULL, 254 | Phone nvarchar(25) NULL, 255 | MaritalStatus nchar(1) NULL, 256 | EmergencyContactName nvarchar(50) NULL, 257 | EmergencyContactPhone nvarchar(25) NULL, 258 | SalariedFlag bit NULL, 259 | Gender nchar(1) NULL, 260 | PayFrequency tinyint NULL, 261 | BaseRate money NULL, 262 | VacationHours smallint NULL, 263 | SickLeaveHours smallint NULL, 264 | CurrentFlag bit NOT NULL, 265 | SalesPersonFlag bit NOT NULL, 266 | DepartmentName nvarchar(50) NULL, 267 | StartDate date NULL, 268 | EndDate date NULL, 269 | Status nvarchar(50) NULL, 270 | EmployeePhoto varbinary NULL, 271 | FOREIGN KEY (SalesTerritoryKey) REFERENCES DimSalesTerritory(SalesTerritoryKey) 272 | ) 273 | 274 | CREATE TABLE DimGeography( 275 | GeographyKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 276 | City nvarchar(30) NULL, 277 | StateProvinceCode nvarchar(3) NULL, 278 | StateProvinceName nvarchar(50) NULL, 279 | CountryRegionCode nvarchar(3) NULL, 280 | EnglishCountryRegionName nvarchar(50) NULL, 281 | SpanishCountryRegionName nvarchar(50) NULL, 282 | FrenchCountryRegionName nvarchar(50) NULL, 283 | PostalCode nvarchar(15) NULL, 284 | SalesTerritoryKey int NULL, 285 | IpAddressLocator nvarchar(15) NULL, 286 | FOREIGN KEY (SalesTerritoryKey) REFERENCES DimSalesTerritory(SalesTerritoryKey) 287 | ) 288 | 289 | CREATE TABLE DimOrganization( 290 | OrganizationKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 291 | ParentOrganizationKey int NULL, 292 | PercentageOfOwnership nvarchar(16) NULL, 293 | OrganizationName nvarchar(50) NULL, 294 | CurrencyKey int NULL, 295 | FOREIGN KEY (CurrencyKey) REFERENCES DimCurrency(CurrencyKey) 296 | ) 297 | 298 | CREATE TABLE DimProductCategory( 299 | ProductCategoryKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 300 | ProductCategoryAlternateKey int NULL, 301 | EnglishProductCategoryName nvarchar(50) NOT NULL, 302 | SpanishProductCategoryName nvarchar(50) NOT NULL, 303 | FrenchProductCategoryName nvarchar(50) NOT NULL 304 | ) 305 | 306 | CREATE TABLE DimProductSubcategory( 307 | ProductSubcategoryKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 308 | ProductSubcategoryAlternateKey int NULL, 309 | EnglishProductSubcategoryName nvarchar(50) NOT NULL, 310 | SpanishProductSubcategoryName nvarchar(50) NOT NULL, 311 | FrenchProductSubcategoryName nvarchar(50) NOT NULL, 312 | ProductCategoryKey int NULL, 313 | FOREIGN KEY (ProductCategoryKey) REFERENCES DimProductCategory(ProductCategoryKey) 314 | ) 315 | 316 | CREATE TABLE DimProduct( 317 | ProductKey int IDENTITY(1,1) PRIMARY KEY, 318 | ProductAlternateKey nvarchar(25) NULL, 319 | ProductSubcategoryKey int NULL, 320 | WeightUnitMeasureCode nchar(3) NULL, 321 | SizeUnitMeasureCode nchar(3) NULL, 322 | EnglishProductName nvarchar(50) NOT NULL, 323 | SpanishProductName nvarchar(50) NOT NULL, 324 | FrenchProductName nvarchar(50) NOT NULL, 325 | StandardCost money NULL, 326 | FinishedGoodsFlag bit NOT NULL, 327 | Color nvarchar(15) NOT NULL, 328 | SafetyStockLevel smallint NULL, 329 | ReorderPoint smallint NULL, 330 | ListPrice money NULL, 331 | Size nvarchar(50) NULL, 332 | SizeRange nvarchar(50) NULL, 333 | Weight float NULL, 334 | DaysToManufacture int NULL, 335 | ProductLine nchar(2) NULL, 336 | DealerPrice money NULL, 337 | Class nchar(2) NULL, 338 | Style nchar(2) NULL, 339 | ModelName nvarchar(50) NULL, 340 | LargePhoto varbinary NULL, 341 | EnglishDescription nvarchar(400) NULL, 342 | FrenchDescription nvarchar(400) NULL, 343 | ChineseDescription nvarchar(400) NULL, 344 | ArabicDescription nvarchar(400) NULL, 345 | HebrewDescription nvarchar(400) NULL, 346 | ThaiDescription nvarchar(400) NULL, 347 | GermanDescription nvarchar(400) NULL, 348 | JapaneseDescription nvarchar(400) NULL, 349 | TurkishDescription nvarchar(400) NULL, 350 | StartDate datetime NULL, 351 | EndDate datetime NULL, 352 | Status nvarchar(7) NULL, 353 | FOREIGN KEY (ProductSubCategoryKey) REFERENCES DimProductSubCategory(ProductSubCategoryKey) 354 | ) 355 | 356 | CREATE TABLE DimPromotion( 357 | PromotionKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 358 | PromotionAlternateKey int NULL, 359 | EnglishPromotionName nvarchar(255) NULL, 360 | SpanishPromotionName nvarchar(255) NULL, 361 | FrenchPromotionName nvarchar(255) NULL, 362 | DiscountPct float NULL, 363 | EnglishPromotionType nvarchar(50) NULL, 364 | SpanishPromotionType nvarchar(50) NULL, 365 | FrenchPromotionType nvarchar(50) NULL, 366 | EnglishPromotionCategory nvarchar(50) NULL, 367 | SpanishPromotionCategory nvarchar(50) NULL, 368 | FrenchPromotionCategory nvarchar(50) NULL, 369 | StartDate datetime NOT NULL, 370 | EndDate datetime NULL, 371 | MinQty int NULL, 372 | MaxQty int NULL 373 | ) 374 | 375 | CREATE TABLE DimSalesReason( 376 | SalesReasonKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 377 | SalesReasonAlternateKey int NOT NULL, 378 | SalesReasonName nvarchar(50) NOT NULL, 379 | SalesReasonReasonType nvarchar(50) NOT NULL 380 | ) 381 | 382 | CREATE TABLE FactCurrencyRate( 383 | CurrencyKey int NOT NULL, 384 | DateKey int NOT NULL, 385 | AverageRate float NOT NULL, 386 | EndOfDayRate float NOT NULL, 387 | Date datetime NULL, 388 | PRIMARY KEY (CurrencyKey,DateKey), 389 | FOREIGN KEY(DateKey) REFERENCES DimDate(DateKey), 390 | FOREIGN KEY(CurrencyKey) REFERENCES DimCurrency(CurrencyKey) 391 | ) 392 | 393 | CREATE TABLE FactInternetSales( 394 | ProductKey int NOT NULL, 395 | OrderDateKey int NOT NULL, 396 | DueDateKey int NOT NULL, 397 | ShipDateKey int NOT NULL, 398 | CustomerKey int NOT NULL, 399 | PromotionKey int NOT NULL, 400 | CurrencyKey int NOT NULL, 401 | SalesTerritoryKey int NOT NULL, 402 | SalesOrderNumber nvarchar(20) NOT NULL, 403 | SalesOrderLineNumber tinyint NOT NULL, 404 | RevisionNumber tinyint NOT NULL, 405 | OrderQuantity smallint NOT NULL, 406 | UnitPrice money NOT NULL, 407 | ExtendedAmount money NOT NULL, 408 | UnitPriceDiscountPct float NOT NULL, 409 | DiscountAmount float NOT NULL, 410 | ProductStandardCost money NOT NULL, 411 | TotalProductCost money NOT NULL, 412 | SalesAmount money NOT NULL, 413 | TaxAmt money NOT NULL, 414 | Freight money NOT NULL, 415 | CarrierTrackingNumber nvarchar(25) NULL, 416 | CustomerPONumber nvarchar(25) NULL, 417 | OrderDate datetime NULL, 418 | DueDate datetime NULL, 419 | ShipDate datetime NULL, 420 | PRIMARY KEY(SalesOrderNumber,SalesOrderLineNumber), 421 | FOREIGN KEY(CurrencyKey) REFERENCES DimCurrency(CurrencyKey), 422 | FOREIGN KEY(CustomerKey) REFERENCES DimCustomer(CustomerKey), 423 | FOREIGN KEY(OrderDateKey) REFERENCES DimDate(DateKey), 424 | FOREIGN KEY(DueDateKey) REFERENCES DimDate(DateKey), 425 | FOREIGN KEY(ShipDateKey) REFERENCES DimDate(DateKey), 426 | --FOREIGN KEY(ProductKey) REFERENCES DimProduct(ProductKey) 427 | FOREIGN KEY(PromotionKey) REFERENCES DimPromotion(PromotionKey), 428 | FOREIGN KEY(SalesTerritoryKey) REFERENCES DimSalesTerritory(SalesTerritoryKey) 429 | ) 430 | 431 | CREATE TABLE FactInternetSalesReason( 432 | SalesOrderNumber nvarchar(20) NOT NULL, 433 | SalesOrderLineNumber tinyint NOT NULL, 434 | SalesReasonKey int NOT NULL, 435 | PRIMARY KEY (SalesOrderNumber,SalesOrderLineNumber,SalesReasonKey), 436 | FOREIGN KEY(SalesOrderNumber,SalesOrderLineNumber) REFERENCES FactInternetSales(SalesOrderNumber, SalesOrderLineNumber), 437 | FOREIGN KEY(SalesReasonKey) REFERENCES DimSalesReason(SalesReasonKey) 438 | ) 439 | 440 | CREATE TABLE FactSurveyResponse( 441 | SurveyResponseKey int IDENTITY(1,1) NOT NULL PRIMARY KEY, 442 | DateKey int NOT NULL, 443 | CustomerKey int NOT NULL, 444 | ProductCategoryKey int NOT NULL, 445 | EnglishProductCategoryName nvarchar(50) NOT NULL, 446 | ProductSubcategoryKey int NOT NULL, 447 | EnglishProductSubcategoryName nvarchar(50) NOT NULL, 448 | Date datetime NULL, 449 | FOREIGN KEY (DateKey) REFERENCES DimDate(DateKey), 450 | FOREIGN KEY (CustomerKey) REFERENCES DimCustomer(CustomerKey) 451 | 452 | ) 453 | 454 | CREATE TABLE [DimReseller]( 455 | [ResellerKey] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, 456 | [GeographyKey] [int] NULL, 457 | [ResellerAlternateKey] [nvarchar](15) NULL, 458 | [Phone] [nvarchar](25) NULL, 459 | [BusinessType] [varchar](20) NOT NULL, 460 | [ResellerName] [nvarchar](50) NOT NULL, 461 | [NumberEmployees] [int] NULL, 462 | [OrderFrequency] [char](1) NULL, 463 | [OrderMonth] [tinyint] NULL, 464 | [FirstOrderYear] [int] NULL, 465 | [LastOrderYear] [int] NULL, 466 | [ProductLine] [nvarchar](50) NULL, 467 | [AddressLine1] [nvarchar](60) NULL, 468 | [AddressLine2] [nvarchar](60) NULL, 469 | [AnnualSales] [money] NULL, 470 | [BankName] [nvarchar](50) NULL, 471 | [MinPaymentType] [tinyint] NULL, 472 | [MinPaymentAmount] [money] NULL, 473 | [AnnualRevenue] [money] NULL, 474 | [YearOpened] [int] NULL, 475 | FOREIGN KEY (GeographyKey) REFERENCES DimGeography(GeographyKey) 476 | ) 477 | 478 | CREATE TABLE [FactResellerSales]( 479 | [ProductKey] [int] NOT NULL, 480 | [OrderDateKey] [int] NOT NULL, 481 | [DueDateKey] [int] NOT NULL, 482 | [ShipDateKey] [int] NOT NULL, 483 | [ResellerKey] [int] NOT NULL, 484 | [EmployeeKey] [int] NOT NULL, 485 | [PromotionKey] [int] NOT NULL, 486 | [CurrencyKey] [int] NOT NULL, 487 | [SalesTerritoryKey] [int] NOT NULL, 488 | [SalesOrderNumber] [nvarchar](20) NOT NULL, 489 | [SalesOrderLineNumber] [tinyint] NOT NULL, 490 | [RevisionNumber] [tinyint] NULL, 491 | [OrderQuantity] [smallint] NULL, 492 | [UnitPrice] [money] NULL, 493 | [ExtendedAmount] [money] NULL, 494 | [UnitPriceDiscountPct] [float] NULL, 495 | [DiscountAmount] [float] NULL, 496 | [ProductStandardCost] [money] NULL, 497 | [TotalProductCost] [money] NULL, 498 | [SalesAmount] [money] NULL, 499 | [TaxAmt] [money] NULL, 500 | [Freight] [money] NULL, 501 | [CarrierTrackingNumber] [nvarchar](25) NULL, 502 | [CustomerPONumber] [nvarchar](25) NULL, 503 | [OrderDate] [datetime] NULL, 504 | [DueDate] [datetime] NULL, 505 | [ShipDate] [datetime] NULL, 506 | PRIMARY KEY (SalesOrderNumber, SalesOrderLineNumber), 507 | FOREIGN KEY(CurrencyKey) REFERENCES DimCurrency(CurrencyKey), 508 | FOREIGN KEY(OrderDateKey) REFERENCES DimDate(DateKey), 509 | FOREIGN KEY(DueDateKey) REFERENCES DimDate(DateKey), 510 | FOREIGN KEY(ShipDateKey) REFERENCES DimDate(DateKey), 511 | FOREIGN KEY(EmployeeKey) REFERENCES DimEmployee(EmployeeKey), 512 | FOREIGN KEY(ProductKey) REFERENCES DimProduct(ProductKey), 513 | FOREIGN KEY(PromotionKey) REFERENCES DimPromotion(PromotionKey), 514 | FOREIGN KEY(ResellerKey) REFERENCES DimReseller(ResellerKey), 515 | FOREIGN KEY(SalesTerritoryKey) REFERENCES DimSalesTerritory(SalesTerritoryKey) 516 | ) 517 | 518 | -------------------------------------------------------------------------------- /solutions/Chapter 1/adventureworks_docs_v2.html: -------------------------------------------------------------------------------- 1 | 2 |

List of Database tables

3 | ------------ 4 |
5 | DimCurrency DimProductCategory FactInternetSalesReason 6 | DimCustomer DimProductSubcategory FactResellerSales 7 | DimDate DimPromotion FactSurveyResponse 8 | DimDepartmentGroup DimReseller customer_address_us 9 | DimEmployee DimSalesReason customer_email_a 10 | DimGeography DimSalesTerritory vwCUSTOMER_ADDRESS 11 | DimOrganization FactCurrencyRate vwCUSTOMER_BIRTHDATE 12 | DimProduct FactInternetSales 13 |
14 |

DimCurrency

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
cidnametypenotnulldflt_valuepk
0CurrencyKeyint IDENTITY(1,1)11
1CurrencyAlternateKeynchar(3)10
2CurrencyNamenvarchar(50)10
46 |

DimProductCategory

47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |
cidnametypenotnulldflt_valuepk
0ProductCategoryKeyint IDENTITY(1,1)11
1ProductCategoryAlternateKeyint00
2EnglishProductCategoryNamenvarchar(50)10
3SpanishProductCategoryNamenvarchar(50)10
4FrenchProductCategoryNamenvarchar(50)10
92 |

FactInternetSalesReason

93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 |
cidnametypenotnulldflt_valuepk
0ProductKeyint10
1OrderDateKeyint10
2DueDateKeyint10
3ShipDateKeyint10
4CustomerKeyint10
5PromotionKeyint10
6CurrencyKeyint10
7SalesTerritoryKeyint10
8SalesOrderNumbernvarchar(20)11
9SalesOrderLineNumbertinyint12
10RevisionNumbertinyint10
11OrderQuantitysmallint10
12UnitPricemoney10
13ExtendedAmountmoney10
14UnitPriceDiscountPctfloat10
15DiscountAmountfloat10
16ProductStandardCostmoney10
17TotalProductCostmoney10
18SalesAmountmoney10
19TaxAmtmoney10
20Freightmoney10
21CarrierTrackingNumbernvarchar(25)00
22CustomerPONumbernvarchar(25)00
23OrderDatedatetime00
24DueDatedatetime00
25ShipDatedatetime00
285 |

DimCustomer

286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 |
cidnametypenotnulldflt_valuepk
0CustomerKeyint IDENTITY(1,1)11
1GeographyKeyint00
2CustomerAlternateKeynvarchar(15)10
3Titlenvarchar(8)00
4FirstNamenvarchar(50)00
5MiddleNamenvarchar(50)00
6LastNamenvarchar(50)00
7NameStylebit00
8BirthDatedate00
9MaritalStatusnchar(1)00
10Suffixnvarchar(10)00
11Gendernvarchar(1)00
12EmailAddressnvarchar(50)00
13YearlyIncomemoney00
14TotalChildrentinyint00
15NumberChildrenAtHometinyint00
16EnglishEducationnvarchar(40)00
17SpanishEducationnvarchar(40)00
18FrenchEducationnvarchar(40)00
19EnglishOccupationnvarchar(100)00
20SpanishOccupationnvarchar(100)00
21FrenchOccupationnvarchar(100)00
22HouseOwnerFlagnchar(1)00
23NumberCarsOwnedtinyint00
24AddressLine1nvarchar(120)00
25AddressLine2nvarchar(120)00
26Phonenvarchar(20)00
27DateFirstPurchasedate00
28CommuteDistancenvarchar(15)00
499 |

DimProductSubcategory

500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 |
cidnametypenotnulldflt_valuepk
0ProductSubcategoryKeyint IDENTITY(1,1)11
1ProductSubcategoryAlternateKeyint00
2EnglishProductSubcategoryNamenvarchar(50)10
3SpanishProductSubcategoryNamenvarchar(50)10
4FrenchProductSubcategoryNamenvarchar(50)10
5ProductCategoryKeyint00
552 |

FactResellerSales

553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 |
cidnametypenotnulldflt_valuepk
0ProductKeyint10
1OrderDateKeyint10
2DueDateKeyint10
3ShipDateKeyint10
4ResellerKeyint10
5EmployeeKeyint10
6PromotionKeyint10
7CurrencyKeyint10
8SalesTerritoryKeyint10
9SalesOrderNumbernvarchar11
10SalesOrderLineNumbertinyint12
11RevisionNumbertinyint00
12OrderQuantitysmallint00
13UnitPricemoney00
14ExtendedAmountmoney00
15UnitPriceDiscountPctfloat00
16DiscountAmountfloat00
17ProductStandardCostmoney00
18TotalProductCostmoney00
19SalesAmountmoney00
20TaxAmtmoney00
21Freightmoney00
22CarrierTrackingNumbernvarchar00
23CustomerPONumbernvarchar00
24OrderDatedatetime00
25DueDatedatetime00
26ShipDatedatetime00
752 |

DimDate

753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 |
cidnametypenotnulldflt_valuepk
0DateKeyint11
1FullDateAlternateKeydate10
2DayNumberOfWeektinyint10
3EnglishDayNameOfWeeknvarchar(10)10
4SpanishDayNameOfWeeknvarchar(10)10
5FrenchDayNameOfWeeknvarchar(10)10
6DayNumberOfMonthtinyint10
7DayNumberOfYearsmallint10
8WeekNumberOfYeartinyint10
9EnglishMonthNamenvarchar(10)10
10SpanishMonthNamenvarchar(10)10
11FrenchMonthNamenvarchar(10)10
12MonthNumberOfYeartinyint10
13CalendarQuartertinyint10
14CalendarYearsmallint10
15CalendarSemestertinyint10
16FiscalQuartertinyint10
17FiscalYearsmallint10
18FiscalSemestertinyint10
896 |

DimPromotion

897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 |
cidnametypenotnulldflt_valuepk
0PromotionKeyint IDENTITY(1,1)11
1PromotionAlternateKeyint00
2EnglishPromotionNamenvarchar(255)00
3SpanishPromotionNamenvarchar(255)00
4FrenchPromotionNamenvarchar(255)00
5DiscountPctfloat00
6EnglishPromotionTypenvarchar(50)00
7SpanishPromotionTypenvarchar(50)00
8FrenchPromotionTypenvarchar(50)00
9EnglishPromotionCategorynvarchar(50)00
10SpanishPromotionCategorynvarchar(50)00
11FrenchPromotionCategorynvarchar(50)00
12StartDatedatetime10
13EndDatedatetime00
14MinQtyint00
15MaxQtyint00
1019 |

FactSurveyResponse

1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 |
cidnametypenotnulldflt_valuepk
0SurveyResponseKeyint IDENTITY(1,1)11
1DateKeyint10
2CustomerKeyint10
3ProductCategoryKeyint10
4EnglishProductCategoryNamenvarchar(50)10
5ProductSubcategoryKeyint10
6EnglishProductSubcategoryNamenvarchar(50)10
7Datedatetime00
1086 |

DimDepartmentGroup

1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 |
cidnametypenotnulldflt_valuepk
0DepartmentGroupKeyint IDENTITY(1,1)11
1ParentDepartmentGroupKeyint00
2DepartmentGroupNamenvarchar(50)00
1118 |

DimReseller

1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 |
cidnametypenotnulldflt_valuepk
0ResellerKeyint11
1GeographyKeyint00
2ResellerAlternateKeynvarchar00
3Phonenvarchar00
4BusinessTypevarchar10
5ResellerNamenvarchar10
6NumberEmployeesint00
7OrderFrequencychar00
8OrderMonthtinyint00
9FirstOrderYearint00
10LastOrderYearint00
11ProductLinenvarchar00
12AddressLine1nvarchar00
13AddressLine2nvarchar00
14AnnualSalesmoney00
15BankNamenvarchar00
16MinPaymentTypetinyint00
17MinPaymentAmountmoney00
18AnnualRevenuemoney00
19YearOpenedint00
1269 |

DimEmployee

1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | 1476 | 1477 | 1478 | 1479 | 1480 | 1481 | 1482 | 1483 | 1484 | 1485 | 1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | 1494 | 1495 | 1496 |
cidnametypenotnulldflt_valuepk
0EmployeeKeyint IDENTITY(1,1)11
1ParentEmployeeKeyint00
2EmployeeNationalIDAlternateKeynvarchar(15)00
3ParentEmployeeNationalIDAlternateKeynvarchar(15)00
4SalesTerritoryKeyint00
5FirstNamenvarchar(50)10
6LastNamenvarchar(50)10
7MiddleNamenvarchar(50)00
8NameStylebit10
9Titlenvarchar(50)00
10HireDatedate00
11BirthDatedate00
12LoginIDnvarchar(256)00
13EmailAddressnvarchar(50)00
14Phonenvarchar(25)00
15MaritalStatusnchar(1)00
16EmergencyContactNamenvarchar(50)00
17EmergencyContactPhonenvarchar(25)00
18SalariedFlagbit00
19Gendernchar(1)00
20PayFrequencytinyint00
21BaseRatemoney00
22VacationHourssmallint00
23SickLeaveHourssmallint00
24CurrentFlagbit10
25SalesPersonFlagbit10
26DepartmentNamenvarchar(50)00
27StartDatedate00
28EndDatedate00
29Statusnvarchar(50)00
30EmployeePhotovarbinary00
1497 |

DimSalesReason

1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1511 | 1512 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 |
cidnametypenotnulldflt_valuepk
0SalesReasonKeyint IDENTITY(1,1)11
1SalesReasonAlternateKeyint10
2SalesReasonNamenvarchar(50)10
3SalesReasonReasonTypenvarchar(50)10
1536 |

DimGeography

1537 | 1538 | 1539 | 1540 | 1541 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 | 1553 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | 1560 | 1561 | 1562 | 1563 | 1564 | 1565 | 1566 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1595 | 1596 | 1597 | 1598 | 1599 | 1600 | 1601 | 1602 | 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | 1620 | 1621 | 1622 | 1623 |
cidnametypenotnulldflt_valuepk
0GeographyKeyint IDENTITY(1,1)11
1Citynvarchar(30)00
2StateProvinceCodenvarchar(3)00
3StateProvinceNamenvarchar(50)00
4CountryRegionCodenvarchar(3)00
5EnglishCountryRegionNamenvarchar(50)00
6SpanishCountryRegionNamenvarchar(50)00
7FrenchCountryRegionNamenvarchar(50)00
8PostalCodenvarchar(15)00
9SalesTerritoryKeyint00
10IpAddressLocatornvarchar(15)00
1624 |

DimSalesTerritory

1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 | 1633 | 1634 | 1635 | 1636 | 1637 | 1638 | 1639 | 1640 | 1641 | 1642 | 1643 | 1644 | 1645 | 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | 1655 | 1656 | 1657 | 1658 | 1659 | 1660 | 1661 | 1662 | 1663 | 1664 | 1665 | 1666 | 1667 | 1668 | 1669 | 1670 | 1671 | 1672 | 1673 | 1674 | 1675 | 1676 |
cidnametypenotnulldflt_valuepk
0SalesTerritoryKeyint IDENTITY(1,1)11
1SalesTerritoryAlternateKeyint00
2SalesTerritoryRegionnvarchar(50)10
3SalesTerritoryCountrynvarchar(50)10
4SalesTerritoryGroupnvarchar(50)00
5SalesTerritoryImagevarbinary(255)00
1677 |

DimOrganization

1678 | 1679 | 1680 | 1681 | 1682 | 1683 | 1684 | 1685 | 1686 | 1687 | 1688 | 1689 | 1690 | 1691 | 1692 | 1693 | 1694 | 1695 | 1696 | 1697 | 1698 | 1699 | 1700 | 1701 | 1702 | 1703 | 1704 | 1705 | 1706 | 1707 | 1708 | 1709 | 1710 | 1711 | 1712 | 1713 | 1714 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1722 |
cidnametypenotnulldflt_valuepk
0OrganizationKeyint IDENTITY(1,1)11
1ParentOrganizationKeyint00
2PercentageOfOwnershipnvarchar(16)00
3OrganizationNamenvarchar(50)00
4CurrencyKeyint00
1723 |

FactCurrencyRate

1724 | 1725 | 1726 | 1727 | 1728 | 1729 | 1730 | 1731 | 1732 | 1733 | 1734 | 1735 | 1736 | 1737 | 1738 | 1739 | 1740 | 1741 | 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1750 | 1751 | 1752 | 1753 | 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1764 | 1765 | 1766 | 1767 | 1768 |
cidnametypenotnulldflt_valuepk
0CurrencyKeyint11
1DateKeyint12
2AverageRatefloat10
3EndOfDayRatefloat10
4Datedatetime00
1769 |

DimProduct

1770 | 1771 | 1772 | 1773 | 1774 | 1775 | 1776 | 1777 | 1778 | 1779 | 1780 | 1781 | 1782 | 1783 | 1784 | 1785 | 1786 | 1787 | 1788 | 1789 | 1790 | 1791 | 1792 | 1793 | 1794 | 1795 | 1796 | 1797 | 1798 | 1799 | 1800 | 1801 | 1802 | 1803 | 1804 | 1805 | 1806 | 1807 | 1808 | 1809 | 1810 | 1811 | 1812 | 1813 | 1814 | 1815 | 1816 | 1817 | 1818 | 1819 | 1820 | 1821 | 1822 | 1823 | 1824 | 1825 | 1826 | 1827 | 1828 | 1829 | 1830 | 1831 | 1832 | 1833 | 1834 | 1835 | 1836 | 1837 | 1838 | 1839 | 1840 | 1841 | 1842 | 1843 | 1844 | 1845 | 1846 | 1847 | 1848 | 1849 | 1850 | 1851 | 1852 | 1853 | 1854 | 1855 | 1856 | 1857 | 1858 | 1859 | 1860 | 1861 | 1862 | 1863 | 1864 | 1865 | 1866 | 1867 | 1868 | 1869 | 1870 | 1871 | 1872 | 1873 | 1874 | 1875 | 1876 | 1877 | 1878 | 1879 | 1880 | 1881 | 1882 | 1883 | 1884 | 1885 | 1886 | 1887 | 1888 | 1889 | 1890 | 1891 | 1892 | 1893 | 1894 | 1895 | 1896 | 1897 | 1898 | 1899 | 1900 | 1901 | 1902 | 1903 | 1904 | 1905 | 1906 | 1907 | 1908 | 1909 | 1910 | 1911 | 1912 | 1913 | 1914 | 1915 | 1916 | 1917 | 1918 | 1919 | 1920 | 1921 | 1922 | 1923 | 1924 | 1925 | 1926 | 1927 | 1928 | 1929 | 1930 | 1931 | 1932 | 1933 | 1934 | 1935 | 1936 | 1937 | 1938 | 1939 | 1940 | 1941 | 1942 | 1943 | 1944 | 1945 | 1946 | 1947 | 1948 | 1949 | 1950 | 1951 | 1952 | 1953 | 1954 | 1955 | 1956 | 1957 | 1958 | 1959 | 1960 | 1961 | 1962 | 1963 | 1964 | 1965 | 1966 | 1967 | 1968 | 1969 | 1970 | 1971 | 1972 | 1973 | 1974 | 1975 | 1976 | 1977 | 1978 | 1979 | 1980 | 1981 | 1982 | 1983 | 1984 | 1985 | 1986 | 1987 | 1988 | 1989 | 1990 | 1991 | 1992 | 1993 | 1994 | 1995 | 1996 | 1997 | 1998 | 1999 | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | 2027 | 2028 | 2029 | 2030 | 2031 |
cidnametypenotnulldflt_valuepk
0ProductKeyint IDENTITY(1,1)01
1ProductAlternateKeynvarchar(25)00
2ProductSubcategoryKeyint00
3WeightUnitMeasureCodenchar(3)00
4SizeUnitMeasureCodenchar(3)00
5EnglishProductNamenvarchar(50)10
6SpanishProductNamenvarchar(50)10
7FrenchProductNamenvarchar(50)10
8StandardCostmoney00
9FinishedGoodsFlagbit10
10Colornvarchar(15)10
11SafetyStockLevelsmallint00
12ReorderPointsmallint00
13ListPricemoney00
14Sizenvarchar(50)00
15SizeRangenvarchar(50)00
16Weightfloat00
17DaysToManufactureint00
18ProductLinenchar(2)00
19DealerPricemoney00
20Classnchar(2)00
21Stylenchar(2)00
22ModelNamenvarchar(50)00
23LargePhotovarbinary00
24EnglishDescriptionnvarchar(400)00
25FrenchDescriptionnvarchar(400)00
26ChineseDescriptionnvarchar(400)00
27ArabicDescriptionnvarchar(400)00
28HebrewDescriptionnvarchar(400)00
29ThaiDescriptionnvarchar(400)00
30GermanDescriptionnvarchar(400)00
31JapaneseDescriptionnvarchar(400)00
32TurkishDescriptionnvarchar(400)00
33StartDatedatetime00
34EndDatedatetime00
35Statusnvarchar(7)00
2032 |

FactInternetSales

2033 | 2034 | 2035 | 2036 | 2037 | 2038 | 2039 | 2040 | 2041 | 2042 | 2043 | 2044 | 2045 | 2046 | 2047 | 2048 | 2049 | 2050 | 2051 | 2052 | 2053 | 2054 | 2055 | 2056 | 2057 | 2058 | 2059 | 2060 | 2061 | 2062 | 2063 | 2064 | 2065 | 2066 | 2067 | 2068 | 2069 | 2070 | 2071 | 2072 | 2073 | 2074 | 2075 | 2076 | 2077 | 2078 | 2079 | 2080 | 2081 | 2082 | 2083 | 2084 | 2085 | 2086 | 2087 | 2088 | 2089 | 2090 | 2091 | 2092 | 2093 | 2094 | 2095 | 2096 | 2097 | 2098 | 2099 | 2100 | 2101 | 2102 | 2103 | 2104 | 2105 | 2106 | 2107 | 2108 | 2109 | 2110 | 2111 | 2112 | 2113 | 2114 | 2115 | 2116 | 2117 | 2118 | 2119 | 2120 | 2121 | 2122 | 2123 | 2124 | 2125 | 2126 | 2127 | 2128 | 2129 | 2130 | 2131 | 2132 | 2133 | 2134 | 2135 | 2136 | 2137 | 2138 | 2139 | 2140 | 2141 | 2142 | 2143 | 2144 | 2145 | 2146 | 2147 | 2148 | 2149 | 2150 | 2151 | 2152 | 2153 | 2154 | 2155 | 2156 | 2157 | 2158 | 2159 | 2160 | 2161 | 2162 | 2163 | 2164 | 2165 | 2166 | 2167 | 2168 | 2169 | 2170 | 2171 | 2172 | 2173 | 2174 | 2175 | 2176 | 2177 | 2178 | 2179 | 2180 | 2181 | 2182 | 2183 | 2184 | 2185 | 2186 | 2187 | 2188 | 2189 | 2190 | 2191 | 2192 | 2193 | 2194 | 2195 | 2196 | 2197 | 2198 | 2199 | 2200 | 2201 | 2202 | 2203 | 2204 | 2205 | 2206 | 2207 | 2208 | 2209 | 2210 | 2211 | 2212 | 2213 | 2214 | 2215 | 2216 | 2217 | 2218 | 2219 | 2220 | 2221 | 2222 | 2223 | 2224 |
cidnametypenotnulldflt_valuepk
0ProductKeyint10
1OrderDateKeyint10
2DueDateKeyint10
3ShipDateKeyint10
4CustomerKeyint10
5PromotionKeyint10
6CurrencyKeyint10
7SalesTerritoryKeyint10
8SalesOrderNumbernvarchar(20)11
9SalesOrderLineNumbertinyint12
10RevisionNumbertinyint10
11OrderQuantitysmallint10
12UnitPricemoney10
13ExtendedAmountmoney10
14UnitPriceDiscountPctfloat10
15DiscountAmountfloat10
16ProductStandardCostmoney10
17TotalProductCostmoney10
18SalesAmountmoney10
19TaxAmtmoney10
20Freightmoney10
21CarrierTrackingNumbernvarchar(25)00
22CustomerPONumbernvarchar(25)00
23OrderDatedatetime00
24DueDatedatetime00
25ShipDatedatetime00
2225 | 2226 | -------------------------------------------------------------------------------- /solutions/Chapter 1/create_documentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sqlite3 ../../AdventureWorks.db << EOF 3 | .mode html 4 | .output adventureworks_docs_v2.html 5 | .headers on 6 | .print 7 | .print

List of Database tables

8 | .print ------------ 9 | .print
10 | .tables 11 | .print
12 | .print

DimCurrency

13 | .print 14 | .print 15 | PRAGMA table_info('DimCurrency'); 16 | .print
17 | .print

DimProductCategory

18 | .print 19 | .print 20 | PRAGMA table_info('DimProductCategory'); 21 | .print
22 | .print

FactInternetSalesReason

23 | .print 24 | .print 25 | PRAGMA table_info('FactInternetSales'); 26 | .print
27 | .print

DimCustomer

28 | .print 29 | .print 30 | PRAGMA table_info('DimCustomer'); 31 | .print
32 | .print

DimProductSubcategory

33 | .print 34 | .print 35 | PRAGMA table_info('DimProductSubCategory'); 36 | .print
37 | .print

FactResellerSales

38 | .print 39 | .print 40 | PRAGMA table_info('FactResellerSales'); 41 | .print
42 | .print

DimDate

43 | .print 44 | .print 45 | PRAGMA table_info('DimDate'); 46 | .print
47 | .print

DimPromotion

48 | .print 49 | .print 50 | PRAGMA table_info('DimPromotion'); 51 | .print
52 | .print

FactSurveyResponse

53 | .print 54 | .print 55 | PRAGMA table_info('FactSurveyResponse'); 56 | .print
57 | .print

DimDepartmentGroup

58 | .print 59 | .print 60 | PRAGMA table_info('DimDepartmentGroup'); 61 | .print
62 | .print

DimReseller

63 | .print 64 | .print 65 | PRAGMA table_info('DimReseller'); 66 | .print
67 | .print

DimEmployee

68 | .print 69 | .print 70 | PRAGMA table_info('DimEmployee'); 71 | .print
72 | .print

DimSalesReason

73 | .print 74 | .print 75 | PRAGMA table_info('DimSalesReason'); 76 | .print
77 | .print

DimGeography

78 | .print 79 | .print 80 | PRAGMA table_info('DimGeography'); 81 | .print
82 | .print

DimSalesTerritory

83 | .print 84 | .print 85 | PRAGMA table_info('DimSalesTerritory'); 86 | .print
87 | .print

DimOrganization

88 | .print 89 | .print 90 | PRAGMA table_info('DimOrganization'); 91 | .print
92 | .print

FactCurrencyRate

93 | .print 94 | .print 95 | PRAGMA table_info('FactCurrencyRate'); 96 | .print
97 | .print

DimProduct

98 | .print 99 | .print 100 | PRAGMA table_info('DimProduct'); 101 | .print
102 | .print

FactInternetSales

103 | .print 104 | .print 105 | PRAGMA table_info('FactInternetSales'); 106 | .print
107 | .print 108 | .quit 109 | EOF -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.3.2.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* 3 | from vwCUSTOMER_BIRTHDATE a 4 | INNER JOIN vwCUSTOMER_ADDRESS b 5 | ON a.CustomerKey = b.CustomerKey -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.3.3.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* from 3 | DimCustomer a 4 | INNER JOIN 5 | FactInternetSales b 6 | ON a.CustomerKey = b.CustomerKey 7 | ORDER By a.CustomerKey; -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.3.4.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* from 3 | FactInternetSales a 4 | INNER JOIN 5 | DimCustomer b 6 | ON a.CustomerKey = b.CustomerKey 7 | ORDER By a.CustomerKey; -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.3.5.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* 3 | FROM 4 | FactInternetSales a 5 | INNER JOIN 6 | FactSurveyResponse b 7 | ON 8 | a.OrderDate = b.Date -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.3.sql: -------------------------------------------------------------------------------- 1 | -- SQLite Chapter 2.3 2 | 3 | -- create views 4 | create view vwCUSTOMER_ADDRESS 5 | as SELECT 6 | CustomerKey, 7 | AddressLine1, 8 | AddressLine2, 9 | GeographyKey 10 | FROM 11 | DimCustomer; 12 | 13 | CREATE view vwCUSTOMER_BIRTHDATE 14 | AS SELECT 15 | CustomerKey, 16 | Title, 17 | FirstName, 18 | MiddleName, 19 | LastName, 20 | NameStyle, 21 | BirthDate 22 | FROM 23 | DimCustomer; 24 | 25 | -------------------------------------------------------------------------------- /solutions/Chapter 2/Chapter 2.6.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | Select E.EmployeeKey as EmployeeKey, 3 | E. FirstName as Employee_First_Name, 4 | E.LastName as Employee_Last_Name, 5 | M.FirstName as Manager_First_Name, 6 | M.LastName as Manager_Last_Name 7 | from DimEmployee E 8 | join DimEmployee M 9 | on E.ParentEmployeeKey = M.EmployeeKey; -------------------------------------------------------------------------------- /solutions/Chapter 3/3.3.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | select C.CustomerKey, 3 | C.FirstName, 4 | C.LastName, 5 | A.EmailAddress, 6 | B.GeographyKey 7 | from 8 | DimCustomer C 9 | LEFT JOIN customer_email_a as A 10 | ON C.CustomerKey = A.CustomerKEY 11 | LEFT JOIN customer_address_us as B 12 | ON C.CustomerKey = B.CustomerKEY -------------------------------------------------------------------------------- /solutions/Chapter 3/3.3.2.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT p.ProductKey, 3 | sum(s.SalesAmount) as Sum_of_Sales 4 | from DimProduct p 5 | left join FactInternetSales s using(ProductKey) 6 | group by p.ProductKey 7 | -------------------------------------------------------------------------------- /solutions/Chapter 3/3.3.3.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | select DimProduct.ProductKey, 3 | DimProduct.EnglishProductName, 4 | FactInternetSales.OrderDate, 5 | FactInternetSales.OrderQuantity, 6 | FactInternetSales.SalesAmount 7 | from DimProduct 8 | left join FactInternetSales 9 | on DimProduct.ProductKey = FactInternetSales.ProductKey 10 | order by DimProduct.ProductKey; -------------------------------------------------------------------------------- /solutions/Chapter 3/3.5.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | Select 3 | ResellerName, 4 | AddressLine1, 5 | AddressLine2, 6 | G.City, 7 | G.StateProvinceCode, 8 | G.PostalCode, 9 | G.CountryRegionCode, 10 | S.ProductKey, 11 | P.ProductSubcategoryKey, 12 | S.SalesAmount 13 | FROM 14 | DimReseller as R 15 | LEFT JOIN FactResellerSales as S 16 | ON R.ResellerKey = S.ResellerKey 17 | INNER JOIN DimGeography as G 18 | ON R.GeographyKey = G.GeographyKey 19 | LEFT JOIN DimProduct as P 20 | ON S.ProductKey = P.ProductKey 21 | WHERE G.CountryRegionCode = 'US' 22 | ORDER BY S.SalesAmount ASC -------------------------------------------------------------------------------- /solutions/Chapter 4/4.3.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | Select p.ProductKey, 3 | p.EnglishProductName, s.* 4 | FROM DimProduct p 5 | LEFT JOIN FactInternetSales s ON p.ProductKey = s.ProductKey; -------------------------------------------------------------------------------- /solutions/Chapter 4/4.3.2.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT 3 | p.ProductKey, 4 | p.EnglishProductName, 5 | s.* 6 | FROM FactInternetSales s 7 | LEFT JOIN DimProduct p ON p.ProductKey = s.ProductKey; -------------------------------------------------------------------------------- /solutions/Chapter 4/4.3.3.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | select * from DimProduct where productkey = 480; -------------------------------------------------------------------------------- /solutions/Chapter 4/4.5.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | SELECT a.*, b.* 3 | FROM 4 | customer_address_us a 5 | LEFT JOIN FactInternetSales b 6 | ON a.CustomerKey = b.CustomerKey 7 | UNION 8 | SELECT a.*, b.* 9 | FROM 10 | FactInternetSales b 11 | LEFT JOIN customer_address_us a 12 | ON a.CustomerKey = b.CustomerKey -------------------------------------------------------------------------------- /solutions/Chapter 5/5.3.1.sql: -------------------------------------------------------------------------------- 1 | -- SQLite 2 | Select * 3 | from DimCurrency CROSS JOIN DimDepartmentGroup; --------------------------------------------------------------------------------