\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{datamansam} \pdfinfo{ /Title (database-modelling.pdf) /Creator (Cheatography) /Author (datamansam) /Subject (DataBase modelling Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{DataBase modelling Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{datamansam} via \textcolor{DarkBackground}{\uline{cheatography.com/139410/cs/29956/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}datamansam \\ \uline{cheatography.com/datamansam} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 25th May, 2022.\\ Updated 25th May, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Models}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Conceptual}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Highest-level, Important entities and the relationships among them.} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} No attribute is specified. & No primary key is specified. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Logical}}} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Data in as much detail as possible, without regard to how they will be physical implemented in the database} \tn % Row Count 9 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\{\{Steps:\}\}} \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{1, Specify primary keys for all entities.} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{2, Find the relationships between different entities.} \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{3, Find all attributes for each entity.} \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} 4. Resolve many-to-many relationships. & separate the two entities and create two one-to-many (1:n) relationships between them with a third intersect entity. \tn % Row Count 20 (+ 6) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{5, Normalization.} \tn % Row Count 21 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Physical}}} \tn % Row Count 22 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{How the model will be built in the database.} \tn % Row Count 23 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{A physical database model shows all table structures, including column name, column data type, column constraints, primary key, foreign key, and relationships between tables.} \tn % Row Count 27 (+ 4) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Convert entities into tables.} \tn % Row Count 28 (+ 1) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Convert relationships into foreign keys.} \tn % Row Count 29 (+ 1) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Convert attributes into columns.} \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Models (cont)}} \tn % Row 17 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Modify the physical data model based on physical constraints / requirements.} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.54747 cm} x{4.42953 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Partitioning Tables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Use Case:} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{As our data scales, queries/updates may not always fit into memory} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Horizontal Partitioning:} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Splitting a table by rows} \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} Pros: & Indices of heavily-used partitions fit in memory; Supports OLAP and OLTP \tn % Row Count 8 (+ 3) % Row 5 \SetRowColor{white} Cons: & Partitioning existing table can be a hassle; Some constraints can not be set \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Horizontal partitioning}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{ATE TABLE sales ( \newline ... \newline timestamp DATE NOT NULL \newline ) \newline PARTITION BY RANGE (timestamp); \newline CREATE TABLE sales\_2019\_q1 PARTITION OF sales \newline FOR VALUES FROM ('2019-01-01') TO ('2019-03-31'); \newline ... \newline CREATE TABLE sales\_2019\_q4 PARTITION OF sales \newline FOR VALUES FROM ('2019-09-01') TO ('2019-12-31'); \newline CREATE INDEX ON sales ('timestamp')} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Sharding}} \tn % Row 0 \SetRowColor{LightBackground} sharding implies the data is spread across multiple computers while partitioning does not & Partitioning is about grouping subsets of data within a single database instance \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Sharding and partitioning are both about breaking up a large data set into smaller subsets.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Models: Diagramitic Overview}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/datamansam_1638143119_Model LCP.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Models: Tablular Overivew}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/datamansam_1638143208_Model LCP table.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SSAS}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Has a three-tier architecture} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{RDBMS: The data from different sources like Excel, Database, Text, others can be pulled with the help of ETL tool into the RDBMS.} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{SSAS: Aggregate data from RDBMS is pushed into SSAS cubes by using analysis services projects. The SSAS cubes will create an analysis database, and once the analysis database is ready, it can be used for many purposes.} \tn % Row Count 9 (+ 5) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Client: Clients can access data using Dashboards, Scorecards, Portals etc.} \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} A cube is a basic unit of storage & It is a collection of data which has been aggregated to allow queries to return data quickly. \tn % Row Count 16 (+ 5) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{The MOLAP is made of data cube which contains of measures and dimensions} \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} Dimension Table & contains dimensions, or characteristics (who, what, where), of a fact. \tn % Row Count 22 (+ 4) % Row 7 \SetRowColor{white} & Joined to fact table with a foreign key \tn % Row Count 24 (+ 2) % Row 8 \SetRowColor{LightBackground} & de-normalized tables. \tn % Row Count 26 (+ 2) % Row 9 \SetRowColor{white} A fact table is the most important table in a dimensional model. & A Fact Table contains Measurements/fact and Foreign key to the dimension table. For example, payroll operations. \tn % Row Count 32 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SSAS (cont)}} \tn % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Two SSAS model types} \tn % Row Count 1 (+ 1) % Row 11 \SetRowColor{white} Multi-Dimensional Data Model & consists of a data cube. It is a group of operations which allows you to query the value of cells by using cube and dimension members as coordinates. \tn % Row Count 9 (+ 8) % Row 12 \SetRowColor{LightBackground} & rules which decide the way that measure values are rolled up within hierarchies \tn % Row Count 13 (+ 4) % Row 13 \SetRowColor{white} Tabular modeling organizes data into related tables. & The table doesn't designate as "dimensions" or "facts" and development time is less with tabular because of all related tables able to serve both roles. \tn % Row Count 22 (+ 9) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.87965 cm} x{0.87717 cm} x{0.87717 cm} p{0.54301 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{No SQL databases}} \tn % Row 0 \SetRowColor{LightBackground} Key - Value Stores & \seqsplit{Document} & \seqsplit{Columnar} & Graph \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{OLAP}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{On-Line Analytical Processing.} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} OLAP is Multidimensional & Providing ability to analyze metrics in different dimensions such as time, geography, gender, product, etc \tn % Row Count 7 (+ 6) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{For example, sales for the company are up. What region is most responsible for this increase? Which store in this region is most responsible for the increase?} \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{For example, sales for the company are up:} \tn % Row Count 12 (+ 1) % Row 4 \SetRowColor{LightBackground} What region is most responsible for this increase? & Which store in this region is most responsible for the increase? \tn % Row Count 16 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SSRS}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Microsoft SQL Server has three types of SQL Services} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Microsoft SQL Server Integration services which integrate data from different sources.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Microsoft SQL Server Analytical service which helps for the analysis of the data} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Microsoft SQL Server Reporting service allows for generating a visual report of the data.} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{SSRS data sources} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Retrieve data from managed, OLE ODBC, and DB connections} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Display data in a variety of formats which includes tabular, free-form, and charts} \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Reporting Life Cylce} \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Authoring: In this phase, the report author defines the layout and syntax of the data. The tools used in this process are the SQL Server Development Studio and SSRS tool.} \tn % Row Count 18 (+ 4) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Management: This phase involves managing a published report which is mostly part of the websites. In this stage, you need to consider access control over report execution.} \tn % Row Count 22 (+ 4) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Delivery: In this phase, you need to understand when the reports need to be delivered to the customer base. Delivery can be on-demand or pre-defined schedule. You can also add an automation feature of subscription which creates reports and sends to the customer automatically} \tn % Row Count 28 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}