HOME

TheInfoList




In
computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , , and . Computer science ...
, data that has several parts, known as a '' record,'' can be divided into fields (data fields).
Relational database A relational database is a digital database In , a database is an organized collection of stored and accessed electronically from a . Where databases are more complex they are often developed using formal techniques. The (DBMS) is the tha ...
s arrange data as sets of
database record In the context of a relational database A relational database is a digital database based on the relational model of data, as proposed by E. F. Codd in 1970. A software system used to maintain relational databases is a relational database manag ...
s, so called rows. Each record consists of several ''fields''; the fields of all records form the
columns A column or pillar in architecture File:Plan d'exécution du second étage de l'hôtel de Brionne (dessin) De Cotte 2503c – Gallica 2011 (adjusted).jpg, upright=1.45, alt=Plan d'exécution du second étage de l'hôtel de Brionne (dessin) ...
. Examples of fields: name, gender, hair colour. In
object-oriented programming Object-oriented programming (OOP) is a programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mai ...
, a ''field'' (also called ''data member'' or ''
member variable In object-oriented programming Object-oriented programming (OOP) is a programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Som ...
'') is a particular piece of
data Data (; ) are individual facts A fact is something that is truth, true. The usual test for a statement of fact is verifiability—that is whether it can be demonstrated to correspond to experience. Standard reference works are often used ...

data
encapsulated within a
class Class or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used differently f ...
or
object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Entity, something that is tangible and within the grasp of the senses ** Object (abstract), an object which does not exist at any particular time or pl ...
. In the case of a regular field (also called ''
instance variable In object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and code: data in the form of Field (computer science), fields (oft ...
''), for each instance of the object there is an
instance variable In object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and code: data in the form of Field (computer science), fields (oft ...
: for example, an Employee class has a Name field and there is one distinct name per employee. A static field (also called ''
class variableIn object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and code: data in the form of Field (computer science), fields (often ...
'') is one variable, which is shared by all instances. Fields are abstracted by
properties Property (''latin: Res Privata'') in the abstract is what belongs to or with something, whether as an attribute or as a component of said thing. In the context of this article, it is one or more components (rather than attributes), whether phys ...
, which allow them to be read and written as if they were fields, but these can be translated to
getter A getter is a deposit of reactive material that is placed inside a vacuum system, for the purpose of completing and maintaining the vacuum. When gas molecules strike the getter material, they combine with it chemically or by absorption. Thus the ...
and
setter Image:Can Setter dog GFDL.jpg, 250px, Irish Setter The setter is a Dog type, type of gundog used most often for hunting game (food), game such as quail, pheasant, and grouse. In the UK, the four setter breeds, together with the Pointer (do ...
method calls.


Fixed length

Fields that contain a fixed number of bits are known as fixed length fields. A four byte field for example may contain a 31 bit binary integer plus a sign bit (32 bits in all). A 30 byte name field may contain a person's name typically padded with blanks at the end. The disadvantage of using fixed length fields is that some part of the field may be wasted but space is still required for the maximum length case. Also, where fields are omitted, padding for the missing fields is still required to maintain fixed start positions within a record for instance.


Variable length

A variable length field is not always the same physical size. Such fields are nearly always used for text fields that can be large, or fields that vary greatly in length. For example, a bibliographical database like
PubMed PubMed is a free search engine accessing primarily the MEDLINE bibliographic database, database of references and abstracts on life sciences and biomedical topics. The United States National Library of Medicine (NLM) at the National Institutes ...

PubMed
has many small fields such as publication date and author name, but also has abstracts, which vary greatly in length. Reserving a fixed-length field of some length would be inefficient because it would enforce a maximum length on abstracts, and because space would be wasted in most records (particularly if many articles lacked abstracts entirely). Database implementations commonly store varying-length fields in special ways, in order to make all the records of a given type have a uniform small size. Doing so can help performance. On the other hand, data in
serialized
serialized
forms such as stored in typical file systems, transmitted across networks, and so on usually uses quite different performance strategies. The choice depends on factors such as the total size of records, performance characteristics of the storage medium, and the expected patterns of access. Database implementations typically store variable length fields in ways such as *a sequence of characters or bytes, followed by an ''end-marker'' that is prohibited within the string itself. This makes it slower to access later fields in the same record because the later fields are not always at the same physical distance from the start of the record. *a ''pointer'' to data in some other location, such as a
URI A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or physical resource used by web technologies. URIs may be used to identify anything, including real-world objects, such as people and places, concep ...
, a file offset (and perhaps length), or a key identifying a record in some special place. This typically speeds up processes that do not need the contents of the variable length fields, but slows processes that do. *a ''length prefix'' followed by the specified number of characters or bytes. This avoids searches for an end-marker as in the first method, and avoids the loss of
locality of reference In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algori ...
as in the second method. On the other hand, it imposes a maximum length: the biggest number that can be represented using the (generally fixed length) prefix. In addition, records still vary in length, and must be traversed in order to reach later fields. If a varying-length field is often empty, additional optimizations come into play.


Example

This Person java class has 3 fields: firstName, lastName, and heightInCentemeters. public class Person


See also

*
Class variableIn object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and code: data in the form of Field (computer science), fields (often ...
*
Data hierarchyData hierarchy refers to the systematic organization of data, often in a hierarchical form. Data organization involves characters, fields, records, files and so on. This concept is a starting point when trying to see what makes up data and whether da ...
*
Instance variable In object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and code: data in the form of Field (computer science), fields (oft ...
*
Mutator methodIn computer science, a mutator method is a method (computer science), method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter (together also known as accessors), which retu ...


References

{{DEFAULTSORT:Field (Computer Science) Data modeling