Notes about schema for rdf / first lab

Allikas: Lambda

Notes written during the lecture:

Our assumed input:

object    property   value            
<a1>      <name>     "john"^^string
<a1>      <country>  "usa"^^string

<a2>      <neighbour>  <a1>

recommended structure for import:

Three varchar fields as-is input data (obj, prop, val) plus metainfo of your choice (id is highly recommended).

  id: autoincrement int
  (optionally ts: timestamp)
  (optionally status: char or boolean etc)
  (optionally even more metainfo fields)
  obj : varchar  
  prop : varchar
  val : varchar

alternatively could encode type as a separate column
optionally could make a table for unique names, recommendation
not to bother with this:

  id: autoincrement int
  name: <a1>

and making the obj and prop columns int, values pointing to names table

Example query for search by two fields: join needed for each 

select obj from geo as geo1, geo as geo2 where 
geo1.prop='<name>' and geo1.val='"john"^^string' and
geo2.prop='<country>' and geo2.val='"usa"^^string' and

Recommended: make a second table with json

A new table geojs like this:

id object info
   <a1>   {"<name>": ["john"^^string","pete"^^string], 
           "<country>":  ["usa"^^string"],

Populate by writing a program working over the first table.

Worse alternative as an example:

		   ["<country>"  "usa"^^string]]