# How to include in the query, from what super-type the attribute came from?

**URL:** https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196
**Category:** TypeQL
**Created:** [6 September 2022 19:20 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196 "2022-09-06T19:20:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mike](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mike](https://forum.typedb.com/u/mike)
#### Post date: [6 September 2022 19:20 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196/1 "2022-09-06T19:20:01Z")

</div>

Hi,

During schema introspection I need to know from what super-type (if any) every field came from.

E.g.

```auto
define
  name sub attribute, value string;
  description sub attribute, value string;

  supertype sub entity, owns name;
  subtype sub supertype, owns description;

```

When I do `match $x sub entity; $x owns $attr;` the result doesn’t seem to have the information from what super-type `name` or `description` came from. Is there a native way to find it?

---

<div class="post-metadata">

### Author: ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)
#### Post date: [7 September 2022 09:04 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196/2 "2022-09-07T09:04:04Z")

</div>

To clarify, you are trying to find the supertype of the `name` and `description` attribute types?  
You can do

```auto
match $type sub entity, owns $attr-type; $attr-type sub $attr-super-type;

```

---

<div class="post-metadata">

### Author: ![mike](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mike](https://forum.typedb.com/u/mike)
#### Post date: [7 September 2022 09:17 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196/3 "2022-09-07T09:17:24Z")

</div>

Not really that. I want to find that:

- `subtype` has two attributes, `name` and `description`
- attribute `name` has come from the `supertype`
- attribute `description` is its own attribute

---

<div class="post-metadata">

### Author: ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)
#### Post date: [7 September 2022 09:28 UTC](https://forum.typedb.com/t/how-to-include-in-the-query-from-what-super-type-the-attribute-came-from/196/4 "2022-09-07T09:28:42Z")

</div>

We should extend the language with `owns!` which would help resolve this pretty quickly!  
However in the meantime:

```auto
match $x sub entity, owns $attr-type; $x sub $super-owner; $super-owner owns $attr-type; not { $super-owner sub! $super-super-owner; $super-super-owner owns $attr-type;};

```

In other words, find the ownership, then find a supertype that also has the ownership, such that it doesn’t have a supertype that also owns the attribute-type.
