Imagine we have a Classes A and B and C.
Imagine we have two object Properties “hasC” and “hasB”
how can we have a class property restriction, so is it says
A is subclass of
hasB min 1 B ("which has" hasC min 1 C)
hasC min 1 C
Where the value of hasC.C is the same for the B instance and the instance of this class A.
Where the value of hasC.C is the same for the B instance and the instance of this class A.
This kind of axiom isn't usually possible in OWL. As Ignazio mentioned in a comment, if you have a particular instance of C in mind, e.g., c73, you can use an enumerated class, like hasC some {c73} or the expression hasC value c73, but you can't do general "agreement" axioms like this. For instance, there's no way to define a "diamond hierarchy subclass" as one which has two distinct ancestors that have some common ancestor.
Related
I am a beginner at SQL and I am using Microsoft Access. I am trying to create count tables based on Object Def. However, some objects in Object Def have a related column that indicates how many objects are within that row. Most objects in Object Def are singular objects and are represented with a blank field.
I want the output to look something like this:
Object Def Total
Cat 3
Dog 4
Rat 4
You could use
SELECT object_def,
SUM(Nz(object_count, 1)) AS total
FROM table_name
GROUP BY object_def;
For ease of testing for your scenario: http://sqlfiddle.com/#!18/1e9d5/3
Otherwise, Group By gets you the objective you are trying to obtain.
I need to perform an grouped aggregate on a property of vertices of a certain class, the group by field is however a vertex two steps away from my current node and I can't make it work.
My case:
The vertex A contains the property I want to aggregate on and have n number of vertices with label references. The vertex I want to group on is any of those vertices (B, C or D) if that vertex has a defined by edge to vertex F.
A ----references--> B --defined by--> E
\---references--> C --defined by--> F
\--references--> D --defined by--> G
...
The query I thought would work is:
select sum(property), groupOn from (
select property, out('references')[out('definedBy').#rid = F] as groupOn from AClass
) group by groupOn
But it doesn't work, the inner statement gives me a strange response which isn't correct (returns no vertices) and I suspect that out() isn't supported for bracket conditions (the reason for the .#rid is that the docs I found stated that only "=" are supported.
out('references')[out('definedBy') contains F] doesn't work either, that returns the out('definedBy') for the $current vertex).
Anyone with an idea how to achieve this? In my example, the result I would like is the property in one column and the #rid of the C vertex in another. Then I can happily perform my group by aggregates.
Solved it! In OrientDB 2.1 (I'm trying rc4) there's a new clause called UNWIND (see SELECT in docs).
Using UNWIND I can do:
SELECT sum(property), groupOn from (
SELECT property, out('references') as groupOn
FROM AClass
UNWIND groupOn
) WHERE groupOn.out('definedBy')=F
GROUP BY groupOn
It could potentially be a slow function depending on the number of vertices of AClass and its references, I'll report back if I find any performance issues.
Let a and b be integer-valued attributes that may be NULL in some tuples. For each of the following conditions that may appear in a WHERE clause, describe exactly the set of (a,b) tuples that satisfy the condition, including the case where a and/or b is null.
(a) a=10 OR b=20
(b) a=10 AND b=20
(c) a<10 OR a>=10
(d) a=b
Kind of confused as to how to approach this problem. What exactly is this asking? It was in my textbook but we are learning about views and ER diagrams. Not sure how this ties into those topics.
For a) there will be two types of tuples:
a = 10 and b can be anything including null
b = 20 and a can be anything including null
From that you should be able to work out b) and c).
d) is interesting. There is only one type of tuple:
a = b and a is not null and b is not null
Null never equals anything, not even itself.
Let's say i have the following hierarchy that i use as a dimension:
Root
A1
B11
B12
...
B1N
B1Special
A2
B21
B22
...
B2N
B2Special
...
AM
BM1
BM2
...
BMN
BMSpecial
Under each of the "B" nodes there are several more nodes at different levels. Each leaf of the hierarchy has a measure associated (SUM of some fact F).
Is it possible with MDX to have the SUM of all and only the items children of the "Special" nodes?
I have to assume you want to see the sum of all 'Special' nodes only once, at the root level. In other words, you want to see just one number in your results set.
Assuming the hierarchy detailed in your original question was called 'Bob', and you had another dimension called 'Kate', you might try this...
WITH MEMBER [Bob].[Only the special levels]
AS 'Aggregate(
Filter(
{[Bob].[Name of level which holds B members].members},
InStr(1, [Bob].CurrentMember.Name, "Special") > 0
)
)'
SELECT {[Kate].defaultMember} ON ROWS,
{[Measures].[Whever you want to see aggregated]} ON COLUMNS
FROM [Cube name]
WHERE ([Bob].[Only the special levels])
This creates a new, temporary, member in the Bob dimension, which is an aggregation of several other members in the Bob dimension. We start with all the members that sit in one particular level. The Filter chooses only those members which have the word "special" in their name.
Note that InStr is a VBA function which is supported by Microsoft SSAS. It returns zero if the chosen string is not found. Alternative string searching functions may be available in other flavours of MDX.
You then use this new member in your WHERE clause, and slap your other dimensions/measures wherever you want.
What is the difference between :: and . in pig?
When do I use one vs the other?
E.g., I know that :: is need in join when a field exists in both aliases:
A = foreach (join B by (x), C by (y)) generate B::y as b_y, C::y as c_y;
and I need . when accessing group fields:
A = foreach (group B by (x,y)) generate group.x as x, group.y as y, SUM(B?z) as z;
However, do I pass B::z or B.z to SUM above instead of B?z?
In Pig, :: is used as a disambiguation tool after operations which could possibly create naming collisions. Notably, this happens with JOIN, CROSS, and FLATTEN. Consider two relations, A:{(id:int, name:chararray)} and B:{(id:int, location:chararray)}. If you want to associate names with locations, naturally you would do:
C = JOIN A BY id, B BY id;
Without the disambiguation operator, your schema would be
C:{(id:int, name:chararray, id:int, location:chararray)}
Now you can't tell which field id refers to. To avoid this, Pig will instead do
C:{(A::id:int, A::name:chararray, B::id:int, B::location:chararray)}
Likewise, you could FLATTEN two bags whose tuples have fields with the same name, and they would also collide. So the same operator is used in this case as well. When there is no such conflict, you do not need to use the full name: name is unambiguous here. To simplify C, then, you can do this:
D = FOREACH C GENERATE A::id, name, location;
The . operator, by contrast, projects fields from bags and tuples. If you have a bag b with schema {(x:int, y:int, z:int)}, the projection b.y yields a bag with just the specified field: {(y:int)}. You can project multiple fields at once with parentheses: b.(y,z) yields {(y:int, z:int)}.
When used with tuples, the result is a tuple with just the specified fields. If the tuple t has schema (x:int, y:int, z:int), then t.x is the tuple (x:int) and t.(y,z) is the tuple (y:int, z:int).
To your specific question about SUM, note that SUM along with the other summary statistic UDFs, takes a bag as its argument. Therefore, you need to create a bag with just the one field per tuple that you want to sum. Using the projection operator, .: B.z.
IIRC you get :: as a side effect after some statements. You cannot bother about it, unless (as you mentioned) a name exists inside two different prefixes.
The . is different in that you are going inside the structure.
group.x as x, group.y as y is equivalent to FLATTEN(group)
SUM(B?z) - here you should do SUM(B.z), to specify that you need a particular field to SUM.