In: Computer Science
What are the core components of DynamoDB
The core components of DynamoDB are:
1) Tables, Items & Attributes
2) Primary Key
3) Secondary Indexes
4) DynamoDB Streams
1) Tables, Items & Attributes:
- A table can be visualized as a group of items, for eg. In employee records, items like Employee ID, Employee Name, Address etc will be grouped and stored in a table.
- An item is a set of attributes in a table, that is uniquely identifiable among all of the other items. For eg. in a cars table, each item represents one vehicle.
- An attribute is a fundamental data element, something that does not need to be broken down any further. For eg. in a department table an item might have attributes such as Department ID, Name, Manager etc.
2) Primary Key: A primary key is a unique attribute that is necessary while creating a table, it can't be null at any given point. A primary key attribute is a must. For eg, in an Employee table, Employee ID is a primary key. Two types of primary key are supported in DynamoDB.
i) Simple Primary Key: It's basically a single attribute, eg. Employee ID in an Employee records table.
ii) Composite Primary Key: It's also known as the Partition key and Sort key. The primary component is the partition key and the secondary component is the Sort key.
3) Secondary Indexes: A secondary indexes lets you query the data in the table using an alternate key. After you create a secondary index on a table, you can read data from the index in much the same way as you do from the table. Two types of indexes are supported in DynamoDB.
i) Global secondary index- This index is used to possess a partition and sort key, which can differ from table keys.
ii) Local secondary index- This index is used to possess a partition key identical to the table, however it's sort key differs.
4) DynamoDB streams: This is an optional feature that captures data modification events in DynamoDB tables. The data about these events appear in the stream in near-real time and in the order that the event occured. Each event is represented by a stream record. If you enable a stream on a table, DynamoDB stream writes a record whenever one of the following events occur:
i) A new item is added to the table
ii) An item is updated
iii) An item is deleted from the table.
Stream records have a lifetime of 24 hours after that, they are automatically removed from the system.