Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
Best data structure for nested multi tenant structure

I am not sure if I am going the right way about structuring my data, I am looking at creating a multi tenant database which I will provide as JSON to the front end with the relevant information for each client.

Below is an example array with one entry that represents one clients data, this would be repeated for each client.

Each client will have subsets of client data which include employees, teams, locations etc.

Each client will have an array of customers who will all be able to be assigned rewards, and enter personal info which will be accessible by the client, the same applies for all the other nested arrays and objects.

Is this nested way of structuring things the correct way to go, or should I have a seperate structure for clients and customers.

[
  {
    client_id: 12345678,
    client_name: "client one",
    client_email: "email@email.com",
    client_teams: [
      {
        team_id: 1234,
        team_name: "team one",
        team_location_id: "ldn_01"
      },
      {
        team_id: 1234,
        team_name: "team two",
        team_location: "ldn_02"
      }
    ],
    client_employees: [
      {
        employee_id: 1234,
        team_id: 1234,
        employee_email: "email@email.com",
        employee_password: "password",
        employee_username: "name",
        employee_access: "admin"
      },
      {
        employee_id: 4567,
        team_id: 1234,
        employee_email: "email@email.com",
        employee_password: "password",
        employee_username: "name",
        employee_access: "viewer"
      }
    ],
    is_connected: false,
    date_joined: "date",
    customers: [
      {
        customer_id: 1234,
        first_name: "firstname",
        last_name: "last name",
        date_joined: "date",
        total_rewards_redeemed: 1,
        total_points_accumulated: 20,
        current_points_accumulated: 2,
        rewards_available: [1234, 1235],
        age: 25,
        city: "London"
      }
    ],
    locations: [
      { location_id: 1234, location_name: "location one" },
      { location_id: 2234, location_name: "location two" }
    ],
    rewards: [
      {
        reward_id: 1234,
        reward_name: "10off",
        reward_description: "10% off",
        reward_start_date: "25-06-2022",
        reward_end_date: "30-06-2023"
      }
    ],
    campaigns: []
  }
];```
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda