GithubHelp home page GithubHelp logo

Comments (16)

gregoryyoung avatar gregoryyoung commented on September 22, 2024

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.

coyksdev avatar coyksdev commented on September 22, 2024

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.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

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.

coyksdev avatar coyksdev commented on September 22, 2024

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.

coyksdev avatar coyksdev commented on September 22, 2024

This is what my events table look like

screen shot 2018-03-05 at 4 15 05 pm

should I add a aggregate id column?

from m-r.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

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.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

from m-r.

coyksdev avatar coyksdev commented on September 22, 2024

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?

screen shot 2018-03-05 at 4 40 29 pm

from m-r.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

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.

coyksdev avatar coyksdev commented on September 22, 2024

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.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

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.

coyksdev avatar coyksdev commented on September 22, 2024

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.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

I already have eventstore. That the data is stored directly on disk vs tables makes little difference (aside from performance).

from m-r.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

Further look at Rinat's work and the chapter I wrote about building an eventstore on top of a relational db

from m-r.

coyksdev avatar coyksdev commented on September 22, 2024

alright. Thanks for your help. :) We are new to event sourcing and cqrs.

from m-r.

gregoryyoung avatar gregoryyoung commented on September 22, 2024

Good luck 👍 feel free to let me know if you need further help.

from m-r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.