Chapter 2. Creating a Store

Table of Contents

Defining Tables
Initializing the Store

The first thing to do is define your Store (the closest thing Trivial Persist has to a Database). This involves three steps:

  1. Choose a directory to store the data (referred to below as the "Store Directory").

  2. Define your Table(s) by placing a text file (tablename.schema) for each Table in that directory.

  3. Initialize your Store with that directory.

Defining Tables

.schema files are also stored in java.util.Properties format, and contain one line for each field (column) in its Table. Valid field types are String, Long, Date, Boolean, Double. For example, here's a silly Table definition for storing six fields of information about cars:

make=string
model=string
year=long
firstmanufactured=date
convertible=boolean
grossweight=double

Note

All string comparisons in Trivial Persist are case-insensitive. This includes field names, field types, table names, etc.