Which programming languages ​​have tuples

Tuple


The term tuple comes from mathematics and describes an ordered set of objects that are summarized and represented in a certain way - for example as lists with data fields. In contrast to a set, the elements of which are unordered, tuples are ordered in an order. The order is irrelevant for sets, but for tuples the order plays an important role, as this creates an order. These mathematical properties of the tuples are the reason why they are used in computer science, because tuples can be understood as ordered lists if their order or the so-called index set is precisely defined. In relational databases, index structures and in programming, tuples serve as the theoretical basis for building special data structures.

General information on the topic [edit]

A tuple is defined as an ordered pair written in brackets and separated by commas or semicolons: 2-tuple = (1,2) or 3-tuple = (1,2,3). The objects that are in the bracket are called components. In this case there are only two or three components that follow one another numerically. However, tuples can also contain several components, whereby 3-tuples can be referred to as triples, 4-tuples as quadruples and 5-tuples as quintuples.[1] Basically, this notation can also be used to describe tuples that contain n-components: n-tuple = (1, ..., n), which is referred to as a stream in computer science.

This abstract mathematical definition of tuples is intended to make it clear that each component of a tuple can be clearly assigned to a data record linked to it. Otherwise access to such a data structure would not be possible. If a user wants to access a data record from a relational database, this data record must be ordered in a certain way. This is exactly what tuples do - although there are different schemes of order and in computer science the tuples are more likely to be called with the names of individual data structures. For example as an array, list or stream. The tuples form the underlying structures for these data types or models.

How it works [edit]

In computer science, the term tuple describes an ordered combination of values ​​that are also defined as attributes or data fields. Each data field is characterized by the so-called atomic content. This means that what is in the data field must not have complex content and therefore cannot be broken down further. In the case of the following tuple, the values ​​such as name or address should not be broken down further, since each value represents exactly one data record:

Database entry 1 = (name, address, email, telephone number)

The order is important both when saving a new data record and when retrieving an old data record. It is true that individual data fields can be searched for and read, but this is only possible because they are in a specific order, which is given by the database entry 1 to n. The same applies to storage: each new data record is clearly assigned to the entries in this order. The database entry is referred to as a key. Each key can only appear once.

If data fields are to be broken down, this is regulated via the data structure and the number of keys, because tuples can definitely contain other lists, strings or data types - but only in other tables whose assignment is clear through a key. Relational databases have the advantage that they are ordered in a certain way by the key (also index set). Most relational databases work with an attribute notation: This means that each tuple is defined by specifying key-value pairs, which are also called attributes. A table then has a sequence of keys, the data fields of which consist of the specification of attributes and properties.[2] In this way, the above-mentioned database entry 1 can be expanded as follows:

Database entry 1 = (name = Martin, address = Musterweg, email = [email protected], telephone number = 017012345)

A problem with this notation is that no data field or attribute-value pair can be duplicated. This would lead to ambiguity. The relationships between database entries and the attribute-value pairs would no longer be clearly defined and the processing system outputs results that can contradict each other.

However, such problems can be avoided by having a clear and extensive data structure that matches the data to be stored. In concrete terms, this means that it is entirely possible to select the number of data fields in such a way that contradicting or duplicate entries are effectively avoided. For example, the database entries can be expanded to include additional attribute-value pairs such as city, street, age, customer number or other data. The key sequence in this context is the sequence of the keys: It must not change so that the relationships between database entries 1 to n and the associated data fields are clearly defined.

Examples [edit]

The use of tuples in data structures often depends on the programming paradigm used. In most functional and imperative programming languages, tuples are used, in object-oriented programming, on the other hand, objects can often be described as tuples. A selection of examples:[3]

  • In the SQL database language, tuples are a data structure that can be used for definition, storage and various queries. As is well known, the basis for tuples are tables and tables are the basic data type in SQL.
  • Tuples are used as a data and query type in many programming languages ​​- as are tables. For example in Haskell, Prolog, Python, Java, C ++ or Lisp.
  • In standard programming libraries or frameworks such as .NET or Ruby, tuples are also offered as data types.

Meaning for programming [edit]

The importance of tuples for programming is enormous. A major advantage of tuples and the representation of information as tables is the option to map complex data and facts in such a way that information technology queries can take place in this data. Because data can be stored in relations or tuples, it is possible to extract this information via computer and, for example, transfer the data to another part of the program in order to carry out a certain action. Because the two-valued logic in computer science requires data structures that can be stored in binary. Tables, tuples, arrays and matrices meet this requirement.

References Edit]

  1. ^ Tuple mathebibel.de. Retrieved on November 7, 2016
  2. ↑ Tuple glossar.hs-augsburg.de. Retrieved on November 7, 2016
  3. ↑ Which programming languages ​​have tuples? quora.com. Retrieved on November 7, 2016

Web links [edit]