Jd/General

From J Wiki
Jump to: navigation, search
Jd | Overview | General | Ops | Admin | Guide | Technical | Release | Convert | License | Support

Install

Install Jd (addon data/jd) with JAL/Package Manager. Jd requires J64 (803 or later) on Windows, Linux, or Mac.

Run

There is a slight preference for JHS as the front end. Running Jd tutorials in jconsole is awkward. Eventually your Jd systems are likely deployed in servers (perhaps in a cloud) and JHS makes secure remote management and development a natural continuation of using Jd on your own local machine. If not already familiar with the JHS front end, time spent getting familiar is time well spent.

   load'jd'
... welcome message ...

The welcome message tells you if you require a license key and how to get one.

The welcome message suggests how to get started, and in particular how to list and run tutorials and examples.

Args

The main function is jd:

   jd'...' NB. perform Jd op

The argument is parsed to a list of boxes. A string is treated as list of blank delimited boxes. The first box in a list of boxes is treated as a list of blank delimited values.

   jd'insert f a';23     === jd'insert';'f';'a';23

Column definitions have blanks and are delimited by , or LF and have more complicated rules. The following are equivalent:

   jd'createtable f a int,b byte 4'
   jd'createtable f a int',LF,'byte 4'
   jd'createtable';'f';'a int';'b byte 4'
   jd'createtable f a';'a int';'b byte 4'

Options follow the command, start with /, and have a fixed number (0 or more) parameters.

   jd'reads /lr /e from f'

Names

Column, table, and database names have similar validation:

  • utf-8 supported
  • RESERVEDCHARS_jd_ are not allowed in names
  • RESERVEDWORDS_jd_ are not allowed
  • the jd... prefix is not allowed in table or column names
  • the ~... prefix is not allowed
  • the +- characters are allowed in names, but should be avoided in table names because of conflicts when parsing the read from clause
  • the ^ character is used by the system in table names for ptable and should be avoided

Types

Standard types are: boolean, int, float, byte.

All standard types can have trailing shape.

jd'createtable f a int 2,b byte 4' NB. n,2 int and n,4 byte

There are also date types, and varbyte - a variable sized byte type.

Date types are stored internally as int, and converted on read/write:

edate (epochdt)

edate types are in iso 8601 format and are stored as nanoseconds before/after 2000-01-01. See tutorial epochdt.

  • edate - 2014-01-02
  • edatetime - 2014-01-02T03:04:05
  • edatetimem - 2014-01-02T03:04:05,123
  • edatetimen - 2014-01-02T03:04:05,123456789

date

date types are:

  • date stored as int with digits yyyymmdd
  • datetime stored as int with digits yyyymmddhhmmss

The csv loader supports yyyy/mm/dd vs dd/mm/yyyy.

varbyte

With average sizes less than 50, it may be better to store the data as fixed size.

Drop/Delete

A database structure maps directly to a folder structure. A database is a folder, a table is a folder in a database, and a column is a folder in a table.

A db/table/col drop cannot be undone. It would be unfortunate to inadvertently drop something that was hard to recover.

Restrictions while building a database can be a nuisance, but when things are stable it can be nice to disallow drops. This can be done with jdaccess but that is perhaps more mechanism than warranted.

jddropstop provides an easy way to prevent bad drops.

A db/table/col drop uses the utility jddeletefolder. This utility is also used in other admin activities, for example, deleting folders of csv files that have been processed.

A jddeletefolder cannot be undone. It would be unfortunate to inadvertently delete something that was hard to recover.

jddeletefolder allows delete only if certain criteria are met and this can prevent an unintended delete.