Initializing the Database

There are two ways to define the metadata of the database:

Option 1: Define the metadata in the initdb.conf and run the tgdb init command.

Option 2: Create the metadata via the admin console (the server needs to be initialized and started first).

Prerequisites

See the Hands-on Exercise Overview to get an overview of the exercise.

Procedure

  1. Type cd <tgdb_home>/bin and press the Enter key.
  2. Make a copy of initdb.conf and name it inithousedb.conf.
    Edit the inithousedb.conf and within the section [initdb], set the name of database to housedb.
  3. Note: Perform this step only if you have selected Option 1. Skip this step if you have selected Option 2.
    Replace the sections [attrtypes], [nodetypes], [indices] and [users] with the following metadata:
    [attrtypes]
    memberName = @type:string
    crownName	= @type:string
    houseHead	= @type:boolean @default:false
    yearBorn = @type:int
    yearDied = @type:int
    reignStart = @type:date
    reignEnd = @type:date
    crownTitle = @type:string
    relType = @type:string
    
    [nodetypes]
    houseMemberType = @attrs:memberName,crownName,yearBorn,yearDied,reignStart,reignEnd,crownTitle
    @pkey:memberName
    
    [indices]
    	
    [users]
    napoleon = @passwd:bonaparte @role:user
  4. Save the file inithousedb.conf.
  5. Initialize the database using the command tgdb -i -c <tgdb_home>/bin/inithousedb.conf
    The output of the tgdb console should be: Database initialized successfully :TGSuccess.
  6. Validate the database files, which were created successfully, placed in the <tgdb_home>/data/housedb location.

What to do next

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