Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda