T
TypeDB5mo ago
krishnan

Wouldn't your desired approach require

Wouldn't your desired approach require declaring the plays for all 1000 attributes? Or do you just declare it once on a supertype and the plays is inherited?
15 Replies
modeller
modeller5mo ago
I'm not sure I understand @krishnan . Say I have my core attributes (i.e. the common ones before defining any actual objects) defined as follows:
define

# Attributes
attribute stix-attribute-string, value string;
attribute stix-type sub stix-attribute-string;
attribute stix-id sub stix-attribute-string;
attribute spec-version sub stix-attribute-string;
attribute labels sub stix-attribute-string;
attribute lang sub stix-attribute-string;
attribute description sub stix-attribute-string;
attribute relationship-type sub stix-attribute-string;

attribute stix-attribute-int, value int;
attribute confidence sub stix-attribute-int;

attribute stix-attribute-bool, value bool;
attribute revoked sub stix-attribute-bool;
attribute defanged sub stix-attribute-bool;

attribute stix-attribute-date, value datetime;
attribute created sub stix-attribute-date;
attribute modified sub stix-attribute-date;
attribute start-time sub stix-attribute-date;
attribute stop-time sub stix-attribute-date;

attribute stix-attribute-double, value double;
define

# Attributes
attribute stix-attribute-string, value string;
attribute stix-type sub stix-attribute-string;
attribute stix-id sub stix-attribute-string;
attribute spec-version sub stix-attribute-string;
attribute labels sub stix-attribute-string;
attribute lang sub stix-attribute-string;
attribute description sub stix-attribute-string;
attribute relationship-type sub stix-attribute-string;

attribute stix-attribute-int, value int;
attribute confidence sub stix-attribute-int;

attribute stix-attribute-bool, value bool;
attribute revoked sub stix-attribute-bool;
attribute defanged sub stix-attribute-bool;

attribute stix-attribute-date, value datetime;
attribute created sub stix-attribute-date;
attribute modified sub stix-attribute-date;
attribute start-time sub stix-attribute-date;
attribute stop-time sub stix-attribute-date;

attribute stix-attribute-double, value double;
and additional attributes just add onto that list. Assume there are 1,000 attributes and 120 composite objects, which could have the granular marking relation applied. Assume that the granular marking needs to be an optional component on the Fetch statement for the 120 objects. How should this work in practice??? Do I have to define the granular marking as possibly having any one of the 1,000 attributes?? So how is the granular marking relation defined then?
krishnan
krishnanOP5mo ago
I'm likely missing something.
How can i model this, since i cant attach a relation to any attribute, so how do i refer to them??
I assume this means you know how to do it if you were allowed to attach attributes to relations? Can you show how you do it in this case? Because Georgii's suggestion made sense to me, and I thought it would be an easy translation of your existing solution.
The issue with this solution is that assuming I have a thousand different attributes across all of the value types, then i need to define the granular marking relation in the schema with all 1,000 attributes, which seems an ugly solution to implement
I was wondering how you would have avoided this ugliness, had you been able to attach attributes to relations. I might be best off leaving this to Joshua since he's neck deep in stix. Although I am guilty (as you've often charged) of thinking in terms of toy-datasets, I find it a little hard to believe that the best way to model any real-world system involves an entity owning thousands of attributes. On the other hand, I think your scale is intriguing and would love to see if you can do some meta-programming somehow and let TypeQL do the work that your query generators are currently doing.
modeller
modeller5mo ago
Oh, my old v2 model was beautiful and very elegant The relation and attribute side are done in one or two lines, like
define
embedded sub relation,
relates pointed-to, # the object being pointed to
relates owner; # the current object

data-marking sub embedded,
relates marking as pointed-to,
relates marked as owner;

object-marking sub data-marking;

granular-marking sub data-marking,
relates object;


##### ATTRIBUTES #####

stix-attribute-string sub attribute, value string, abstract,
plays data-marking:marked;


stix-attribute-integer sub attribute, value long, abstract,
plays data-marking:marked;
etc.
define
embedded sub relation,
relates pointed-to, # the object being pointed to
relates owner; # the current object

data-marking sub embedded,
relates marking as pointed-to,
relates marked as owner;

object-marking sub data-marking;

granular-marking sub data-marking,
relates object;


##### ATTRIBUTES #####

stix-attribute-string sub attribute, value string, abstract,
plays data-marking:marked;


stix-attribute-integer sub attribute, value long, abstract,
plays data-marking:marked;
etc.
So the relation is defined in two lines, and the roles are attached to the attributes and the objects, and it all just works prefectly. This idea of making the relation own every attribute seems like a nightmare. Thoughts ? and @Joshua ?
modeller
modeller5mo ago
This is the problem. The v2 was beautiful and concise, and the v3 looks like a nightmare If you search for "granular-marking" in the above schema, section (there are an additional 3 sections) you will see the term is only used 4 times, and the definitions is so terse, its amazing. Groan, what a terrible decision not to enable attributes to play roles, imho, that was a giant step back for TypeQL for heaps of cool use cases, such as: - granular markings - IAM-based recording of access, - etc.
krishnan
krishnanOP5mo ago
So the role I'm interested in is granular-marking:marked (or rather, data-marking:marked)? I see what you're doing - You allow any attribute to play marked by just declaring your n base attribute types to play it. I just need to figure out why you can't do the same for Georgii's solution. Is it because owning a supertype of an attribute doesn't mean ownership of subtypes of the attribute is inherited? (v/s the attribute playing a role does mean subtypes of that attribute inherit the ability to play that role)
modeller
modeller5mo ago
If you guys can make it that elegant, i am all up for it. I still think its a strategic mistake not enabling attributes to play roles, as the v2 solution worked a treat. Over to you and @Joshua, @christoph.dorn and crew to work out a solution. I dont need it tonight, but some time over the next few days would be good, so its better to discuss it amongst the team Thanks mate No rush, better to get it right, and elegant imho
krishnan
krishnanOP5mo ago
Quick question though: Is there no stronger-typing rule for marked? i.e. Can any stix-object type be marked by any stix-attribute type?
modeller
modeller5mo ago
Well, I wasn't as strong on constraints when i first designed the schema, so it is admittedly a bit lax I juset opened the doors to everythoing, and then i use my Python clsses in the ORM to handle constraints
krishnan
krishnanOP5mo ago
My nose says getting stronger constraints is the way to elegance, but I can leave that to Joshua since I have 0 stix domain knowledge.
modeller
modeller5mo ago
In a way, this is also a challenge to @christoph.dorn , since taking away the ability for attributes to play roles has signifcant limitations in high end applictions
krishnan
krishnanOP5mo ago
Well you'd need to provide an example which demonstrates this. My counter-challenge to using the stix schema you've linked as counter-example is that I don't think it's tightened enough. The fact that you require declaring 1000s of ownerships may well be a positive for TypeDB - i.e. it penalises you for keeping things too open.
modeller
modeller5mo ago
The applications for an attribute playing roles are in secure environments, where one wants to mark which attributes have been read, edited, updated or deleted, by whom (IAM) and when. TypeDB cant do this application anyomore unfortunately plus obviously granular markings, on any attribute markings for language, or other purposes There is a data warehouse model for this called Arrow modelling
krishnan
krishnanOP5mo ago
Right, I see what you mean. Going to the SQL way of seeing things though, can't you just mark the modification on the owner? I agree it's counter-intuitive since we're the PERA model where attributes are supposed to be first-class citizens. You're spot on with that.
modeller
modeller5mo ago
With an atomic data model, one needs to mark atoms for various purposes, including recording CRUD actions that seems like a fairly obvious statement its not just what entity was looked at, but which parts some attributes could be marked SECURE, and thereby dependent on IAM marking entities and relations is a very coarse measure, and does not enable varying security on pieces of data this is the function of granular markings, where some attributes may be marked SECURE or PRIVATE Marking the entire entity or relation is known as an Object Marking, whereas marking at the attribute level is a Granular Marking. Quite distinct and TypwQL no longer supports it

Did you find this page helpful?