Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





Field (computer science)





Article  

Talk  



Language  

Watch  

Edit  





Incomputer science, data that has several parts, known as a record, can be divided into fields (data fields). Relational databases arrange data as sets of database records, so called rows. Each record consists of several fields; the fields of all records form the columns. Examples of fields: name, gender, hair colour.

Inobject-oriented programming, a field (also called data memberormember variable) is a particular piece of data encapsulated within a classorobject. In the case of a regular field (also called instance variable), for each instance of the object there is an instance variable: for example, an Employee class has a Name field and there is one distinct name per employee. A static field (also called class variable) is one variable, which is shared by all instances.[1] Fields are abstracted by properties, which allow them to be read and written as if they were fields, but these can be translated to getter and setter method calls.

Fixed length

edit

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

edit

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 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 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

If a varying-length field is often empty, additional optimizations come into play.

Example

edit

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

public class Person
{
 private String firstName;
 private String lastName;
 
 private int heightInCentimeters;
}

See also

edit

References

edit
  1. ^ "Data fields". Sliccware. Retrieved 2011-08-12.

Retrieved from "https://en.wikipedia.org/w/index.php?title=Field_(computer_science)&oldid=1196239155"
 



Last edited on 16 January 2024, at 22:17  





Languages

 


العربية
Català
Čeština
Deutsch
Español
Français
Italiano
עברית
Қазақша
Nederlands

Polski
Português
Русский
Slovenčina
Українська
Tiếng Vit

 

Wikipedia


This page was last edited on 16 January 2024, at 22:17 (UTC).

Content is available under CC BY-SA 4.0 unless otherwise noted.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Terms of Use

Desktop