What does the term "tuple" mean in relational databases?

Please explain what is meant by tuples in sql? Thank..

+50
sql terminology definition tuples rdbms
Apr 15 '09 at 11:28
source share
10 answers

Most of the answers here are on the right track. However, a string is not a tuple . Tuples * are unordered sets of known values โ€‹โ€‹with names. Thus, the following tuples are the same thing (I use the syntax of an imaginary tuple, since the relational tuple is largely a theoretical construct):

 (x=1, y=2, z=3) (z=3, y=2, x=1) (y=2, z=3, x=1) 

... assuming, of course, that x, y and z are integers. Also note that there is no such thing as a โ€œduplicateโ€ tuple. Thus, not only the above are equal, they are one and the same. Finally, tuples can only contain known values โ€‹โ€‹(thus, no zeros).

A row ** is an ordered set of known or unknown values โ€‹โ€‹with names (although they may be omitted). Therefore, the following comparisons return false in SQL:

 (1, 2, 3) = (3, 2, 1) (3, 1, 2) = (2, 1, 3) 

Note that there are ways to "fake". For example, consider this INSERT :

 INSERT INTO point VALUES (1, 2, 3) 

Assuming x is the first, y is the second, and z is the third, this query can be rewritten as follows:

 INSERT INTO point (x, y, z) VALUES (1, 2, 3) 

Or that:

 INSERT INTO point (y, z, x) VALUES (2, 3, 1) 

... but all we really do is reorder, not delete it.

Also note that there may be unknown values. So you may have strings with unknown values:

 (1, 2, NULL) = (1, 2, NULL) 

... but note that this comparison will always be UNKNOWN . After all, how can you find out if two unknown values โ€‹โ€‹are equal?

And finally, rows can be duplicated. In other words, (1, 2) and (1, 2) can be compared as equal, but this does not necessarily mean that they are one and the same.

If this is a topic that interests you, I would highly recommend reading SQL and Relational Theory: how to write accurate SQL code from CJ Date.

* Please note that I am talking about tuples, as they exist in a relational model that is slightly different from mathematics in general.

** And just in case, when you are interested, almost everything in SQL is a row or a table. Therefore, (1, 2) is a row, and VALUES (1, 2) is a table (with one row).

UPDATE I expanded this answer a bit in the blog post here .

+71
Jul 05 '09 at 0:52
source share

This is the abbreviated " N-tuple " (for example, in quadruple , quintuple , etc.)

This is a rowset string taken as a whole.

If you issue:

 SELECT col1, col2 FROM mytable 

the whole result will be ROWSET , and each pair of col1, col2 will be tuple .

Some databases may work with the tuple as a whole.

For example, you can do this:

 SELECT col1, col2 FROM mytable WHERE (col1, col2) = ( SELECT col3, col4 FROM othertable ) 

which checks that an integer tuple from one ROWSET matches an integer tuple from another ROWSET .

+14
Apr 15 '09 at 11:34
source share

In relational databases, relationship tables (in the mathematical sense) . Relationships are tuple sets. Thus, a table row in a relational database is tied to a tuple.

Relations Wiki:

In mathematics (more precisely, in set theory and logic), a relation is a property that assigns truth values โ€‹โ€‹to combinations (k-tuples) of k individuals. Typically, a property describes a possible connection between components of a k-tuple. For a given set of k-tuples, the truth is assigned a value to each k-tuple, depending on whether or not it is executed.

+4
Apr 15 '09 at 11:40
source share

Whatever its use in mathematics, a tuple in an RDBMS is usually considered a row in a table or a set of results. In an RDBMS, a tuple is disordered. A tuple in MDDBMS is an instance of data in a cell with dimension instances (members) associated with it.

What is a tuple in a column collection data store?

+3
Jan 20 '14 at 3:43
source share

tuple = 1 record; n-tuple = ordered list of entries 'n'; Book of Elmas Navate (p. 198 3rd edition).

record = either ordered or disordered.

+2
Apr 01 '13 at 9:24 on
source share

row from database table

0
Apr 15 '09 at 11:30
source share

As I understand it, the table has a set of keys K and an input function T with domain K. The row or โ€œtupleโ€ of the table is a function r with region K, for which r (k) is an element T (k) for each key k. Thus, the terminology is misleading in the sense that the "tuple" is really more like an associative array.

0
Sep 08 '13 at 20:31 on
source share

Tuple is used to refer to a row in a relational database model. But the tuple has a slight difference in the row.

0
Sep 22 '17 at 16:23
source share

Tuples are known values โ€‹โ€‹that are used to link a table in a relational database.

-one
Feb 24 '10 at 12:30
source share

A tuple is used to define a piece of data from a cube; it consists of an ordered set of one element from one or more dimensions. A tuple is used to identify specific sections of multidimensional data from a cube; a tuple consisting of one member from each dimension in a cube fully describes the value of the cell.

-2
Apr 15 '09 at 11:31
source share



All Articles