SYDA Schema Reference¶
This document defines the schema format for the SYDA (Synthetic Data) library. It describes the supported field types and constraints.
Basic Schema Structure¶
A schema in SYDA is defined as a JSON or YAML object with field names as keys and field types as values. The simplest form is:
Field Types¶
The following field types are supported:
text¶
Generic text field for storing names, descriptions, and other textual content.
Example:
string¶
Same as text, used for storing character data.
Example:
number¶
Numeric field that can represent integers or decimal values.
Example:
integer¶
Integer value with no decimal places. Can also use the alias int
.
Example:
float¶
Floating-point number that can have decimal places.
Example:
date¶
Date value in standard format.
Example:
datetime¶
Date and time value.
Example:
boolean¶
True/false value. Can also use the alias bool
.
Example:
email¶
Email address with appropriate validation.
Example:
phone¶
Phone number field.
Example:
address¶
Physical address field.
Example:
url¶
URL/website address.
Example:
array¶
List of items. Arrays are typically populated using custom generators in the application code.
Example:
foreign_key¶
Reference to another table in the database.
Example:
Supported Field Properties¶
Fields can be defined with additional properties by using an object instead of a string:
The following properties can be used when defining fields:description¶
Human-readable description of the field's purpose.
Example:
length¶
Fixed length for the field.
Example:
min_length¶
Minimum length for string fields.
Example:
max_length¶
Maximum length for string fields.
Example:
min¶
Minimum value for numeric fields.
Example:
max¶
Maximum value for numeric fields.
Example:
decimals¶
Number of decimal places for float fields.
Example:
format¶
Format string specification (for dates, etc.).
Example:
enum¶
List of possible values for the field.
Example:
pattern¶
Regular expression pattern for validation.
Example:
references¶
Foreign key reference to another table and field.
Example:
Note: Field properties are validated during schema validation. For example, using an invalid field type will cause validation to fail with a detailed error message.
Field Constraints¶
Constraints can be specified directly in the field definition or in a separate constraints
object:
The following constraints are supported:
not_null¶
Field cannot be null or empty.
Example:
unique¶
Values must be unique within the dataset.
Example:
primary_key¶
Field is a primary key for the table.
Example:
format¶
Format specification for specialized field types.
Example:
pattern¶
Regular expression pattern for validation.
Example:
min¶
Minimum value for numeric fields.
Example:
max¶
Maximum value for numeric fields.
Example:
min_length¶
Minimum string length for text fields.
Example:
max_length¶
Maximum string length for text fields.
Example:
length¶
Exact string length for text fields.
Example: