# Database

LanceDB-based storage for face embeddings and attributes.

## What is ReID Database?

`ReID_Database` is the underlying storage layer for face embeddings and person attributes in `degirum-face`. It uses LanceDB to store:

* Face embedding vectors for similarity search
* Person attributes (names, metadata)
* Associated face images
* Model metadata for validation

The database is automatically managed by `FaceRecognizer` and `FaceTracker` - you typically don't instantiate it directly.

## When to Use

**Automatic usage** - The database is created and managed when you initialize `FaceRecognizer` or `FaceTracker`:

```python
# Database created automatically at db_path
recognizer = degirum_face.FaceRecognizer(
    config=degirum_face.FaceRecognizerConfig(
        db_path="./my_faces.lance",  # Database location
        # ...
    )
)
```

**Direct usage** - Only needed for:

* Custom database operations
* Database migration/backup tools
* Advanced batch processing
* Direct embedding management

## How It Works

The database uses LanceDB with four internal tables:

| Table        | Purpose                                      |
| ------------ | -------------------------------------------- |
| `embeddings` | Face embedding vectors with image references |
| `attributes` | Person metadata (names, IDs)                 |
| `images`     | Face image storage (PNG format)              |
| `_metadata`  | Model validation metadata                    |

**Key features:**

* **Vector search** - Fast similarity search using cosine distance
* **Deduplication** - Automatic embedding deduplication via hashing
* **Thread-safe** - Safe for concurrent access
* **Model validation** - Ensures embeddings from same model
* **Connection pooling** - Single connection per database path

See [Configuration Guide](/face-recognition/guides/overview-3/configuration.md) for database initialization options.

See [Methods Reference](/face-recognition/guides/overview-3/methods.md) for complete API.


---

# 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.degirum.com/face-recognition/guides/overview-3.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.
