# Cross-data source relationships

{% hint style="success" %}
This is the official documentation of the `@forestadmin/agent` Node.js agent.
{% endhint %}

Adding as many data sources as you need is good, inter-connecting them together is better.

The relation mechanism allows you to add a relation between different data sources, regardless of their type.

{% hint style="info" %}
If you want to know more about adding relations, please refer to this [section](/developer-guide-agents-nodejs/agent-customization/relationships.md).
{% endhint %}

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');
const { createMongooseDataSource } = require('@forestadmin/datasource-mongoose');

// Plug multiple data sources to a single agent.
const agent = createAgent(options)
  .addDataSource(createSqlDataSource('postgres://user:pass@a.server:5432/mySchema'))
  .addDataSource(
    createSqlDataSource('postgres://user:pass@another.server:5432/anotherSchema'),
  )
  .addDataSource(createMongooseDataSource(require('./mongoose-models')));

// Add a relation between a Mongoose collection and a SQL collection.
agent.customizeCollection('countryFromMongoose', collection =>
  collection.addOneToManyRelation('towns', 'townsFromPostgres', {
    originKey: 'country_id',
  }),
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/getting-started/relationships.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
