User:Swampware/SRF programming language
SRF (Sets, Relations, and Functions) is a data manipulation language based on set notation.
Sets
[edit]A set is defined as zero or more elements within curly braces: {1,2,3}.
Tuples
[edit]A tuple is an ordered list of values. A tuple is defined as zero or more ordered elements within parentheses: (1,2,3). Tuples cannot be altered once they are created. You cannot add, remove, or alter items on a tuple. A tuple can contain elements of different data types. Tuples by themselves aren't very useful, but we can use them with sets to create data structures of arbitrary complexity.
Relations
[edit]A relation is a set of tuples: {(1,"a"),(2,"b"),(3,"c")}. Relations are similar to database tables, and we can perform relational algebra on them.
Functions
[edit]A function is a relation where each tuple has 2 elements (binary relation) and the first element of each tuple must be unique to the function. Functions are similar to dictionaries in that they map an keys to values. Functions are also similar to conventional functions, in that they can be invoked by passing a set of parameters and return a value. Functions provide a conceptual bridge between data and code.
Set operations
[edit]We can perform several operations on sets, and by definition relations and functions.
Union
[edit]Union allows us to take all of the elements in one set and combine them with the elements of another set to produce a third set.
Intersection
[edit]Intersections takes two sets and returns a new set containing only the element in common.
Difference
[edit]The difference of two sets is all of the items in the first set that are not also in the second set.
Cartesian Product
[edit]The cartesian product of 2 sets is a binary relation consisting of every combination of the 2 sets.
Relational Algebra
[edit]Now that we have defined relations we can apply operations to relations in the form of relational algebra.
Projection
[edit]Selection
[edit]Rename
[edit]Joins
[edit]Division
[edit]Division or subset partition is the process of chopping a relation into set of relations.
Aggregation
[edit]Aggregation allows us to summarize the results of our operations on a relation.
References
[edit]- Lex de Haan, Toon Koppelaars: Applied Mathematics for Database Professionals, ISBN 1590597451
- A. V. Aho, J. D. Ullman: Foundations of Computer Science, C Edition., ISBN 0716782847
- H. Garcia-Molina, J. D. Ullman, Jennifer Widom: Database Systems: The Complete Book, ISBN 0132282119
- Raghu Ramakrishnan, Johannes Gehrke: Database Management Systems, ISBN 0071230572