Comments (16)
The aggregate id identifies the aggregate root. All aggregate roots have an id which unique identifies them. This code base uses uuids but {aggregate type}:{incrementing sequence} is just as good.
from m-r.
Somehow I understand the theory, however I couldn't implement it in my database design. by aggregate, do you mean it has a separate database table? and the aggregate id is the foreign key inside the events table?
from m-r.
Ah I see where your problem is coming from. An aggregate is a group of objects. It is better to think about an aggregate as being a document in a document db (and is often implemented as such). In order to access it you need the overall aggregate id and all ids internally need only be unique within the aggregate.
from m-r.
Lets say I have an User as Aggregate Root
User {
aggregateId: Guid
username: String
password: String,
roles: [Role]
}
Role: {
name: String
permissions: [Permission]
}
Permission {
name: String
}
from m-r.
This is what my events table look like
should I add a aggregate id column?
from m-r.
I would call it a stream id and map aggregate id to a stream id. I have done this before :) https://github.com/eventstore/eventstore
from m-r.
from m-r.
I see. Here is another question, so when i created a user there are two events that happens. UserCreated event and VerificationTokenCreated event. Since they are in one transaction, should I design my events table like this?
from m-r.
The first. neveventstore made the mistake of taking something similar to the second model. What if I am a subscriber am only interested in VerificationTokenCreated events.
from m-r.
thanks greg. i have another question. so to clear my question about the aggregate. should I create a separate table for all aggregates? for example, I have different aggregate roots (User and Role).
| id | AggregateRoot |
| xgftryhf | User |
| yhtyuhu | Role |
from m-r.
eventstore does not but a table/event type is a valid design and is common in accounting systems. Usually you will have a table called "transactions" where the second column after a unique id is "transaction type" which then specifies the details of the transaction are in a known table.
EventStore does not do this, instead it just records the transaction data in a single conceptual "table"
from m-r.
will you provide a concrete example of an events table? here is an article that shows the commonly required fields http://danielwhittaker.me/2014/10/18/6-code-smells-cqrs-events-avoid/. I'm sorry because I have so many questions. hehehe!
from m-r.
I already have eventstore. That the data is stored directly on disk vs tables makes little difference (aside from performance).
from m-r.
Further look at Rinat's work and the chapter I wrote about building an eventstore on top of a relational db
from m-r.
alright. Thanks for your help. :) We are new to event sourcing and cqrs.
from m-r.
Good luck 👍 feel free to let me know if you need further help.
from m-r.
Related Issues (20)
- EventDescriptor purpose HOT 4
- Add LICENSE to repository HOT 2
- About FakeBus sample implementation and contracts for the registration HOT 13
- How to implement business rules? HOT 10
- Why do commands include the entity id when creating entities? HOT 34
- How to implement bulk processing? HOT 6
- Event is mutable HOT 1
- Deactivate action should be POST
- Extraneous properties (and even class)? HOT 2
- Should configuration settings be eventsourced? HOT 1
- Use ReflectionMagic and get rid of InfrastructureCrap.DontBotherReadingItsNotImportant.cs HOT 2
- CQRS and CRUD misconception HOT 21
- Remove bus from projections HOT 1
- Test
- What is the semantic of the Version property in the Event class ?
- Regarding the class naming convention HOT 3
- InventoryItemRenamed: Can't for the life of me see where this is being handled HOT 2
- AggregateRoot version never updated HOT 9
- Why use DelegateAdjuster? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m-r.