Fields — Giving a Table Its Shape
By the end of this chapter you can give a table a shape that keeps bad data out, and you can read the full field-type menu knowing exactly which entries this guide has personally tested and which it is reporting.
A field is a promise
A spreadsheet column holds anything: text in one row, a number in the next, a date typed three different ways. A NocoDB field holds one kind of thing in every row. Quantity is a Number field, so "three" cannot be typed into it as a word; Acquired is a Date, so it sorts by calendar, not by spelling. That strictness is the whole difference between a list and a database, and it is why the type is chosen once, when the field is made, per column rather than per cell.
Every table also gets system fields
it did not ask for, which the lab saw
added to both of its tables: an Id
number that counts the rows in, plus
CreatedAt, UpdatedAt, nc_created_by
and nc_updated_by, and a hidden order
value the grid uses for manual sorting.
You never type into them; they are the
table's memory of itself. One field,
chosen at creation, is the display
value — the one shown when another
table refers to a row. For both lab
tables that is Name.
The lab's two tables
From transcript t04, the shape the
running example uses. Locations is
deliberately tiny: just Name, plus
the relationship fields chapter 7 will
add. Items carries the everyday
types:
| Field | Type | Holds |
|---|---|---|
| Name | Single line text | "Cordless drill" |
| Category | Single select | one of Tools / Books / Games / Kitchen |
| Quantity | Number | 4 |
| UnitValue | Currency | 6.50, with a currency attached |
| Acquired | Date | 2024-05-02 |
| TotalValue | Formula | computed — chapter 7 |
Creating a table with its fields is one call in the API, and one dialog in the app: name the table, add a row per field with its type, save. Single select deserves one sentence of its own, because it is the type that turns typos into impossibilities: the allowed values are declared with the field (the four categories above), each gets a colour, and no row may hold anything else.
The full menu, honestly labelled
The documentation's list, grouped the way the field picker groups it. Exercised by this lab are marked with a bullet of proof behind them; the rest are reported, not tested.
- Text based — Single line text ✔, Long text, Email, Phone number, URL.
- Numeric — Number ✔, Decimal, Currency ✔, Percent, Duration, Rating, Auto number.
- Select based — Single select ✔, Multi select, Checkbox.
- Date and time — Date ✔, DateTime, Year, Time.
- Link based — Links ✔, Lookup ✔, Rollup ✔. These are chapter 7, the heart of the tool.
- Computed by formula — Formula ✔, which takes a small expression language of its own (functions for text, numbers, dates and logic), covered in chapter 7.
- Files and codes — Attachment, Barcode, QR code, GeoData, JSON, and a Button type that runs an action or a script when clicked.
- People and stamps — User (a person from the base's members), and the automatic Created time / Last modified time / Created by / Last modified by, which arrive as system fields without being asked.
Two honest notes. Attachment fields store uploaded files on disk under the tool directory — chapter 13 counts them in a backup — and this lab used none, so their behaviour here is documented, not measured. And changing a field's type after rows exist is possible for some pairs and refused for others; the safe habit, taught in the recipes, is to decide the shape with a handful of test rows first.