Jump to content

User:Josephbubb/Record (computer science)

From Wikipedia, the free encyclopedia

A record is a collection of fields of data, typically in a fixed number and sequence. The fields of a record may also be called members, particularly in object-oriented programming; fields may also be called elements, though this risks confusion with the elements of a collection.

Records are distinguished from arrays by the fact that their number of fields is determined in the definition of the record, and by the fact the records are a heterogenous data type; not all of the fields must contain the same type of data[1].

Keys[edit][edit]

A record may have zero or more keys. A key maps an expression to a value, or a set of values, in the record. A primary key is a key this is unique throughout all stored records; only one if this key exists[2]. In other words, no duplicate may exist for any primary key. For example an employee file might contain employee number, name, department, and salary. The employee number will be unique in the organization and would be the primary key. Depending on the storage medium and file organization the employee number might be indexed—that is also stored in a separate file to make lookup faster. The department code is not necessarily unique; it may also be indexed, in which case it would be considered a secondary key, or alternate key[3]. If it is not indexed the entire employee file would have to be scanned to produce a listing of all employees in a specific department. Keys are usually chosen in a way that minimizes the chances of multiple values being feasibly mapped to by one key. For example, the salary field would not normally be considered usable as a key since many employees will likely have the same salary. Indexing is one factor considered when designing a file.

History[edit][edit]

The original machine-readable medium used for data (as opposed to control) was punch card used for records in the 1890 United States Census: each punch card was a single record. Compare the journal entry from 1880 and the punch card from 1895. Records were well-established in the first half of the 20th century, when most data processing was done using punched cards. Typically each record of a data file would be recorded in one punched card, with specific columns assigned to specific fields. Generally, a record was the smallest unit that could be read in from external storage (e.g. card reader, tape or disk). The contents of punchcard-style records were originally called "unit records" because since punchcards had pre-determined document lengths.[4] When storage systems became more advanced with the use of hard drives and magnetic tape, variable-length records became the standard. A variable-length record is a record in which the size of the record in bytes is approximately equal to the sum of the sizes of the its fields. This was not possible to do before more advanced storage hardware was invented because all of the punchcards had to conform to pre-determined document lengths that the computer could physically read.

Although records are not often used in their original context anymore (i.e. being used solely for the purpose of containing data), records influenced newer object oriented programming languages and relational database management systems. Since records provided more modularity in the way data was stored and handled, they are better suited at representing complex, real-world concepts than the primitive data types provided by default in languages. This influenced later languages such as C++, Python, JavaScript, and Objective-C which address the same modularity concerns of programmers[5]. Objects in these languages are essentially records with the addition of methods and inheritance, which allow programmers to manipulate the way data behaves instead of only the contents of a record. Many programmers regard records as obsolete now since object-oriented languages have features that far surpass what records are capable of. On the other hand, many programmers argue that the low overhead and ability to use records in assembly language make records still relevant when programming with low levels of abstraction. to Today, the most popular languages on the TIOBE index, an indicator of the popularity of programming languages, have been influenced in some way by records due to the fact that they are object oriented[6]. Query languages such as SQL and Object Query Language were also influenced by the concept of records. These languages allow the programmer to store sets of data, which are essentially records, in tables[7]. This data can then be retrieved using a primary key. The tables themselves are also records which may have a foreign key: a key that references data in another table.

Operations[edit][edit]

Pascal's "with" statement[edit][edit]

In the Pascal programming language, the command with R do S would execute the command sequence S as if all the fields of record R had been declared as variables. Similarly to entering a different namespace in an object-oriented language like C#, it is no longer necessary to use the record name as a prefix to access the fields. So, instead of writing Pt.X := 5; Pt.Y := Pt.X + 3 one could write with Pt do begin X := 5; Y := X + 3 end.

Self-defining records[edit][edit]

A self-defining record is a type of record which contains information to identify the record type and to locate information within the record. It may contain the offsets of elements; the elements can therefore be stored in any order or may be omitted. The information stored in a self-defining record can be interpreted as metadata for the record, which is similar to what one would expect to find in the UNIX metadata regarding a file, containing information such as the record's creation time and the size of the record in bytes. Alternatively, various elements of the record, each including an element identifier, can simply follow one another in any order.

  1. ^ Pape, Tobias; Kirilichev, Vasily; Bolz, Carl Friedrich; Hirschfeld, Robert (2017-01-13). "Record data structures in racket: usage analysis and optimization". ACM SIGAPP Applied Computing Review. 16 (4): 25–37. doi:10.1145/3040575.3040578. ISSN 1559-6915.
  2. ^ "Add or change a table's primary key in Access". support.microsoft.com. Retrieved 2022-03-01.
  3. ^ "Alternate key - Oracle FAQ". www.orafaq.com. Retrieved 2022-03-01.
  4. ^ Encyclopedia of computer science. Edwin D. Reilly, Anthony Ralston, David Hemmendinger (4th ed. ed.). Chichester, Eng.: Wiley. 2003. ISBN 978-1-84972-160-8. OCLC 436846454. {{cite book}}: |edition= has extra text (help)CS1 maint: others (link)
  5. ^ Leavens, Gary T.; Weihl, William E. (1990). "Reasoning about object-oriented programs that use subtypes". Proceedings of the European conference on object-oriented programming on Object-oriented programming systems, languages, and applications - OOPSLA/ECOOP '90. New York, New York, USA: ACM Press. doi:10.1145/97945.97970.
  6. ^ "index | TIOBE - The Software Quality Company". www.tiobe.com. Retrieved 2022-03-01.
  7. ^ "What is a Relational Database (RDBMS)?". Oracle. Retrieved February 28, 2022.{{cite web}}: CS1 maint: url-status (link)