0

Thanks in advance!

I want to ceate a Saas solution using AWS for multiple tenants each having multiple users. Each of the user (Example : Admin, Manager, Supervisor) have to upload their department users data (Eg: Name, SurName, Email, Phone etc. and these user attributes together are identified by a HashKey)

In short I have to store all users's information of multiple departments of multiple companies including each users HashKey

How can this be done using DynamoDB? Can someone help in creating a Table schema?

Query pattern mostly used is : A tenant will provide HashKey and would want to fetch all user information from it or part of it by providing HashKey and some fields.

Regards,

amirouche
  • 7,682
  • 6
  • 40
  • 94
user1393608
  • 1,299
  • 3
  • 16
  • 29
  • Seems more like an SQL problem, rather than NoSQL at first glance. I am not really sure whether you will get something reasonable out of DynamoDB in this case (at least reasonable in a sense that it would perform better & cheaper than regular SQL solution using RDS for example). – Matus Dubrava Jul 24 '20 at 11:18
  • Will TenantId a primaryKey and Global secondary Index on Attributes calculated HashKey work? – user1393608 Jul 24 '20 at 11:26
  • No it wouldn't because primary key needs to be unique (only one item per key). In your case, you need to store multiple items per single tenant which means that the tenant ID cannot be used as a single value for the primary key. You would need to design a composite primary key which would still need to be unique so it would need to be something like tenant id + user id (sort key) which doesn't make much sense. The global secondary index doesn't play role in this case (it is there only to support additional query formats + it can cost much more) – Matus Dubrava Jul 24 '20 at 11:41
  • Would 2 tables instead of only one help in this scenario or should there be one table per tenant?. I want this Saas platform to be highly scalable and transactional – user1393608 Jul 24 '20 at 12:11
  • 1
    Maybe if you have one table per tenant with composite primary key (user_hash + department [sort key]) but this can possibly get pretty costly. – Matus Dubrava Jul 24 '20 at 12:47
  • How about concatenation of tenantID and userHash (tenantID_userHash) as a primary key and rest attributes as the value in DynamoDB. And tenantID and department information in RDS will that help? – user1393608 Jul 25 '20 at 06:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/218562/discussion-between-user1393608-and-matus-dubrava). – user1393608 Jul 25 '20 at 06:35

1 Answers1

1

You can use only one table and "separate" the data using dynamodb index. Create an Index that will be responsible for storing the tenant hash (id, whatever) and then use it to fetch the data when needed.