Wagyū DatabaseDeadLetter Data Arrays
View tutorials overview
Introduction
Databases or more correctly DeadLetter Data Arrays are used to hold object information for Conversations.Conversations can also be linked to conventional databases using API's or conversion toolsets.
The Library & Conversation used are linked below, for both comparison and ease of execution.
Everything shown in blue must be substituted with your own values.
This tutorial will not deal with the initial establishment of DeadLetter or your web server/web presence.
What you'll learn
- | How to configure a basic Array |
---|---|
- | How to automatically insert objects into an Array |
- | How to setup CHAD parameters for an Array |
What you'll need
- | A Github: in this example we're using Github (as host) but you could substitute any service or your own VPS |
---|---|
- | html POST endpoint you'll need somewhere to receive output from the 'database' |
- | Author Key: it goes without saying you'll need an Author Key - ideally setup with a Parcel endpoint |
Step One - initial configuration
Before we go any further we need to setup an Array to familiarise yourself with Arrays read the walk through.The Array Brokering Library shown below is what we'll be using to manage our database, in this example we're sorting Wagyu (和牛, Wagyū, "Japanese beef") cattle (calves).
_NAME [ //CALL WAGYU-SORTING -- BND /RW CLASS #0.00 ]
_USER [ ^FUSE ?DLD.KEYSET_ ]
_AUTHORITY [ //SET OB.D5 -- 00.000 //SET OB.D5_1 -- 00.500 //SET WING_STATE OB.D5_* -- 00.500 ] [ //SET OB.D6 -- 00.500 //SET WING_STATE OB.D6_* -- 00.500 ] [ //SET OB.D7 -- 00.500 //SET WING_STATE OB.D7_* -- 00.500 ] [ //SET OB.D8 -- 00.500 //SET WING_STATE OB.D8_* -- 00.500 ] [ //SET OB.D9 -- 00.500 //SET WING_STATE OB.D9_* -- 00.500 ]
_REQUEST [ //CALL A: *$ ]
_POST [ //POST DLD.KEYSET-DO-ID: ]
Array Brokering - Name
The first step in brokering is setting your name Schemer, as one of the five fixed Array attributes - in this case _NAMEHere we're setting the Array name to WAGYU-SORTING & binding it's value to the Naming Class (in this case OB.D0 as set in the Object Management Library.
_NAME [ //CALL WAGYU-SORTING -- BND /RW CLASS #0.00 ]
Array Brokering - User
Next we need to set the Authors able to update/manage the Array, as one of the five fixed Array attributes - in this case _USERHere we're locking the Array users to DLD.KEYSET or in other words the Author of the Brokering Library and in-turn the Array. This information is stored in OB.D1 as set in the Object Management Library.
_USER [ ^FUSE ?DLD.KEYSET_ ]
Array Brokering - Authority
Before we go any further we need to set our Authorities, as we're managing cattle (Objects) and organising them into various states (classes) we'll need the following;OB.D5 | used for 'new' objects |
---|---|
OB.D6 | used for 'type' of objects |
OB.D7 | used for 'state' of objects |
OB.D8 | used for 'grade' of objects |
OB.D9 | used for 'heritage' of objects |
Here we're informing deadCL which OB (Object Classes) we'll be using. We're using the default values 00.000 for the master class & 00.500 for each sub-class. This information is stored in OB.D2 as set in the Object Management Library.
_AUTHORITY [ //SET OB.D5 -- 00.000 //SET OB.D5_1 -- 00.500 //SET WING_STATE OB.D5_* -- 00.500 ] [ //SET OB.D6 -- 00.500 //SET WING_STATE OB.D6_* -- 00.500 ] [ //SET OB.D7 -- 00.500 //SET WING_STATE OB.D7_* -- 00.500 ] [ //SET OB.D8 -- 00.500 //SET WING_STATE OB.D8_* -- 00.500 ] [ //SET OB.D9 -- 00.500 //SET WING_STATE OB.D9_* -- 00.500 ]
Array Brokering - Request
in-order to make requests your Array requires instructions on how to treat each one. As one of the five fixed Array attributes - in this case _REQUESTTo maintain our requests within the Array, we can inform deadCL with *$ This information is stored in OB.D3 as set in the Object Management Library.
_REQUEST [ //CALL A: *$ ]
Array Brokering - Post
The last step for Brokering your new Array in setting the POST parameters. As one of the five fixed Array attributes - in this case _REQUESTYour Broker should set the POST parameter (as your Author key) [ //POST DLD.KEYSET-DO-ID: ] This step is crucial to interact with your Array.
This information is stored in OB.D4 as set in the Object Management Library.
_POST [ //POST DLD.KEYSET-DO-ID: ]
Step Two - Defining our state changes
Okay, now it's time to build the Library. For the purposes of this example we're using a series of (very) basic rules.Here our library is simply organising inbound objects to prepare for insertion and cross comparison with Arrayed objects.
CALF; RECORD -- OB.D5 { STORE -- NEW = OB.D5_1 STORE -- REMOVED = OB.D5_2 STORE -- CONSOLIDATED = OB.D5_* -N VAL_00-T.M-T.H-T.D } TYPE; RECORED -- OB.D6 { STORE -- KUROGE = OB.D6_1_* STORE -- AKAGE = OB.D6_2_* STORE -- NIHON = OB.D6_3_* STORE -- MUKAKU = OB.D6_4_* -N VAL_OB.D5_* -- VALUE } STATE; RECORED -- OB.D7 { STORE -- ALIVE = OB.D7_1_* STORE -- DEAD = OB.D7_2_* STORE -- SLAUGHTERED = OB.D7_3_* STORE -- UNBORN = OB.D7_4_* -N VAL_OB.D5_* -- VALUE } GRADE; RECORED -- OB.D8 { STORE -- A = OB.D8_1_* STORE -- B = OB.D8_2_* STORE -- C = OB.D8_3_* -N VAL_OB.D5_* -- VALUE } HERITAGE; RECORED -- OB.D9 { STORE -- D-F = OB.D9_1_* STORE -- D-M = OB.D9_2_* -N VAL_OB.D5_* -- VALUE }
Initial State
Our first KC handles both the base state (the state considered as true before inspection) & the state when variable values are inserted.We're usingOB.D5_1 to record the base state. received & OB.D5_* to record the variable values inserted, as in this instance we don't care which class they're recorded into - provided it's not OB.D5_1 or OB.D5_2.
CALF; RECORD -- OB.D5 { STORE -- NEW = OB.D5_1 STORE -- REMOVED = OB.D5_2 STORE -- STATE = OB.D5_* -N VAL_00-T.M-T.H-T.D }
Type Record
The next stage within our Library records Wagyu type, Here we're storing records for the four different types of Wagyu recognised in Japan.
TYPE; RECORED -- OB.D6 { STORE -- KUROGE = OB.D6_1_* STORE -- AKAGE = OB.D6_2_* STORE -- NIHON = OB.D6_3_* STORE -- MUKAKU = OB.D6_4_* -N VAL_OB.D5_* -- VALUE }
State Record
In the context of this database example we use STATE to indicate the current state of the Wagyu (object).
STATE; RECORED -- OB.D7 { STORE -- ALIVE = OB.D7_1_* STORE -- DEAD = OB.D7_2_* STORE -- SLAUGHTERED = OB.D7_3_* STORE -- UNBORN = OB.D7_4_* -N VAL_OB.D5_* -- VALUE }
Grade Record
Wagyu is traditionally split into three 'yield scores' they're A (Yield of cut is above the average range), B (average), C (below average range).We'll store these values in OB.D8_*
GRADE; RECORED -- OB.D8 { STORE -- A = OB.D8_1_* STORE -- B = OB.D8_2_* STORE -- C = OB.D8_3_* -N VAL_OB.D5_* -- VALUE } HERITAGE; RECORED -- OB.D9 { STORE -- D-F = OB.D9_1_* STORE -- D-M = OB.D9_2_* -N VAL_OB.D5_* -- VALUE }
Heritage Record
We're using the Heritage value to store the direct lineage of each Calf, we're only storing the direct parentage for the purposes of this example.We'll store these values in OB.D9_*
HERITAGE; RECORED -- OB.D9 { STORE -- D-F = OB.D9_1_* STORE -- D-M = OB.D9_2_* -N VAL_OB.D5_* -- VALUE }
Step Three - Setting up
Next we need to setup supporting information in-order for the Conversation to run correctly.
SORT; {arrange systematically in groups; separate according to type} CHANGE; {change in state, becomes different} {a change of place, position, or state} COMPARE; {have a specified relationship with another thing or person in terms of nature or quality} REVIEW; {Assess with the intention of instituting change if necessary} *INPUT; PARCEL- C {57a2BH} = DATA-000 PARCEL- A {0xr2BH} = MANAGE-000 PARAMETERS; { 'CALF' = OB.D5_* 'NEW' = OB.D5_1 'REMOVED' = OB.D5_2 'TYPE' = OB.D6_* 'KUROGE' = OB.D6_1_* 'AKAGE' = OB.D6_2_* 'NIHON' = OB.D6_3_* 'MUKAKU' = OB.D6_4_* 'STATE' = OB.D7_* 'ALIVE' = OB.D7_1_* 'DEAD' = OB.D7_2_* 'SLAUGHTERED' = OB.D7_3_* 'UNBORN' = OB.D7_4_* 'GRADE' = OB.D8_* 'A; = OB.D8_1_* 'B' = OB.D8_2_* 'C' = OB.D8_3_* 'HERITAGE' = OB.D9_* 'D-F' = OB.D9_1_* 'D-M' = OB.D9_2_* } ALL = { CONSOLIDATED = OB.D5_* } QUERIES{CALF, TYPE, STATUS, GRADE, HERITAGE, ALL} POST; PARCEL- C PARAMETERS -- API.DOMAIN.COM
Definitions
By default deadCL pulls all definitions from the Oxford English Dictionary however here we've defined a strict meaning for each key-word used within the Conversation.In this case we're only concerned with;
Sort | this allows us to reliably use MBS to divide a single or multi-parted value into seperate Object classes within the Array |
---|---|
Change | this enables us to use MBS 'understand' changes to object state (i.e alive to dead) |
Review | this allows us to easily use MBS compare inputted values for mistakes, duplications & various other functions |
Compare | this permits us to use MBS to cross-compare objects contained within different classes |
SORT; {arrange systematically in groups; separate according to type} CHANGE; {change in state, becomes different} {a change of place, position, or state} COMPARE; {have a specified relationship with another thing or person in terms of nature or quality} REVIEW; {Assess with the intention of instituting change if necessary}
Inputs
Next we need to setup our object inputs, here we're setting up a single CHAD endpoint to receive object values.You'll need to ensure your AK is configured with the appropriate endpoint, with a value of 57a2BH.
While our management input should be set to 0xr2BH & is using Arnold.
*INPUT; PARCEL- C {57a2BH} = DATA-000 PARCEL- A {0xr2BH} = MANAGE-000
API configuration
To interact with the Array, you'll need to configure how deadCL handles request (inbound and outbound)The Parameters we're defining are;
- | TYPE |
---|---|
- | STATE |
- | GRADE |
- | HERITAGE |
- | NEW |
- | CALF |
- | REMOVED |
Theses, are used to define which Array Class you're trying to query, Coupled with a fixed query
This configuration provides complete (read-only) access to the Array, over the 'manage' endpoint.
PARAMETERS; { 'CALF' = OB.D5_* 'NEW' = OB.D5_1 'REMOVED' = OB.D5_2 'TYPE' = OB.D6_* 'KUROGE' = OB.D6_1_* 'AKAGE' = OB.D6_2_* 'NIHON' = OB.D6_3_* 'MUKAKU' = OB.D6_4_* 'STATE' = OB.D7_* 'ALIVE' = OB.D7_1_* 'DEAD' = OB.D7_2_* 'SLAUGHTERED' = OB.D7_3_* 'UNBORN' = OB.D7_4_* 'GRADE' = OB.D8_* 'A; = OB.D8_1_* 'B' = OB.D8_2_* 'C' = OB.D8_3_* 'HERITAGE' = OB.D9_* 'D-F' = OB.D9_1_* 'D-M' = OB.D9_2_* } ALL = { CONSOLIDATED = OB.D5_* } QUERIES{TYPE, STATUS, GRADE, HERITAGE, ALL}
Set POST endpoint
Here we'll set the POST endpoint,Theses, are used to define which Array Class you're trying to query, coupled with a fixed query - it is also where all POST payload will be sent.
POST; PARCEL- C PARAMETERS -- API.DOMAIN.COM
Step Four - The Conversation
Unlike most Conversations we're only handling the organisation of objects observed over the input and their insertion into the Array with a handful of checks.As a result our Conversation is rather sparse.
dld.keyset('NAME_YOURNAME') *Catch-all - libs *Catch-lib -R @WAGYU_MANAGEMENT_2019 *input; [DATA-000] OBSERVE; CALF, NEW CHECK; compare [DATA-000], CONSOLIDATED DISCARD; [DATA-000], ignore, present = 'CONSOLIDATED' HERITAGE-CONFIRM; CHECK, D-F RECORD = CONSOLIDATED 'OB.D5_*' PRESENT CHECK, D-M RECORD = CONSOLIDATED 'OB.D5_*' PRESENT ignore, [DATA-000] if = 'absent' SUBMIT; divide [DATA-000], PARAMETERS = 'STORE' *END*
Setting your input
It goes without saying but you'll need to set an input address; here we've set it as our 'data' Parcel input.
*input;
[DATA-000]
New Cattle
Here, We're looking for a payloads received marked as 'CALF' as defined in our parameters; the value must be unique as it's used to link each Object Class to the 'calf'
OBSERVE;
CALF, NEW
Handling 'States' Looking for duplicates
Before we can enter the values into our Array we need to prevent our Conversation from writing new object data over existing values - This is fortunately serves a double purpose here preventing duplications.Our first check simply 'compares' the entire payload '[DATA-000]' to our Consolidated record. If they are deemed a 'match' the payload is discarded (ignored).
CHECK; compare [DATA-000], CONSOLIDATED DISCARD; [DATA-000], ignore, present = 'CONSOLIDATED'
Basic lineage check
As Wagyu is heavily regulated breeders keep complex records for parentage this check confirms the existence (within the Array) of both parents).If a match can't be found the payload is once again discarded.
HERITAGE-CONFIRM; CHECK, D-F -- D-M CONNECTION CHECK, D-F RECORD = CONSOLIDATED 'OB.D5_*' PRESENT CHECK, D-M RECORD = CONSOLIDATED 'OB.D5_*' PRESENT ignore, [DATA-000] if = 'absent'
Store States
Finally we're storing the values into our Array. Under the values specified in our Library.This means we can easily recall the contents of our Array at a later stage.
SUBMIT; divide [DATA-000], PARAMETERS = 'STORE'
You're Done!
By now you should have a (very) basic understanding of Arrays within DeadLetter (deadCL)While we're only handling JSON payloads in this example, this can easily be modify to review different object data such as Number-plates, people etc.