In my case, I know that most of the times the application is showing, for a specific customer, a summary of the customer information, and the list of customer bookmarks. Going back to our bookmark application, can I design a better data model? Yes!
#Database workbench logical data modeling update#
You shouldn’t start the design of the data model if those questions are not clear, otherwise you risk to update it too often, slowing down development. What kind of queries am I going to use to retrieve information? How often?.When using a NoSQL database, you should design your data model to optimize for the application’s access patterns. This is not efficient, especially if you start to have three or more requests instead of one. This is something quite common when moving a relational data model to NoSQL without changes: table joins are “unrolled” into multiple requests to the database. But what happens in my application when customers log in to display their bookmarks? Each time, the application runs two requests to DynamoDB, the first to get the customer data in the Customer table, the second to get the customer bookmarks in the Bookmark table. This first approach, using two tables, definitely works. Depending the actual application, I could use this to store language or sort preferences, for example something like:
For simplicity, I am using an empty JSON object (such as “”) in examples hereafter. This has the advantage that string comparison preserves the order of dates.
#Database workbench logical data modeling iso#
Each item stored in the table can then use different attributes on top of those in the primary key.įor date fields, such as createDate and updateDate, I use the ISO 8601 standard to store them as strings, like “20200325T091641.123”. In this way, if two customers store the same URL, I can have both in the table.ĭynamoDB doesn’t have a fixed schema, only the attributes in the primary key (the partition key and optionally the sort key) must be defined at table creation. For the Bookmark table, I use a composite primary key, where customerId is the partition key, and url is the sort key. The Customer table has customerId as primary key. The following screenshot shows the details for the Bookmark table. The following screenshot shows the details for the Customer table. Using the Data modeler section in NoSQL Workbench, I create a new data model with two tables. The customerId attribute links information between the two tables.