# How should embedded entities be declared in the Type Index Registry?

**URL:** https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023
**Category:** Solid App Development FAQs
**Created:** [May 9, 2020, 9:41am UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023 "2020-05-09T09:41:45Z")
**Posts on this page:** 16
**Page:** 2

<div class="post-metadata">

### Author: ![anon36056958](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon36056958](https://forum.solidproject.org/u/anon36056958)
#### Post date: [May 10, 2020, 4:57pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/21 "2020-05-10T16:57:31Z")

</div>

It may happen that the pod owner doesn’t yet have shapes of the kind the app needs. Also, the app may require the pod owner to reorganize existing indexes or shapes. All this may require some negotiation, maybe with a third party. None of this is in the spec (yet) but there’s no harm in thinking about it.

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 5:02pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/22 "2020-05-10T17:02:51Z")

</div>

> [@fuubi](#):
>
> Where does the spec proposal say that the typed index operates on an open-world assumption? I am ok with operating on an open-world assumption in general, but in that particular case of a typed index the spec should enforce a closed-world assumption.

In a linked data context I would assume open-world as a default. The document does not say anything about closed-world assumption. How can I assume the data linked from the type index be complete? Especially if “complete” is subjective and depends highly on the kind of application that is looking for data.

---

<div class="post-metadata">

### Author: ![fuubi](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fuubi](https://forum.solidproject.org/u/fuubi)
#### Post date: [May 10, 2020, 5:08pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/23 "2020-05-10T17:08:20Z")

</div>

You could assume it if the spec would enforce it. “Complete” would be objective to the type defined by the `solid:forclass` property.

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 5:15pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/24 "2020-05-10T17:15:54Z")

</div>

RDF types work differently to types on programming languages. So for example the type `https://schema.org/Movie` _does not define_ completeness in any sense. All the properties may or may not occur on resources of that type. And further: all other rdf properties from any vocabulary might occur in addition to the ones officially listed by [schema.org](http://schema.org).

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 5:18pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/25 "2020-05-10T17:18:05Z")

</div>

Coming back to the original question, I would do it like this:

`https://pod.example.com/movies/spirited-away` :

```auto
@prefix : <#>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
@prefix schema: <https://schema.org/>.

:it
    schema:Movie;
    schema:name "Spirited Away".
:watch-action
    a schema:WatchAction;
    schema:object :it.

```

And in the type index:

```auto
<#movies> a solid:TypeRegistration;
    solid:forClass schema:Movie;
    solid:instanceContainer </movies/>.

<#watch-actions> a solid:TypeRegistration;
    solid:forClass schema:WatchAction;
    solid:instanceContainer </movies/>.

```

---

<div class="post-metadata">

### Author: ![fuubi](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fuubi](https://forum.solidproject.org/u/fuubi)
#### Post date: [May 10, 2020, 5:19pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/26 "2020-05-10T17:19:27Z")

</div>

> [@NoelDeMartin](#):
>
> When I say it “lies” I mean that semantically it doesn’t contain the actions, only the movies. When I perfrom a GET `/movies/` I get the following response:

I am not sure it that is legit. But you could try somthing like this:

```auto
@prefix : <#> .
@prefix movies: <./> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix schema: <http://schema.org/> .

movies:spirited-away
    a ldp:Resource,
                           schema:Movie ;
    schema:name "Spirited Away" ;
    schema:potentialAction [
                               schema:WatchAction [schema:agent <https://alice.com/profile/card#me> ;] ;
                           ] ;
.

```

---

<div class="post-metadata">

### Author: ![fuubi](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fuubi](https://forum.solidproject.org/u/fuubi)
#### Post date: [May 10, 2020, 5:20pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/27 "2020-05-10T17:20:40Z")

</div>

> [@aveltens](#):
>
> Coming back to the original question, I would do it like this:

Haha, I was just thinking the same, we drifted away 😁

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 5:24pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/28 "2020-05-10T17:24:11Z")

</div>

> [@fuubi](#):
>
> I am not sure it that is legit. But you could try somthing like this:

I think this way you are saying, that alice might potentially watch the movie, but not that she did it, so it is something different

---

<div class="post-metadata">

### Author: ![fuubi](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fuubi](https://forum.solidproject.org/u/fuubi)
#### Post date: [May 10, 2020, 5:39pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/30 "2020-05-10T17:39:57Z")

</div>

> [@aveltens](#):
>
> I think this way you are saying, that alice might potentially watch the movie, but not that she did it, so it is something different

Ah, you’re right. I missed that 🙈

---

<div class="post-metadata">

### Author: ![NoelDeMartin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/noeldemartin/32/3144_2.png) [@NoelDeMartin](https://forum.solidproject.org/u/NoelDeMartin)
#### Post date: [May 10, 2020, 6:01pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/31 "2020-05-10T18:01:12Z")

</div>

> [@aveltens](#):
>
> And in the type index:
> 
> ```auto
> <#movies> a solid:TypeRegistration;
> solid:forClass schema:Movie;
> solid:instanceContainer </movies/>.
> 
> <#watch-actions> a solid:TypeRegistration;
> solid:forClass schema:WatchAction;
> solid:instanceContainer </movies/>.
> 
> ```

Ok thanks, that’s what I’ll do :).

I thought documents needed to have one “main entity” given the `ldp:contains` property pointing to the url, but it makes sense that they define only the document and not the entities defined inside.

This actually explains why the information that comes with the container request about its resources is only this:

```auto
movies:spirited-away
    a turtle:Resource, ldp:Resource;
    terms:modified "2020-04-13T13:53:30Z"^^XML:dateTime;
    posix:mtime 1586786010.248;
    posix:size 673.

```

Instead of:

```auto
movies:spirited-away
    a turtle:Resource, ldp:Resource, schema:Movie;
    terms:modified "2020-04-13T13:53:30Z"^^XML:dateTime;
    posix:mtime 1586786010.248;
    posix:size 673.

```

I still think it’s difficult to match actions with movies without crawling all the documents in a pod, but it won’t be a problem for my application if I assume they are in the same document as the movie. It’s semantically correct so at least other apps would understand it.

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 6:17pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/32 "2020-05-10T18:17:26Z")

</div>

> [@NoelDeMartin](#):
>
> I still think it’s difficult to match actions with movies without crawling all the documents in a pod, but it won’t be a problem for my application if I assume they are in the same document as the movie. It’s semantically correct so at least other apps would understand it.

Why do you have to assume they are in the same document?

You can just “follow your nose”. In ldflex I would do it like this:

```auto
const movie = await data["https://pod.example.com/movies/spirited-away#watch-action"].schema_object;
const movieName = await data[movie].schema_name;

```

This code will work no matter if the movie URI base on the same document, or completely somewhere else.

I would not like it, if your app breaks, when I reorganize my data and seperate the watch actions from the movies 😉

---

<div class="post-metadata">

### Author: ![NoelDeMartin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/noeldemartin/32/3144_2.png) [@NoelDeMartin](https://forum.solidproject.org/u/NoelDeMartin)
#### Post date: [May 10, 2020, 6:39pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/33 "2020-05-10T18:39:15Z")

</div>

> [@aveltens](#):
>
> You can just “follow your nose”. In ldflex I would do it like this:
> 
> ```auto
> const movie = await data["https://pod.example.com/movies/spirited-away#watch-action"].schema_object;
> const movieName = await data[movie].schema_name;
> 
> ```

I like the idea of “following my nose”, but that’s why I raised concerns with movies not pointing to watch actions, only actions pointing to movies. Imagine I have a movie (so everything I know is `https://pod.example.com/movies/spirited-away`). How would I know where to look for a watch action If I don’t assume it’s on the same document?

In your example you are starting with the action. But my application will browse movies, not actions so the trail my nose will follow starts with a movie.

The reason why I have them inside of the same document is because I want to avoid doing too many requests, specially if I have to wait for one to finish to find the url of the next document.

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 7:34pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/34 "2020-05-10T19:34:10Z")

</div>

It is totally fine to place it in the same document. What I am saying is, you must not assume it will always be there.

But there is another thing to differ. As already mentioned the thing is not the same as the document about the thing. This also means, there may be several documents containing statements about a thing. Therefore it is totally possible to place the watch action into a document of it’s own, and still have a statement that relates Movie and WatchAction in the movie document.

Example:

`https://pod.example.com/movies/spirited-away` :

```auto
@prefix : <#>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
@prefix schema: <https://schema.org/>.

:it
    schema:Movie;
    schema:name "Spirited Away".

</watch-actions/watched-spirited-away#it>
    schema:object :it.

```

In turtle there is no need for a “reverse property” like in JSON-LD, because statements can be made in any direction anyway. You can “follow your nose” _backwards_, by looking for a `schema:object` relation, where the movie is the `object` instead of the `subject`. This works, no matter if the watch-action is “fully” described in the same document or in a document of it’s own. Of course the latter involves an additional request, but it is far from “crawling all the documents in a pod”.

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 10, 2020, 7:42pm UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/35 "2020-05-10T19:42:58Z")

</div>

I just took a look at ldflex and think it is possible to actually use `@reverse` properties in a custom context. If you do so following your nose starting from the watch-action would not be any different:

```auto
const watchAction = await data["https://pod.example.com/movies/spirited-away#it"].schema_object_of;
const agent = await data[watchAction].schema_agent;

```

Be aware that this only affects the _querying_, not how the data is stored as turtle!

---

<div class="post-metadata">

### Author: ![NoelDeMartin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/noeldemartin/32/3144_2.png) [@NoelDeMartin](https://forum.solidproject.org/u/NoelDeMartin)
#### Post date: [May 11, 2020, 5:53am UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/36 "2020-05-11T05:53:27Z")

</div>

> [@aveltens](#):
>
> Example:
> 
> `https://pod.example.com/movies/spirited-away` :
> 
> ```auto
> @prefix : <#>.
> @prefix ldp: <http://www.w3.org/ns/ldp#>.
> @prefix schema: <https://schema.org/>.
> 
> :it
> schema:Movie;
> schema:name "Spirited Away".
> 
> </watch-actions/watched-spirited-away#it>
> schema:object :it.
> 
> ```

Ok, in this case I’d be assuming that at least the `schema:object` property of the watched action is in the same document right?

So this:

> [@aveltens](#):
>
> I would not like it, if your app breaks, when I reorganize my data and seperate the watch actions from the movies 😉

Would still happen. If you remove the action, including it’s `schema:object` property, it’s not entirely wrong that my application stops working?

---

<div class="post-metadata">

### Author: ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)
#### Post date: [May 11, 2020, 6:50am UTC](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023/37 "2020-05-11T06:50:54Z")

</div>

In short: yes, agreed.

But let me frame it differently to explain my reasoning:

```auto
</watch-actions/watched-spirited-away#it>
    schema:object :it.

```

I do not call this “property of the watch action”. It is a statement linking the movie to the watch-action. It is a statement about the watch action and it is a statement about the movie as well. If you remove it from the movie document you are removing a statement about the movie, so yes, this might break things, because I stop applications from following their nose by removing it.

[Previous page](https://forum.solidproject.org/t/how-should-embedded-entities-be-declared-in-the-type-index-registry/3023.md?page=1)
