Defining the Metadata in the Admin Console

The following procedure should be performed only if you have chosen Option 2 when you initialized the database. See the topic Initializing the Database for more details.

Prerequisites

See the topic Starting the Database Server for the previous procedure.

Procedure

  1. Create an admin script file with the following content and save it as houseAdminScript.txt:
    # Schema creation for the House of Bonaparte
    
    # create a new user to connect to db
    create user napoleon passwd=bonaparte
    
    # create attribute descriptions
    create attrdesc memberName as string
    create attrdesc houseHead as boolean
    create attrdesc crownName as string
    create attrdesc crownTitle as string
    create attrdesc yearBorn as int
    create attrdesc yearDied as int
    create attrdesc reignStart as date
    create attrdesc reignEnd as date
    create attrdesc relType as string
    
    # create node type
    create nodetype houseMemberType attributes(memberName, houseHead, crownName, crownTitle, yearBorn, yearDied, reignStart, reignEnd) pkeys (memberName)
    
    disconnect
    exit
  2. Run the admin script in TGDB admin:
    tgdb-admin --url tcp://localhost:8222 --uid admin --pwd admin --file <tgdb-home>/bin/houseAdminScript.txt
    The admin console output is as shown in the following example. The metadata is also created.
    <tgdb_home>/bin>tgdb-admin --url tcp://localhost:8222 --uid admin --pwd admin --file <adminScriptFile>
    [...]
    Successfully connected to server tcp://localhost:8222 with user admin.
    # Schema creation for the House of Bonaparte
    # create a new user to connect to db
    create user napoleon passwd=bonaparte
    Successfully created user on server.
    
    # create attribute descriptions
    create attrdesc memberName as string
    Successfully created attrdesc on server.
    create attrdesc houseHead as boolean
    Successfully created attrdesc on server.
    create attrdesc crownName as string
    Successfully created attrdesc on server.
    create attrdesc crownTitle as string
    Successfully created attrdesc on server.
    create attrdesc yearBorn as int
    Successfully created attrdesc on server.
    create attrdesc yearDied as int
    Successfully created attrdesc on server.
    create attrdesc reignStart as date
    Successfully created attrdesc on server.
    create attrdesc reignEnd as date
    Successfully created attrdesc on server.
    create attrdesc relType as string
    Successfully created attrdesc on server.
    
    # create node type
    create nodetype houseMemberType attributes(memberName, houseHead, crownName, crownTitle, yearBorn,
    yearDied, reignStart, reignEnd) pkeys (memberName)
    Successfully created nodetype on server.
    
    Disconnect
    Successfully disconnected from server.
    
    exit

What to do next

See the topic Building the House of Bonaparte for the next procedure.