From SQL to Math Operators
Math and SQL
Table and math:
Table includes rows and columns of information. All information from one column must be of the same type. The set of ALL possible values of one column is called DOMAIN of this column. Row represents one entity and columns define its characteristics. The DOMAIN of one column is called ATTRIBUTE.
Let C1, C2, …Cn be the column names of a table T.
- n is called the dimension of the table.
- The column names can be associated with attributes or DOMAIN
Let assume that the table T has k rows (rows can be duplicated).
- k is call the cardinality of the table.
- Each row is a tuple, a member of the Cartesian product C1 x C2 x…x Cn
- In math the Cartesian product C1 x C2 x…x Cn is a vector space of n dimension. Hence Table T is a subset of the Cartesian product.
Projection of a n-dimensional vector space to a lesser dimension space is denoted as (.
- The projection (: C1 x C2 x…x Cn ( C1 will project the n-tuple onto the first dimension C1.
- In SQL we express this function as: SELECT C1 from T;
- It is possible that we have many duplicates of values in C1 after the projection. If ALL duplicates are collected, we have the following SQL:
SELECT ALL C1 from T;
If we want to keep only one copy, we use:
SELECT DISTINCT C1 FROM T;
- In math, we use subscript d in ( where d can be ALL or DISTINCT.
Algebra and Simple SQL Statements
SQL: Select * From R Group by GA;
Math: G[GA] R
Meaning: Group table R on the grouping columns GA= {GA1, GA2, …GAn}
R1 x R2: the Cartesian product of table R1 and R2
SQL: SELECT * FROM R WHERE C;
Math: ([C]R
Meaning: Select all rows of table R that satisfy condition C. Duplicate rows are not eliminated.
SQL: SELECT [ALL/DISTINCT] B FROM R;
Math: (d[B]R
Meaning: Project table R on columns B, without eliminating duplicates when d = ALL and with duplicate elimination when d = DISTINCT
SQL: SELECT GA, A, F[AA] FROM R GROUP BY GA;
Math: F[AA]R
Meaning: Project table R on columns GA (grouping columns), on columns A (non-grouping columns, and on the aggregation columns AA={A1, A2,…, An} with the aggregation functions F = {f1, f2,…fn}
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- applicable clep dsst exams for ccaf requirements
- counting all counting on counting up counting down the
- writing a formal mathematical report
- 100 word vocabulary list geometry
- transformational geometry translations
- enhanced mathematics a co requisite approach to
- math vocabulary list
- math vocabulary illustrated dictionary or flip book project
- math algebra unit 1 ell scaffold
- caa blueprints for mathematics caaspp ca dept of education