T-SQL Basics Tutorial: set theory

Source: Internet
Author: User

The set theory was created by the mathematician Georg Cantor, a branch of mathematics based on the relational model. The set of Cantor is defined as follows:

Set, we mean that an arbitrary set of M is the whole of what we perceive or think of, the mutually dissimilar object m (called the element of M).

──joseph W. Dauben and Georg Cantor (Princeton University Press, 1990)

Each word in the definition has profound and important meaning. Set definitions and set dependencies are axioms without proof, and each element in the universe is either a member of a collection or a member of a collection.

Let's start with each word in the Cantor definition. A "set" should treat it as a single entity, and your focus should be on the collection of objects, not on the individual objects that make up the collection. Then, when you write a T-SQL query to a table in a database, such as an employee table, you should see the collection of employees as a whole, not as a single employee. This may not sound important and simple, but it is clear that many programmers have a hard time using this mindset.

The word "XOR" means that each element in the collection must be unique. To jump to a table in a database, you can enforce the uniqueness of rows in a table by defining key constraints. Without a key, you cannot uniquely identify the row, so the table cannot get "set" eligibility. Instead, the table will be a multiple collection or an unordered group of units.

The phrase "we perceive or think of" means that the definition of a set is subjective. Think about the classroom: A person can be considered a collection of "people" or a collection of "students" or "teachers". Therefore, you have a great degree of freedom in defining collections. When you design a data model for a database, the design process should carefully consider the subjective needs of the application to determine the appropriate definition for the relevant entity.

As for "objects", the definition of a collection is not limited to physical objects such as automobiles or employees, but to related abstract objects such as prime numbers or lines.

Cantor's set definition of omitted content is likely to be as important as the content contained. Note that the definition does not mention any order between the elements of the collection, and the order in which the collection elements are listed does not matter. The official tag symbol that lists the collection elements is using braces: {A, B, C}. Because of the order, you can use {b, A, c} or {B, C, a} to represent the same collection. Jumps to a collection of attributes (called columns in SQL) that form the header of a relationship (called a table in SQL), and the elements should be identified by name-not sequentially.

Again, consider the tuples (called Rows in sql) that form the body of the relationship, and the elements are identified by their key values, not by position. Many programmers find it difficult to adapt to the idea that there is no order between rows for a query table. In other words, a query to a table can return rows in a table in any order, unless you explicitly require that the data be sorted in a specific way, based on specific presentation purposes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.