Proper NoSQL data schema for web photo gallery

后端 未结 3 1273
感动是毒
感动是毒 2021-02-01 19:57

I\'m looking to build an appropriate data structure for NoSQL storage of a photo gallery. In my web application, a photo can be part of 1 or more albums. I have experience with

3条回答
  •  别跟我提以往
    2021-02-01 20:09

    Using DynamoDB, the "schema" for the photos table could be:

    Album_Photo

    • Album ID(String, Primary key)
    • Photo ID(Number, Range key)
    • ... Others fields

    Now, where i wrote Other Fields you could save all Photo data and save another request for the proper data table, but this would create redundant data if photo exists in many albuns.

    You could save all photo data in this table for the "main" album, and in the others albuns use an column to specify is the main album ID. As NoSQL databas dont need an strict schema, no column is necessary in an table.

    If photoID has somehow an auto-increment behaviour you can easily get the last X pictures of an album. if not, you could use the Date as Range Key, and photo ID as an column. Is also an good idea use your range key reversed, to query the last row easily.

提交回复
热议问题