vaticle-typedbvaticle-typeql

How to define a simple Address attribute in TypeDB?


I'm just getting started with TypeDB and have a basic question about the schema concepts:

How would I model that a Person has an Address? I.e. a composite attribute like an address that is composed of 3 values:

  1. city,
  2. street,
  3. ZIP code?

My understanding is that an attribute can have exactly ONE value definition, but it can own any number of other attributes.

My attempts:

street sub attribute, value string;
city   sub attribute, value string;
zip    sub attribute, value long;

(1) Attribute without value?

address sub attribute,
    // value ... (does not make sense here) ???
    owns street,
    owns city,
    owns zip;

person sub entity,
    owns address;

(2) Modeled as relation?

address sub relation,
    relates street,
    relates city,
    relates zip,
    relates subject; // ???

person sub entity,
    plays address:subject;  

(3) As entity?

address sub entity,
    owns street,
    owns city,
    owns zip;

person sub entity,
    owns address; // ??? is owning another entity possible?

Which one (if any) would be the recommended way to go?


Solution

  • An address works best as an entity because, as @2bigpigs said, an address is an entity as it has a distinct existence in the domain. Other examples of an entity include an organisation, a location or a person. You can see that an address fits right in among those.