Tuples against records

What is the difference between tuples and records?

+18
data-structures tuples records
Nov 18 '10 at 6:40
source share
3 answers

Both are product types that allow you to create types from several simpler types. Some languages ​​view tuples as a kind of record.

Definitions

A tuple is an ordered group of elements, for example (10, 25).

Typically, a record is a group of named elements, such as { "x": 10, "y": 25 } , where the value has two fields labeled x and y , and the value of the field x is 10 .

Morphological

The word "tuple" comes from the common suffix "-tuple" to "fivefold", "sixfold", "septile", "eight", which means groups of 5, 6, 7 and 8, respectively.

The word "record" comes from data tables. You can represent all possible tuples with fields x and y in the form of a table in which the columns correspond to the fields and rows that collect all the fields for a particular instance of the record.

  value address field x field y 0xABCD 10 25 0x1234 42 "xyz" 

Product Type Equivalence

You can consider a tuple as a kind of record, where the index of the element in the tuple is its name in the equivalent record, therefore (10, 25) - { "0": 10, "1": 25 } . I believe that the ML standard and related languages ​​use records as the basic unit of the join type ( algebraic data types provide type disjunction) and treat tuples as a kind of record in this way.

+10
Nov 18 '10 at 6:44
source share

According to Wikipedia:

In computer science, a record ( also called tuple or struct) is one of the simplest data structures consisting of two or more values ​​or variables stored in a serial position memory; so that each component (called a field or record member) can be accessed by applying different offsets to the start address.

I would say that there is little difference between a tuple and a record.

+5
Nov 18 2018-10-18T00:
source share

A record is a complete row of data elements from one table, for example, a student has a record with the number roll no. 3 in one table, where as a tuple there is a super set of records in which the data belongs to other tables, for example, rows of student roll No. 3 records in other tables in relationships, i.e. attendance, results, contacts, fees, etc. Thus, the entire data set of one student from all tables is a tuple. As I know. Thank.

0
Dec 05 '16 at 14:13
source share



All Articles