# Collections

​In Memgraph Lab, the Collections feature allows you to organize and manage your
Cypher queries efficiently by grouping them into named collections. This
functionality is particularly useful for structuring queries related to specific
projects, datasets, or analytical tasks, enhancing both organization and
collaboration.​

With the collections feature, you get: 

- **Organized query management**: Group related queries together to streamline your
workflow and quickly locate specific queries when needed.​

- **Enhanced collaboration**: Share collections with team members, facilitating better
collaboration and ensuring consistency across projects.​ 

- **Efficient query execution**: Execute queries directly from their respective
collections, reducing redundancy and improving productivity.​

## Create and update a collection 

To begin organizing your queries, you'll first need to **create a new collection**.

To create a new collection, navigate to the **Collections** in Memgraph Lab and
click on **Create collection**. 

![create-collection](https://memgraph.com/docs/pages/data-visualization/features/collections/collections.png)

Next, you will be prompted to directly **add previously executed queries** to
the collection. You can skip this step and add your queries later. 

![add-query](https://memgraph.com/docs/pages/data-visualization/features/collections/add-queries-to-collection.png)

To finish creating the collection, enter a meaningful **Collection name** that
reflects the purpose or context of the queries it will contain.

![collection-name](https://memgraph.com/docs/pages/data-visualization/features/collections/name-collection.png)

There are three main ways to add queries to a collection in Memgraph Lab,
depending on where you are in the interface:

- [From the Collections](#add-query-from-the-collections)
- [From the Query execution](#add-query-from-the-query-execution)
- [From the Run history](#add-query-from-the-run-history)

Every query is defined with its name (required) and description (optional).

![edit-query](https://memgraph.com/docs/pages/data-visualization/features/collections/edit-query.png)

### Add query from the Collections

If you're managing collections directly, simply select a collection and click
**Add query** to manually write and add a new query to the currently open
collection.

### Add query from the Query execution

After executing a query, you can save it directly to a collection.

![add-to-collection](https://memgraph.com/docs/pages/data-visualization/features/collections/add-to-collection.png)

You can either choose an **existing collection** from the dropdown or **create a new
one** on the spot by entering a name during the flow.
You'll also need to provide a **query name** before saving.

![query-name-collections](https://memgraph.com/docs/pages/data-visualization/features/collections/query-description.png)

### Add query from the Run history

You can revisit previously executed queries and add them to a collection.

![add-from-run-history](https://memgraph.com/docs/pages/data-visualization/features/collections/run-history.png)

You can either choose an **existing collection** from the dropdown or **create a
new one** on the spot by entering a name during the flow.

## Importing and exporting collections

Query collections can be exported and imported as JSON files, making it easy to
share across teams or back up your work.

![collection-export](https://memgraph.com/docs/pages/data-visualization/features/collections/export-collection.png)

## Sample collections 

Memgraph Lab includes sample query collections loaded with [
datasets](https://memgraph.com/docs/memgraph-lab/getting-started/data-migration#datasets). These
ready-to-use Cypher queries help users:

- Quickly explore Memgraph features
- Learn Cypher by example
- Understand real-world use cases (e.g. fraud detection, recommendations, network analysis)

Each query within a sample collection includes description to explain
functionality, making them easy to understand and adapt. Ideal for beginners,
they reduce setup time and offer a hands-on way to explore graph data and
practical applications.

### Download a sample collection 

After loading a [dataset](https://memgraph.com/docs/memgraph-lab/getting-started/data-migration#datasets) from the
**Datasets** section, you can download the query collection containing the queries
related to that dataset. 

![download-query-collection](https://memgraph.com/docs/pages/data-visualization/features/collections/import-download-query-collection.png)

For example, if you loaded the Game of Thrones dataset and downloaded the query
collection, you will get the following queries:

![got-collection-queries](https://memgraph.com/docs/pages/data-visualization/features/collections/collection-view.png)
