Database schema for event management

25 Views Asked by At

I am creating a project for an institution.. There will be events held throughout an academic year which have different programs like songs, group songs etc.... These will be held in categories of age of the students.. Kids, juniors, sub-juniors, seniors . I need a modal(s) for this

    import mongoose from "mongoose";

    const eventModel = new mongoose.Schema({
      name: {
        type: String,
        required: true,
      },
      date: {
        type: Date,
        required: true,
      },
      programs: [
        {
          programName: {
            type: String,
            required: true,
          },
          category: {
            type: String,
            required: true,
          },
          ranking: [
            {
              rank: {
                type: Number,
                required: false,
              },
              studentId: {
                type: mongoose.Types.ObjectId,
                required: false,
                ref: "Students",
              },
              participants: [
                {
                  type: mongoose.Types.ObjectId,
                  required: false,
                  ref: "Students",
                },
              ],
            },
          ],
        },
      ],
    
      isFinished: {
        type: Boolean,
        required: false,
      },
    });
    
    export default mongoose.model("Events", eventModel);

This leads to duplication of data of program name since two different groups may have a same program

0

There are 0 best solutions below