简体   繁体   中英

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 ie 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM