spring-bootamazon-dynamodbrelational

How to convert relational tables to one single table using spring boot and dynamodb


I am some how confused and can't think how this can be done using the dynamodb

if we have for example Student Course Teacher

each student is subscribed to many courses each teacher can teach many courses each course can has many students

the Access patterns I want is 1- get student by id 2- get teacher by id 3- get course by id 4- get student by email or by name 5- get teacher by email or by name 6- get course by name

can any one help me How I can make this in java spring boot I can write entity for each one but I want them to be one single table and am confused how this can be done


Solution

  • There may be a better solution, but I gonna structure like this

    Students
    {
     uid: String,
     name: String,
     courses: <Courses<uid>>[],
    }
    
    Teachers
    {
     uid: String,
     name: String,
     courses: <Courses<uid>>[],
    }
    
    Courses
    {
     uid: String,
     name: String,
    }
    
    
    // get item by uid
    var params = {
        TableName: "tableName",
        Key:{
            "uid": "Youruid",
        }
    };
    
    docClient.get(params);
    
    // get item by name
    var params = {
        TableName: "tableName",
        Key:{
            "name": "SomeName",
        }
    };
    
    docClient.get(params);