# How do I create new linked data in my Solid pod

**URL:** <https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926>\
**Category:** Linked Data\
**Created:** [December 2, 2021, 3:18pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926 "2021-12-02T15:18:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederik](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/frederik/32/2997_2.png) [@Frederik](https://forum.solidproject.org/u/Frederik)\
**Post date:** [December 2, 2021, 3:18pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/1 "2021-12-02T15:18:42Z")

</div>

I am creating an Angular application to save linked data in a pod. I am however new to linked data and using ontologies and am trying to find the best way to create for instance a survey with questions and answers following this ontology: [The Survey Ontology](https://cefriel.github.io/survey-ontology/docs/index.html) and store it in a Solid pod. But how do I do this via the solid libraries using SolidDataset and Things? Do I need to manually set all these fields and urls or is there another way? How do I link then an Answer to a Question?

```auto
  const question= buildThing(createThing({ name: "question 1"))
  .addUrl(RDF.type, "https://w3id.org/survey-ontology#ClosedQuestion")
  .build();   

  const newAnswer = buildThing(createThing({ name: "Answer 1"))
  .addUrl(RDF.type, "https://w3id.org/survey-ontology#surveyAnswer")
  .build();   

```

Are there any code examples how similar things like this can be done with Typescript/javascript?

Thanks!

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [December 2, 2021, 6:11pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/2 "2021-12-02T18:11:47Z")

</div>

Could something in this example help you ?

> <https://github.com/scenaristeur/game-sync/blob/f2e0b2a66c92b0f5fe84a75c0151f65021e1bc75/src/plugins/solid-sync.js#L191>

---

<div class="post-metadata">

**Author:** ![Frederik](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/frederik/32/2997_2.png) [@Frederik](https://forum.solidproject.org/u/Frederik)\
**Post date:** [December 3, 2021, 1:36pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/3 "2021-12-03T13:36:32Z")

</div>

Thanks that helped! I got it working!!!

```auto
const question2= buildThing(createThing({ name: "question2"}))
    .addStringNoLocale(SCHEMA_INRUPT.text, "question 2?")
    .addUrl(RDF.type, "https://w3id.org/survey-ontology#ClosedQuestion")
    .build();  

    const question1= buildThing(createThing({ name: "question1"}))
    .addStringNoLocale(SCHEMA_INRUPT.text, "question1?")
    .addUrl(RDF.type, "https://w3id.org/survey-ontology#ClosedQuestion")
    .addUrl("https://w3id.org/survey-ontology#leadsTo", question2)
    .build();  

```

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [December 3, 2021, 4:07pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/4 "2021-12-03T16:07:40Z")

</div>

😃👍 great welcome, don’t hesitate to ask

---

<div class="post-metadata">

**Author:** ![Frederik](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/frederik/32/2997_2.png) [@Frederik](https://forum.solidproject.org/u/Frederik)\
**Post date:** [December 3, 2021, 8:55pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/5 "2021-12-03T20:55:13Z")

</div>

There is still something wrong I see.  
If I store my answers under a new dataset and I want to link the answers to the questions like follows:

```auto
 let myDataset = createSolidDataset();
              saveSolidDatasetAt(this.userService.getRootName() + "survey", myDataset, {
                fetch: this.session.fetch
              }).then((result)=>this.saveSurvey(result));
...
// saveSurvey function: 
const question1= buildThing(createThing({ name: "question1"}))
    .addStringNoLocale(SCHEMA_INRUPT.text, "question 1?")
    .addUrl(RDF.type, "https://w3id.org/survey-ontology#ClosedQuestion")
    .build();  

dataset1= setThing(result, question1);
this.question1 = question1;

...
 saveSolidDatasetAt(this.userService.getRootName() + "survey", result, {
    fetch: this.session.fetch
  }).then((result) => {
    ...
    let answerDAtaset= createSolidDataset();
          saveSolidDatasetAt(this.userService.getRootName() + "answer", 
      answerDAtaset, {
            fetch: this.session.fetch
          }).then((result)=>this.saveAnswer(result));
})

...
saveAnswer(result:any ): any {

  const answer= buildThing(createThing({ name: "answer"}))
    .addStringNoLocale(SCHEMA_INRUPT.text, this.form.get("answer")?.value)
    .addUrl(RDF.type, "https://w3id.org/survey-ontology#ClosedQuestion")
    .addUrl("https://w3id.org/survey-ontology#completesQuestion", this.question1!)
    .build(); 
   
    result = setThing(result, answer);

    saveSolidDatasetAt(this.userService.getRootName() + "answer", result, {
      fetch: this.session.fetch
    }).then((result) => {
...
}
  
  

```

then he is not linking correctly to the question. When I check my pod, it should be:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/c/c55e5d81e9a0a5da76985afb1b6af44b98e2e5d2.png)

https:// [frederikbyl.solidcommunity.net/private/survey#question1](http://frederikbyl.solidcommunity.net/private/survey#question1)  
and it’s:  
https:// [frederikbyl.solidcommunity.net/private/answers#question1](http://frederikbyl.solidcommunity.net/private/answers#question1)

So it is using the wrong base url for question1 thing… .

---

<div class="post-metadata">

**Author:** ![Frederik](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/frederik/32/2997_2.png) [@Frederik](https://forum.solidproject.org/u/Frederik)\
**Post date:** [December 3, 2021, 9:42pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/6 "2021-12-03T21:42:23Z")

</div>

Aha, it’s probably because of the following:

```auto
/**
 * A [[Thing]] whose full Subject URL will be determined when it is persisted.
 */
export declare type ThingLocal = Thing & {
    url: LocalNodeIri;
};
/**
 * Represents the BlankNode that will be initialised to a NamedNode when persisted.
 *
 * This is a Blank Node with a `name` property attached, which will be used to construct this
 * Node's full URL once it is persisted, where it will transform into a Named Node.
 *
 * @hidden Utility type; library users should not need to interact with LocalNodes directly.
 */
export declare type LocalNode = NamedNode<LocalNodeIri>;

```

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [December 4, 2021, 1:46pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/7 "2021-12-04T13:46:03Z")

</div>

We can’t see your files in private folder

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [December 4, 2021, 9:50pm UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/8 "2021-12-04T21:50:12Z")

</div>

As I understand, you want to create 2 things in the same dataset or on two dataset, quite similar to [Create two Things in a SolidDataset with @inrupt/solid-client - #2 by Vincent](https://forum.solidproject.org/t/create-two-things-in-a-soliddataset-with-inrupt-solid-client/4734/2)

---

<div class="post-metadata">

**Author:** ![Frederik](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/frederik/32/2997_2.png) [@Frederik](https://forum.solidproject.org/u/Frederik)\
**Post date:** [December 6, 2021, 8:51am UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/9 "2021-12-06T08:51:17Z")

</div>

Yes indeed, but they are in seperate SolidDatasets. I expected the url of the Thing to be absolute, but it’s relative, so it only contains the part behind the dataset url. So I fixed it with concatenating the solidDataset urls with the Thing relative urls… . not ideal…

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [December 6, 2021, 10:38am UTC](https://forum.solidproject.org/t/how-do-i-create-new-linked-data-in-my-solid-pod/4926/10 "2021-12-06T10:38:12Z")

</div>

The URL of a Thing is relative until it is saved somewhere - after all, before saving it somewhere, it cannot be known yet what the absolute URL will be.

(Keep in mind that the data is immutable, i.e. if you get a Thing from a SolidDataset, its URL won’t change even if you later save that SolidDataset. You’ll have to pull the updated Thing from the SolidDataset that represents stored data to get the full URL.)
