# How can we help?

## Overview

To understand the difference between primary and secondary keys, you need to know that Cordial stores data as JSON objects in the following collections:

- [Contact collection](https://support.cordial.com/hc/en-us/articles/115005530808-Contact-Management-Overview): stores data specific to a contact including [channels](https://support.cordial.com/hc/en-us/articles/13084804213517-Primary-v-secondary-keys#! "Cordial is an omni-channel platform that supports multiple ways to communicate to your contacts including: email, mobile push, web, and sms."), [attributes](https://support.cordial.com/hc/en-us/articles/13084804213517-Primary-v-secondary-keys#! "Contact attributes store data specific to each contact such as first name, address, birthdate, etc. <a href=/hc/en-us/articles/115005528368'>Learn More</a>"), [list membership](https://support.cordial.com/hc/en-us/articles/13084804213517-Primary-v-secondary-keys#! "Contacts can be grouped together into static lists. Which list a contact is a member of is stored in the contact collection. <a href=/hc/en-us/articles/115005528428'>Learn More</a>"), and [cart items](https://support.cordial.com/hc/en-us/articles/13084804213517-Primary-v-secondary-keys#! "If you are passing cart items to your account using JavaScript or API, they are stored with each contact in the contact collection.").
- [Event (contact activities) collection](https://support.cordial.com/hc/en-us/articles/115005528508-Events): stores event data specific to messages (opens, clicks, etc.) or any [custom-named event](https://support.cordial.com/hc/en-us/articles/13084804213517-Primary-v-secondary-keys#! "Custom named events are created by you according to your marketing needs. Examples include: browsed a web page, added someting to the cart, placed an order, etc.").
- [Product collection](https://support.cordial.com/hc/en-us/articles/115005528548-Products): stores data from a product catalog.
- [Orders collection](https://support.cordial.com/hc/en-us/articles/115005528568-Orders): stores order data.
- [Supplements collection](https://support.cordial.com/hc/en-us/articles/115005528468-Supplements): stores additional data (store locations, coupon codes, message content, and more) that doesn't fit into one of the above collections.

## Primary key

A primary key is a piece of data, or value, that uniquely identifies each JSON object in our database. In Cordial, the primary key is typically the `customer_id`. The primary key ensures that each JSON object can be easily retrieved and updated. Cordial gives you the option to choose the primary key or generate it automatically, in which case it will be the `customer_id`.

## Secondary key

A secondary key can be used to find a specific subset of data within a JSON object. Unlike a primary key, a secondary key does not have to be unique. Multiple JSON objects can have the same value for a secondary key, and each value can be associated with multiple JSON objects. Secondary keys are used to enable and enhance specific queries, which facilitates segmentation.

## Example

In this example, let's say you have a JSON object in the contact collection with the following values:

- `customer_id` (primary key)
- `email`
- `first_name`
- `last_name`
- `gender`
- `date_of_birth`
- `purchase_history`
- `website_behavior`

The `customer_id` is the **primary key** for this JSON object. If we want to look up the purchase history of a specific customer, we can use their customer_id to find that data.

But let's say you want to segment your customers by gender for a specific marketing campaign. To do this, you can create a **secondary key** using the gender value. This allows you to quickly find all the contacts that have a specific gender value (e.g., `male` or `female`) and use that information to shape your messaging.
