\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{abirjepatil} \pdfinfo{ /Title (db.pdf) /Creator (Cheatography) /Author (abirjepatil) /Subject (db 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{db Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{abirjepatil} via \textcolor{DarkBackground}{\uline{cheatography.com/20522/cs/3283/}}} \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}abirjepatil \\ \uline{cheatography.com/abirjepatil} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 7th February, 2015.\\ Updated 13th May, 2016.\\ 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*}{4} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{key constraints}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{one to many, many to many etc. the direction of the arrow is pointed where 'one' refers, attribute types :- composite attributes.multivalued attributes.derived attributes. Generalization : composing two or more entities together. specialization reverse of generalization. Disjoint :- user can be a member of at most one entity. overlap just opposite. total atleast one. disjoint can be present in both.partial.% Row Count 9 (+ 9) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Participation Constraints}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{total or partial. represented by bold lines.% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{superkey and candidate key}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{superkey one or more attributes together. candidate key is a minimal superkey. an entity that has a primary key is called as a strong entity. the entity whose primary key is being used is called as the identifying owner.% Row Count 5 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{JDBC Application Programming}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Client - Server Architecture . 2 tier and 3 tier architecture. \newline % Row Count 2 (+ 2) ODBC: Open Database Connectivity.JDBC located in java.sql package. \newline % Row Count 4 (+ 2) JDBC-ODBC bridge • Con: ODBC must be installed \newline % Row Count 5 (+ 1) • JDBC database client • Con: JDBC driver for each server must be available \newline % Row Count 7 (+ 2) • JDBC middleware client • Pro: Only one JDBC driver is required • Application does not need direct connection% Row Count 10 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{JDBC Steps}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{1. Load the driver 2. Define the Connection URL 3. Establish the Connection 4. Create a Statement object 5. Execute a query 6. Process the results 7. Close the Connection \newline % Row Count 4 (+ 4) {\bf{ commit () rollback() getMetaDataObject getwarnings()}}. \newline % Row Count 6 (+ 2) ResultSetMetaData answers the following questions: \newline % Row Count 8 (+ 2) • How many columns are in the result set? \newline % Row Count 9 (+ 1) • What is the name of a given column? \newline % Row Count 10 (+ 1) • Are the column names case sensitive? \newline % Row Count 11 (+ 1) • What is the data type of a specific column? \newline % Row Count 12 (+ 1) • What is the maximum character size of a column? \newline % Row Count 14 (+ 2) • Can you search on a given column?% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Query}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{insert into table name values (select statement). Aggregation {[}MAX,MIN,AVG,COUNT,SUM{]} \newline % Row Count 2 (+ 2) SELECT product, Sum(price*quantity) AS TotalSales \newline % Row Count 3 (+ 1) FROM Purchase \newline % Row Count 4 (+ 1) WHERE date \textgreater{} "10/1" \newline % Row Count 5 (+ 1) GROUP BY product \newline % Row Count 6 (+ 1) without group by \newline % Row Count 7 (+ 1) SELECT DISTINCT x.product, (SELECT Sum(y.price*y.quantity) \newline % Row Count 9 (+ 2) FROM Purchase y \newline % Row Count 10 (+ 1) WHERE x.product = y.product \newline % Row Count 11 (+ 1) AND y.date \textgreater{} '10/1') \newline % Row Count 12 (+ 1) AS TotalSales \newline % Row Count 13 (+ 1) FROM Purchase x \newline % Row Count 14 (+ 1) WHERE x.date \textgreater{} "10/1"% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Joins}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{left outer join:For tables A and B, contains all records of the "left" table \newline % Row Count 2 (+ 2) (A), even if the join-condition does not find any matching \newline % Row Count 4 (+ 2) record in the "right" table% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{OORDBMS}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Abstraction: ignoring the parts that are not important.focus on what an object is and what it does rather than how it is done. Encapsulation: information hiding.separating external aspects from the internal implementation. \newline % Row Count 5 (+ 5) Class: A group of objects with the same attributes and methods. \newline % Row Count 7 (+ 2) {\bf{Methods}} \newline % Row Count 8 (+ 1) 1.{\bf{Member Method:}} defined on Instance Data \newline % Row Count 9 (+ 1) 2.{\bf{Static Method}} : invoked on the object type.can be used that are global. \newline % Row Count 11 (+ 2) 3.{\bf{Constructor Method}}: Built in constructor method.% Row Count 13 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Methods to compare objects: Member Method}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Define a special kind of member methods to compare objects. \newline % Row Count 2 (+ 2)  Define either a map method or an order method in an object type. \newline % Row Count 4 (+ 2)  Map Method \newline % Row Count 5 (+ 1) • Map object instances into one of the scalar types DATE, CHAR, NUMBER,…% Row Count 7 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Class Concepts}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Subclass: A class of objects that is defined as a special case \newline % Row Count 2 (+ 2) of a more general class,the process of forming subclasses \newline % Row Count 4 (+ 2) is called specialization. \newline % Row Count 5 (+ 1) Superclass: A class of objects that is defined as a general \newline % Row Count 7 (+ 2) case of a number of special classes (the process of forming \newline % Row Count 9 (+ 2) a superclass is called generalization). All instances of a \newline % Row Count 11 (+ 2) subclass are also instances of its superclass. \newline % Row Count 12 (+ 1) Inheritance: By default, a subclass inherits all the \newline % Row Count 14 (+ 2) properties of its superclass (or it can redefine some (or all) \newline % Row Count 16 (+ 2) of the inherited methods). Additionally, it may define its \newline % Row Count 18 (+ 2) own unique properties.% Row Count 19 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Oracle Methods}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Member Methods}} \newline % Row Count 1 (+ 1) CREATE OR REPLACE TYPE BODY person\_type AS \newline % Row Count 2 (+ 1) MEMBER FUNCTION get\_areacode RETURN VARCHAR2 IS \newline % Row Count 3 (+ 1) BEGIN \newline % Row Count 4 (+ 1) RETURN SUBSTR(phone, 1, 3); \newline % Row Count 5 (+ 1) END get\_areacode; \newline % Row Count 6 (+ 1) END; \newline % Row Count 7 (+ 1) /SELECT \seqsplit{c.contact.get\_areacode()} \newline % Row Count 8 (+ 1) FROM contacts c; \newline % Row Count 9 (+ 1) -{}- Constructor Method \newline % Row Count 10 (+ 1) Every object type has a constructor method implicitly defined by \newline % Row Count 12 (+ 2) system. \newline % Row Count 13 (+ 1)  Returns a new instance of the user-defined object type and sets up the \newline % Row Count 15 (+ 2) values of its attributes. \newline % Row Count 16 (+ 1)  The name of constructor method is the same as the name of the object \newline % Row Count 18 (+ 2) type. \newline % Row Count 19 (+ 1) p = person\_type('Scott Tiger', '321-123-1234');% Row Count 21 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Creating Object Table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{CREATE TABLE person\_table OF person\_type; \newline % Row Count 1 (+ 1) INSERT INTO person\_table \newline % Row Count 2 (+ 1) VALUES (person\_type ('Scott Tiger', '321-123-1234')); \newline % Row Count 4 (+ 2) SELECT VALUE(p) FROM person\_table p WHERE p.name = 'Scott% Row Count 6 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{overloading/overriding}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{CREATE TYPE Shape\_typ AS OBJECT (..., \newline % Row Count 1 (+ 1) MEMBER PROCEDURE Enlarge(x \newline % Row Count 2 (+ 1) ...) NOT FINAL; / \newline % Row Count 3 (+ 1) CREATE TYPE Circle\_typ UNDER \newline % Row Count 4 (+ 1) MEMBER PROCEDURE Enlarge(x \newline % Row Count 5 (+ 1) NUMBER), \newline % Row Count 6 (+ 1) Shape\_typ (..., \newline % Row Count 7 (+ 1) CHAR(1))); / \newline % Row Count 8 (+ 1) -{}-Define the inherited method Enlarge() to deal \newline % Row Count 9 (+ 1) -{}-input parameters. \newline % Row Count 10 (+ 1) with different types of \newline % Row Count 11 (+ 1) CREATE TYPE Shape\_typ AS OBJECT (..., \newline % Row Count 12 (+ 1) MEMBER PROCEDURE Area(), \newline % Row Count 13 (+ 1) FINAL MEMBER FUNCTION id(x NUMBER)... \newline % Row Count 14 (+ 1) ) NOT FINAL; / \newline % Row Count 15 (+ 1) CREATE TYPE Circle\_typ UNDER Shape\_typ (..., \newline % Row Count 16 (+ 1) OVERRIDING MEMBER PROCEDURE Area(), \newline % Row Count 17 (+ 1) ...); /% Row Count 18 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Order Methods}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{CREATE TYPE \newline % Row Count 1 (+ 1) circle\_type x \newline % Row Count 2 (+ 1) y \newline % Row Count 3 (+ 1) r \newline % Row Count 4 (+ 1) AS OBJECT ( \newline % Row Count 5 (+ 1) NUMBER, \newline % Row Count 6 (+ 1) NUMBER, \newline % Row Count 7 (+ 1) NUMBER, \newline % Row Count 8 (+ 1) ORDER MEMBER FUNCTION match(c circle\_type) \newline % Row Count 9 (+ 1) CREATE OR REPLACE TYPE BODY circle\_type AS \newline % Row Count 10 (+ 1) ORDER MEMBER FUNCTION match (c circle\_type) \newline % Row Count 11 (+ 1) BEGIN \newline % Row Count 12 (+ 1) RETURN INTEGER ); / \newline % Row Count 13 (+ 1) RETURN INTEGER IS \newline % Row Count 14 (+ 1) IF r \textless{} c.r THEN \newline % Row Count 15 (+ 1) RETURN –1; \newline % Row Count 16 (+ 1) -{}- 3.14{\emph{r2 \textless{} 3.14}}c.r2 \newline % Row Count 17 (+ 1) -{}- any negative number \newline % Row Count 18 (+ 1) THEN \newline % Row Count 19 (+ 1) -{}- any positive number \newline % Row Count 20 (+ 1) ELSIF r \textgreater{} c.r \newline % Row Count 21 (+ 1) RETURN 1; \newline % Row Count 22 (+ 1) ELSE \newline % Row Count 23 (+ 1) RETURN 0; \newline % Row Count 24 (+ 1) END IF; \newline % Row Count 25 (+ 1) END; \newline % Row Count 26 (+ 1) END; \newline % Row Count 27 (+ 1) SELECT FORM FROM circles c \newline % Row Count 28 (+ 1) WHERE VALUE(c) \textless{} (circle\_type(40, 25, 5)) ;% Row Count 29 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}