Discussion Forum

designing schema in typeDB

I am new to graphDB and typeDB , i was trying to to design a knowledge base for restaurant, menu, food. I am not quite sure how to make relations in TypeDB, Can someone help me out?
This is how designed ER diagram, I guess it’s right

define
# entities

restaurant sub entity,
    has name,
    has website,
    has contact,
    has info,
    has location,
    has opening-hour,
    has closing-hour;

food sub entity, 
    key name
    has price
    has cuisine
1. ```
define
  restaurant sub entity, owns ..., owns ... , owns ... , plays ownership:owner serves:server;
  menu sub entity, owns ... , owns ... , owns ... , plays contains:container, plays ownership:owned;
  dish sub entity, owns ... , owns ... , owns ... , plays contains:entry, plays serves:served
  contains sub relation, relates entry, relates container;
  ownership sub relation, relates owner,  relates owned;
  serves sub relation, relates server, relates served;

Looks like you’re already basically there with writing out the schema, except you’re using 1.8.x syntax. Have you read the docs at Introduction | Vaticle ?

You define a relation as I showed you in your second snippet:

  contains sub relation, relates entry, relates container;

@joshua , this is the code you mentioned in discord channel https://discordapp.com/channels/665254494820368395/672562706284412935/897117345556873277

i checked the docs, the syntax is correct right? (i haven’t mentioned the attributes)

define
restaurant sub entity,
  plays ownership:owner,
  plays serves:server,
  owns name @key,
  owns website,
  owns phone-number,
  owns info,
  owns location,
  owns opening-hour,
  owns closing-hour;

menu sub entity,
  plays contains:container,
  plays ownership:owned,
  owns name;

dish sub entity, 
  plays contains:entry,
  plays serves:served,
  owns name,
  owns price,
  owns cuisine,
  owns info;

contains sub relation,
    relates entry,
    relates container;

ownership sub relation,
    relates owner, 
    relates owned;

serves sub relation,
    relates server,
    relates served;

name sub attribute,
  value string;
website sub attribute,
  value string;
phone-number sub attribute,
  value string;
info sub attribute,
  value string;
location sub attribute,
  value string;
opening-hour sub attribute,
  value datetime;
closing-hour sub attribute,
  value datetime;
price sub attribute,
  value long;
cuisine sub attribute,
  value string;
1 Like

Looks great! It should be easy to load this into console and play with some data to load into it