concept changelog in category kafka

This is an excerpt from Manning's book Kafka Streams in Action: Real-time apps and microservices with the Kafka Streams API.
In the next chapter, we’ll continue exploring state in streams with more-significant operations, like aggregations and grouping. We’ll also explore the KTable API. Whereas the KStream API concerns itself with individual discrete records, a KTable is an implementation of a changelog, where records with the same key are considered updates. We’ll also discuss joins between KStream and KTable instances. Finally, we’ll explore one of the most exciting developments in Kafka Streams: queryable state. Queryable state allows you to directly observe the state of your stream, without having to materialize the information by reading data from a topic in an external application.
If you consider the stream of events as a log, you can consider this stream of updates as a changelog. Figure 5.4 demonstrates this concept.
Figure 5.4. In a changelog, each incoming record overwrites the previous one with the same key. With a record stream, you’d have a total of four events, but in the case of updates or a changelog, you have only two.
![]()
Here, you can see the relationship between a stream of updates and a database table. Both a log and a changelog represent incoming records appended to the end of a file. In a log, you see all the records; but in a changelog, you only keep the latest record for any given key.