Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
915 views
in Technique[技术] by (71.8m points)

nosql - How to model a Manufacturer in DynamoDB

I come from relational database background and I'm struggling with the concepts of a single table to represents all my data in DynamoDB.

My application has Manufacturers and they give access to their staff to my portal CRM (Manufacturer Users). The Users then add their own customers to the system and log and record all their orders.

  • GetManufacturer()
  • GetManufacturerUsers()
  • GetManufacturerCustomers()
  • GetManufacturerCustomersOrders()

A Manufacturer will never see another Manufacturers Customers orders.

I understand the basics around PK and SK, my question is... really? Is this really single table?

Table Customer Accounts

  • Manufacturers (Name, logo etc)
  • Manufacturer Users (Users of that Manufacturer that access my system i.e. email, role)
  • Customers of the Manufacturer (custID, Name Manufacturer they belong to)
  • Customer transaction data (lots of it)

Given the above, how would you model in DynamoDB?

Access pattern stories

  • Query Manufacturer (Login, Name) by Users SK ManufacturerID
  • Get all Customers IDs and Name by ManufacturerID Filter by UsersID
  • Get all Orders filtered by CustomersID and ManufacturerID
  • Get all Ordered Items filtered by OrdersID and CustomersID
question from:https://stackoverflow.com/questions/65905470/how-to-model-a-manufacturer-in-dynamodb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As you're learning, NoSQL data modeling is completely different than data modeling in a SQL/relational database. Single table design requires you to think differently about your data, which can come with a steep learning curve.

Alex Debrie, author of The DynamoDB Book, has authored some of the best materials about data modeling in DynamoDB. His book is fantastic and I recommend it to anyone wanting to learn about NoSQL data modeling in DynamoDB.

In your situation, I'd start by reading an article on modeling one-to-many relationships in DynamoDB. You can also see the same material in this video presented at the 2019 AWS Re:Invet conference. Both of these resources will give you a much better understanding of single table design in DynamoDB. I haven't found a better resource that can jump-start the DynamoDB learning process.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...