typedb / typeql

TypeQL: the power of programming, in your database
https://typedb.com
Mozilla Public License 2.0
219 stars 46 forks source link

Select all attributes (*) of a Thing #103

Closed richard-julien closed 1 year ago

richard-julien commented 4 years ago

Problem to Solve

When using Graql every attributes needed in the result must be expressed in the query. For grakn as a SQL like database it can be a bit annoying to express the 25 attributes required.

Current Workaround

No workaround, we need to express all the fields you need

Proposed Solution

Add in the language the SQL select * way of fetching data.

Proposal

Have more convention for variable naming if not specified. like. match $user isa User; has name $n; has email; get;

{ id: "V10003", n: "Julien", email: "julien@domain.io"}

And so by convention for every attributes match $user isa User; has *; get;

{ id: "V10003", name: "Julien", email: "julien@domain.io"}

flyingsilverfin commented 4 years ago

@richard-julien , as a workaround for now (though this may be expensive in terms of queries), you can do:

match $x isa User; $x has attribute $a; get; And then collect all the different attributes that come in in different answers for the same user together :)

haikalpribadi commented 4 years ago

What @flyingsilverfin suggested above is the official alternative/workaround, actually. I get that it's not entirely identical, as the attributes need to be collected from all entries in the map, as opposed to one entry containing all attributes.

Did this workaround, work for you, @richard-julien ?

richard-julien commented 4 years ago

Hi @haikalpribadi , for now we use a different approach. Will try this approach asap to see if it speedup the queries :)

flyingsilverfin commented 1 year ago

Closing for now since the has attribute $a is still the recommended approach. This can be used with a group $x to make sure the user doesn't have to collect the values themselves if they arrive out of order.