Skip to content

Commit

Permalink
Defining an indexer data schema (#771)
Browse files Browse the repository at this point in the history
### Description

![Screenshot 2025-01-15 at 5.06.34 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/vIwavW9noSx0eb70aDLz/e37ad4a5-027a-4a66-886c-5910b4bd522d.png)

### Checklist
<!-- Read the Nextra Contributor's Guide here: https://aptos.dev/en/developer-platforms/contribute -->

- If any existing pages were renamed or removed:
  - [x] Were redirects added to [next.config.mjs](../apps/nextra/next.config.mjs)?
  - [x] Did you update any relative links that pointed to the renamed / removed pages?
- Do all Lints pass?
  - [x] Have you ran `pnpm fmt`?
  - [x] Have you ran `pnpm lint`?
  • Loading branch information
rtso authored Jan 15, 2025
1 parent 642a174 commit e5a457e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/nextra/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ export default withBundleAnalyzer(
destination: "/en/build/indexer/indexer-sdk/documentation/setup",
permanent: true,
},
{
source: "/indexer/indexer-sdk/documentation/define-schema",
destination:
"/en/build/indexer/indexer-sdk/documentation/define-schema",
permanent: true,
},
{
source: "/indexer/indexer-sdk/documentation/create-processor",
destination:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default {
setup: { title: "Initial Setup" },
"define-schema": {
title: "Defining a Data Schema",
},
"create-processor": {
title: "Create a Processor",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: "Defining a Data Schema"
---

# Defining a Data Schema

The first step with indexing is choosing a database and defining a schema for the data that you want to store.

## Schema Considerations
When designing an indexer data schema, consider the following:
- Customizability: A schema serves as an interface for your dApp to access data tailored to your specific contract or application.
Ensure your schema is customized to meet your dApp's unique requirements.
- Query Optimization: A well-designed schema can enable more efficient data retrieval, supporting advanced operations such as aggregations, complex filtering, and table joins.
- Enhanced Performance: Schema design can significantly improve your dApp's performance.
By using the indexer, a single indexer query can often replace multiple queries to the fullnode.

## Aptos Core Processors
All data exposed by the [Indexer API](../../aptos-hosted.mdx) is initially indexed using custom processors.
Each core processor indexes a specific type of data.
You can explore the [full list of processors](https://github.com/aptos-labs/aptos-indexer-processors/tree/main/rust/sdk-processor/src/processors) and the [complete indexer data schema](https://github.com/aptos-labs/aptos-indexer-processors/blob/main/rust/processor/src/db/postgres/schema.rs).

The Aptos core processors and the [Quickstart Guide](../quickstart.mdx) use [PostgreSQL](https://www.postgresql.org/) as the database and [Diesel](https://diesel.rs/) as the ORM.
However, you are free to choose any database or ORM that fits your needs.
Popular alternatives include [SeaORM](https://www.sea-ql.org/SeaORM/) and [SQLx](https://github.com/launchbadge/sqlx).
Setting up a database and using an ORM is beyond the scope of these tutorials.
If you need guidance, refer to the tutorials linked above for more information.

0 comments on commit e5a457e

Please sign in to comment.