> ## Documentation Index
> Fetch the complete documentation index at: https://docs.standardcomputers.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend a Standard to Inherit Constraints and Add Fields

> Learn how to extend an existing Standard to create a new table that inherits all parent constraints, with optional additional fields.

Just as object-oriented languages let you extend a class to inherit its properties, you can extend an existing Standard to create a new Standard that inherits all of the parent's constraints. This lets you build on shared definitions without duplicating constraint declarations, keeping your schema DRY and consistent across related record types.

## Extension Syntax

To extend a Standard, declare your new Standard name and reference as usual, then append a colon followed by the parent Standard's reference prepended with `@`:

```stds theme={null}
new_std: NSTD: @STDREF
```

The new Standard inherits every constraint defined in the parent Standard. Your existing queries and references to the parent Standard are unaffected — extension creates a completely separate table.

## Basic Example

A common use case is modeling different vehicle types. You can extend the base `vehicle` Standard to create a `truck` Standard that inherits all vehicle constraints:

```stds theme={null}
truck: TRCK: @VHL
```

With this single line, `TRCK` has all of the same constraints as `VHL` — `vin`, `make`, `model`, and any others defined in `vehicle` — stored in its own dedicated table.

## Adding Extra Constraints

You can give your extended Standard additional constraints by including a constraint block. The extended Standard will contain all parent constraints plus any new ones you define:

```stds theme={null}
truck: TRCK: @VHL {
    protected owner standard @PER OWNR *
    protected max_weight double MXWGHT
}
```

In this example, `TRCK` inherits all constraints from `VHL` and adds two more:

* `owner` — a reference to a `PER` (person) Standard record, required on every truck.
* `max_weight` — a `double` value representing the truck's maximum weight, optional.

<Tip>
  Use extension when two record types share a common structure but need to be queried and stored independently. Avoid extending a Standard just to add a single boolean flag — in that case, adding the constraint directly to the parent Standard may be cleaner.
</Tip>

<Note>
  Extension is not inheritance in the runtime sense — it copies the constraint structure at definition time. Changes to the parent Standard's constraints after extension are not automatically reflected in the extended Standard.
</Note>
