> ## Documentation Index
> Fetch the complete documentation index at: https://docs.astrobee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Layer

> Define how your business concepts map to your raw data

The Data Layer is AstroBee's semantic modeling feature. It creates a business-friendly abstraction over your raw data, allowing you to ask questions in plain English without knowing where the data lives or how tables connect.

## Overview

A data layer consists of:

* **Entities** — Business concepts like Customer, Product, or Order
* **Properties** — Attributes of entities (e.g., Customer.email, Product.price)
* **Relationships** — How entities connect (e.g., Customer → Order)

<Frame caption="Graph view showing entities and their relationships">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/26-data-layer-graph.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=0c904c0299e4a3ca30f009c8336c517b" alt="Data layer graph" width="2850" height="1608" data-path="screenshots/26-data-layer-graph.png" />
</Frame>

## Accessing the Data Layer

Click **Data Layer** in the sidebar to open the editor. The editor has three main tabs:

| Tab            | Purpose                                      |
| -------------- | -------------------------------------------- |
| **Data Layer** | View and edit entities in Graph or List view |
| **Sources**    | Connect data sources to your data layer      |
| **Linkages**   | View discovered relationships between tables |

## Generating a Data Layer

### Connect Sources First

Before generating, connect at least one data source:

1. Click the **Sources** tab
2. Find available data sources
3. Click **Connect** to link them to this data layer

<Frame caption="Sources tab showing available data sources">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/20-data-layer-sources-available.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=4589b7f9133f97eb92730d4531c85f6e" alt="Sources tab" width="2850" height="1608" data-path="screenshots/20-data-layer-sources-available.png" />
</Frame>

### AI-Assisted Generation

Click **Generate Data Layer from selected Sources** to start the AI-assisted workflow:

1. **Business Questions** — AstroBee asks what you want to analyze (customer behavior, sales performance, etc.)
2. **Terminology** — Define your business language (orders vs. sales vs. transactions)
3. **Generation** — AI analyzes your data and creates entities with proper bindings

<Frame caption="AI asks clarifying questions about your business">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/22-generating-data-layer.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=f972e77deb8c91bc35eb61f8f96197e0" alt="Generation questionnaire" width="2850" height="1608" data-path="screenshots/22-generating-data-layer.png" />
</Frame>

The AI will:

* Discover tables and columns in your data sources
* Match entities to tables by name similarity
* Map properties to columns based on data types and meanings
* Create relationships based on discovered linkages

<Frame caption="Summary of generated entities and relationships">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/25-data-layer-generated.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=33012085c9fecd1c0fff7d9d65fef8a1" alt="Generation summary" width="2850" height="1608" data-path="screenshots/25-data-layer-generated.png" />
</Frame>

## Viewing Your Data Layer

### Graph View

The default view shows entities as nodes and relationships as edges:

<Frame caption="Interactive graph visualization">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/26-data-layer-graph.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=0c904c0299e4a3ca30f009c8336c517b" alt="Graph view" width="2850" height="1608" data-path="screenshots/26-data-layer-graph.png" />
</Frame>

* **Nodes** represent entities (dimension, fact, or bridge types)
* **Edges** show relationships with cardinality (1:N, N:N)
* Click **Expand to fullscreen** for a larger view

### List View

Click **List View** for a detailed breakdown:

<Frame caption="List view with all entity details">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/27-data-layer-list-view.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=31cd93564e8d9ab10e9ded5434d954a9" alt="List view" width="2850" height="1608" data-path="screenshots/27-data-layer-list-view.png" />
</Frame>

The list view shows:

* Entity names and descriptions
* All properties with types (Dimension/Measure) and data types
* Field descriptions
* Relationships with join conditions

## Editing Your Data Layer

### Chat-Based Editing

Use the chat input at the bottom to make changes in natural language:

```
Add a property called "lifetime_value" to Customer that calculates
total spend across all orders
```

```
Create a relationship between Product and OrderItem
```

AstroBee interprets your request, makes the changes, and shows them in the Review panel.

### Direct Editing

In List View, click on any element to edit directly:

* Click entity names to rename
* Click descriptions to update
* Click properties to modify types or descriptions

## Reviewing Changes

All changes go to a **scratchpad** before being published. Click the **Review** button to see pending changes:

<Frame caption="Review panel showing pending changes">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/28-review-panel.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=2cd9cd83c6bba56789ec89dc12937bfc" alt="Review panel" width="2850" height="1608" data-path="screenshots/28-review-panel.png" />
</Frame>

The review panel shows:

* **Created** items (new entities, properties, relationships)
* **Modified** items (updated definitions)
* **Deleted** items (removed elements)

Actions:

* **Publish all pending changes** — Apply changes and create a new version
* **Discard all pending changes** — Revert the scratchpad

## Version History

Every time you publish, AstroBee creates a new version. View history by clicking the version buttons:

<Frame caption="Version history with conversation logs">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/37-version-history.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=69ad9bf781fff9c33b93cb066c214bee" alt="Version history" width="2850" height="1608" data-path="screenshots/37-version-history.png" />
</Frame>

Version history includes:

* Timestamp of each version
* Conversation history (what was discussed to create that version)
* Ability to view any previous version

<Note>
  Versions are immutable. To make changes, edit the current version and publish a new one.
</Note>

## Linkage Discovery

The **Linkages** tab shows relationships AstroBee discovered between your source tables:

<Frame caption="Discovered linkages between tables">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/35-linkages-with-data.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=9dc5adf74d48a15652b5074bca8cc56e" alt="Linkages tab" width="2850" height="1608" data-path="screenshots/35-linkages-with-data.png" />
</Frame>

Click a linkage to see details:

<Frame caption="Expanded linkage showing join logic and validation">
  <img src="https://mintcdn.com/astrobee-f4b330e6/ppM7q3dJGmeBWRIe/screenshots/36-linkage-expanded.png?fit=max&auto=format&n=ppM7q3dJGmeBWRIe&q=85&s=66eaefea88292036416f839300d1bfcd" alt="Linkage details" width="2850" height="1608" data-path="screenshots/36-linkage-expanded.png" />
</Frame>

Each linkage shows:

* **SQL join logic** — The actual join condition
* **Validation status** — Whether the join was tested
* **Statistics** — Confidence, coverage, row counts
* **Sample matches** — Example values that match

## Entity Types

AstroBee uses three entity types:

| Type          | Purpose                                        | Example                   |
| ------------- | ---------------------------------------------- | ------------------------- |
| **Dimension** | Descriptive attributes for grouping/filtering  | Customer, Product, Region |
| **Fact**      | Measurable events or transactions              | Order, PageView, Payment  |
| **Bridge**    | Junction tables for many-to-many relationships | OrderItem, UserRole       |

## Property Types

Properties are classified as:

| Type          | Purpose                              | Example                        |
| ------------- | ------------------------------------ | ------------------------------ |
| **Dimension** | Attributes for grouping or filtering | customer\_id, category, status |
| **Measure**   | Numeric values for aggregation       | price, quantity, total\_amount |

## Best Practices

<AccordionGroup>
  <Accordion title="Start with AI generation">
    Let AstroBee create the initial structure, then refine. It's faster than building from scratch.
  </Accordion>

  <Accordion title="Use descriptive names">
    Entity and property names should match how your team talks about the business.
  </Accordion>

  <Accordion title="Add descriptions">
    Good descriptions help AstroBee understand context when answering questions.
  </Accordion>

  <Accordion title="Review linkages">
    Check the Linkages tab to ensure discovered relationships are correct before building on them.
  </Accordion>

  <Accordion title="Version frequently">
    Publish often to maintain a clear history of changes.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Analytics Chat" icon="message-circle" href="/features/analytics">
    Ask questions about your data layer
  </Card>

  <Card title="Connect Data Sources" icon="plug" href="/data/overview">
    Add more data to your data layer
  </Card>
</CardGroup>
