Domain Driven Design & NoSQL


Formal Metadata

Domain Driven Design & NoSQL
Title of Series
Part Number
Number of Parts
Dohmen, Lucas
CC Attribution - NonCommercial 2.0 Germany:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Free and Open Source software Conference (FrOSCon) e.V.
Release Date

Content Metadata

Subject Area
Domain Driven Design & NoSQL Escaping the Tower of Babel Domain Driven Design focuses on finding a common language to improve communication — a still important topic regarding lots of failing projects. In this talk I want to show you how NoSQL’s document stores and graph databases can help with DDD and compare that to modeling in relational databases. Domain Driven Design is a software development process that focuses on the finding a common language for the involved parties. This language and the resulting models are taken from the domain rather than the technical details of the implementation. The goal is to improve the communication between customers, developers and all other involved groups. Even if Eric Evan's book about this topic was written almost ten years ago, this topic remains important because a lot of projects fail for communication reasons. Relational databases have their own language and influence the design of software into a direction further away from the Domain: Entities have to be created for the sole purpose of adhering to best practices of relational database. Two kinds of NoSQL databases are changing that: Document stores and graph databases. In a document store you can model a contains relation in a more natural way and thereby express if this entity can exist outside of its surrounding entity. A graph database allows you to model relationships between entities in a straight forward way that can be expressed in the language of the domain. I want to look at the way a multi model database that combines a document store and a graph database can help you model your problems in a way that is understandable for all parties involved. Speaker: Lucas Dohmen Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
Free and Open Source Software Conference
Building Freeware Open source Protein domain Formal language Power (physics)
Area Context awareness Spacetime Inheritance (object-oriented programming) System administrator Projective plane Expert system Protein domain Insertion loss Protein domain Formal language Formal language Table (information) Estimator Programmer (hardware) Word Software Database Natural language Social class
Word Atomic number Protein domain Formal language Formal language Number
Software developer Feedback Protein domain Expert system Water vapor Protein domain Perspective (visual) Formal language Formal language Table (information) Programmer (hardware) Word Iteration Social class
Point (geometry) Open source Software developer Scientific modelling Open source Protein domain Expert system Protein domain Formal language
Arithmetic mean Database Sampling (statistics)
Relational database Theory of relativity Algebra Finitary relation n-Tupel Set (mathematics) Algebra Abstraction
State of matter Physical law Element (mathematics) n-Tupel Set (mathematics) Mereology Field (computer science) Number Table (information)
Covering space Context awareness Process (computing) Information Protein domain Expert system Translation (relic) Cartesian coordinate system Number Table (information) Formal language Programmer (hardware) Data storage device Database
Point (geometry) Pulse (signal processing) Service (economics) Information State of matter Connectivity (graph theory) Protein domain Sound effect Cartesian coordinate system RAID Mathematical model Field (computer science) Number Category of being Database Object (grammar) Subtraction Identical particles Address space
Point (geometry) Divisor State of matter 1 (number) Combinational logic Protein domain Business object Programmer (hardware) Plane (geometry) Database Oval Repository (publishing) Software repository Energy level Exception handling Multiplication Graph (mathematics) Constructor (object-oriented programming) Word Process (computing) Exterior algebra Integrated development environment Repository (publishing) Factory (trading post) Normal (geometry) Self-organization Dependent and independent variables Pattern language Object (grammar) Procedural programming Pole (complex analysis)
Area Subject indexing Graph (mathematics) Line (geometry) Mereology Address space
Mathematics Open source Database Scientific modelling Object (grammar) Mereology Subtraction Table (information)
Spacetime Data storage device
Point (geometry) Greatest element Multiplication Graph (mathematics) Universe (mathematics) Statement (computer science) Energy level Frame problem Local Group
Computer programming Graph (mathematics) Graph (mathematics) Database Arrow of time Maize Subtraction Mathematical model Condition number
Relational database Multiplication Sine Graph (mathematics) Scientific modelling Gradient Interface (computing) Mereology Mathematical model Workstation Mathematical model Database Quicksort Bimodal distribution Multiplication
Implementation State of matter View (database) Scientific modelling Protein domain Drop (liquid) Distance Mathematical model Formal language Telephone number mapping Video game Error message Game theory Descriptive statistics Physical system Spacetime Graph (mathematics) Product (category theory) Cellular automaton Electronic mailing list Expert system Grass (card game) Entire function Table (information) Graph theory Word Process (computing) Vertex (graph theory) Identical particles
Computer programming Group action Open source Code Scientific modelling System administrator Protein domain Mereology Perspective (visual) Mathematical model Formal language Data model Mathematics Database Representation (politics) Bimodal distribution Implementation Error message Subtraction Address space Descriptive statistics Graph theory Social class Physical system Area Addition Graph (mathematics) Mapping Building Moment (mathematics) Projective plane Mathematical analysis Expert system Instance (computer science) Protein domain Computer Formal language Right angle Object (grammar) Quicksort Digitizing Resultant
a 1 1 I wasn't sure if anyone would show up at 10 and 1 1 2 years so I'm very happy and so there was a there is a story about building and how people when the people but the topic about built this really impressive power here in the beginning they all have 1 language they also language they all understood what each other was and as and because people of people they become king very bright so someone took away their language and they didn't have a common language and war and the tone of the fish
in my experience a lot of software projects start out of with people speaking different languages in the sense of human languages but in the sense of John so for example you might might have someone who's talking about tables this person might be a database administrator for example and and tables have their own I have that Canada their own words to describe things and then you have the programmer and the programmers you might think about space shuttles which based losses and a strong classes and inheritance and and this is an entirely different vocabulary and the vocabulary used whether person talking about the the and then you have dessert person was talking about the the problem at hand the domain expert that wants to solve the problem in our example this is because space is called estimates in this so this person that really understand what table are all classes are 1 inheritance is rather than in the human context maybe and so all speak different each and we are often this situation in your project this might be the designers the language of the programmers but I think those 3 areas are very common and in projects so this
problem problem was a problem that's Eric Evans Saul when he wrote a book about the kind of inside that in the talk I
gave the recently people saw that my name is atoms but it's not the denies that I would have written the book but I'm not so this is not mine so and the major design is that the simple idea that I
when we find an indigenous language we can solve a lot of our
problems so that everyone on the team understands the words that each other's using and we reduce the number of I 1 and if you have the the
programmer the database and administrative the domain where if they understand what what the words mean then they can solve problems together instead of trying to explain to each other their words and stuff like that and because it's the major the language is not from the technical perspective is from the domain so we were talking about space shuttles and astronauts than those are the words we use and when not using classes of tables of stuff like that and so this is the the basic idea and the major design has to the importance of things that have to be there for you can be implemented the 1st 1 is
iterative development that means that you are not making water that you are building iterations so you're getting in the very beginning of feedback especially with the domain experts within your customers of people like that so this is
very important I think a lot of people already have implemented that I hold that the 1 year that's wonderful if you are doing that and talk later plants and I think it's fair to say that a lot of people do that are in 1 way or another and the other thing that is very important is a close relationship new the developments at the and the domain experts because if you don't talk to each other you cannot build language together that's not possible you need to talk to each other in and other way to get this this this will be a problem so my name is
I am not from this beautiful beach in from the cold city called on the most people here will be familiar with that at this point and you don't look at me I think they won't fly as well as for the general model so I will skip those I can work for a company called and how and we build something called during good at on it is and open source most elevator and this raises 2 questions 1 is always also I think most people here are aware of this because of the use of conference so the 2nd question is what is going on and on and this is surprisingly hard question to answer in my experience because I'm going to ask for some time knowledge and still not sure what the answer is sold this trying to find out so if we have this well-known
bubble of SQL this all the databases that and obviously you know as well all the databases that on the spot right so this would mean that it is maybe not not maybe that would be much more so therefore J things that accompanies also the so and this is no OK maybe we can try to grab grab what that means but then people try to make it more complicated by saying that no assume it's not only so now we have this weird thing going on where maybe influence so I
posthumous samples and also with the other thing I don't know if it's true because and and 1 was the means but from let's try to find so you
might 1st ask what is the last year and then you might try and get the answer it's not clear and raise the question what is this thing anyway and SQL I think a lot of people forget that is a relational and that's because we hi behind so many abstractions we tend to forget what what what SQL is and what is going and and a relation
algebra is an algebra of relations that seems obvious but this raises 2 questions 1 is an algebra and was the relation but let's talk about the relation because was merits lecture so a relation is basically this of the relation is a set of tuples a
set of tuples where every single tuple has the same number of elements so in this but case but also the intervals so we have 1 part where there is 18 Alice and in the other case law and we
have some we use the because we are most problem of the ideas of this seems to be the 1st and then we have some you know and this is 1 of the problems with this way of looking at it because we don't know what those fields are this what is state 1 the that stands for and and what does number the and anything so people came up with a quite clever idea on how to make that method to understand and this is putting those tuples tables so if we put it into a
table and we give each of those roles nice heading and we can understand more and more easily what that means so in this case we say the 1st year that is the name of the person and the 2nd 1 is the best thing and this 1 is city but this again is we're on if you're not a programmer because why is this 69 number city is not a number of
dust that this doesn't make any sense to most of you will know when probably why that is the number but if you if you are in it uh talking to someone who is not a programmer has not yet implemented over application with NBC and stuff like that and this might be you and if you try to explain to people that you might see that there is a certain disconnect between those 2 the vocabulary will so let's say we have alice in alice spaceship then this is the drawing that or domain experts blind on a piece of paper here this and she owns this special chapel and then the the database professionals it's started says of course we can take the 1st is like what I don't understand what you what what what you're talking about and you all you all know why that is because you know that we need somewhere what is to stop people we don't need someone to move to store space shuttles for spaceships in general and then we need some joint Table 2 see the relationship between those 2 things but aware that somewhere in in our team there's a translation or probably it's in the hands of someone in the team but there is a translation process and because I'm not a native english speaker and speaker of English and all that is translation we use a lot of stuff even if understand the language quite well we the lose some information along the way you probably have experienced that as well all right so the cover delivery thank you and so if keep this in mind for the next few steps this very important but 1st let's talk about the main fight
so here in this book he talks about 6 main components that we have in our in our domain world 6 different kinds of objects so the 1st 3 are entity value objects so an entity is something that has this is identified by the 19 so it is something that has its own identity let's say that person is an entity because if we change something about the person like last name the person will still be the same person saying if a person gets married and we change the last thing then we will still we still want to say OK this is the same person and then the other
information about this person still relevant and still a real so we have to find some other way to identify the person and not just take all the fields that instructors because then as soon as we change the name we will have a different person also this means that if we have to the 2 datasets where from all the use of the same that doesn't necessarily mean that we have the same object so object person maybe so for example always thought our database of all persons the 1st and last names then there might be to people at 1st love the same 1st name and last name but they're still not the same person you don't want to associate everything that is associated with the 1 person with the other 1 this is entirely different about object of all the objects on the identified by itself so to if we have a straightforward and for example and this was might contain a raid consist of the street this is the number of pulses called for example I and if you choose all objects have the same the number of the since the interesting Poland will be on the sea and there's nothing else identifying they are the same address and this has 1 important of as a consequence which is that that the person is mutable but objects in neutral and this is kind of tricky because as soon as we change something about its object and we can also just copy it and change the values in the cost because the everything that was we said about the original motion is not necessarily true anymore and this has a very important consequences for modeling knowledge database so when we when we say those 2 are added at what is a database and the other 1 by the value and we have which will immutable state still the 1 which is the service and service but is only in front of us and it's in his opinion that the social always status so a good example for that is the male sending so so you have no application at some point 1 % of me then this probably should not have the because if you want if you said this information to his component and you want to have the same effect resulting from the so we only identified by what what it does and we say we don't and they don't have to think about how to build your mutability at this point OK so those 3 are the main categories this
region 1 OK what is shit that can and so there are
many more and those are quite well known for programmers because there are patterns that we use a lot of the 1st ones the factory is
something that is that is a domain object that builds up to the object so for example we have a very complicated procedure to create a person then we might not want to to make the responsibility of the person so what we want to have uh all alter things that builds constructs in some communities like in the community the word factories so job job like that people don't use the word the equal the but it's it's except thing has so yeah I suppose environment the 2nd thing is the repository and repository is something where you can store things in in a way you can get it out the way you can get a song with all we can a specific entry in this domain objects is a collection of domain objects and then a lot of cases the repository is something that is backed by that database because the database is that both things but you have to to understand that in the domain world we don't know what databases because the database doesn't play any role in our domain will and that's what we just say this is something where we can store things and we can get things or we can get search was just a certain criteria for it I and then we have the egg and the aggregated is the combination of the entity and multiple objects so for example we have opposite again this person lives in a certain state and then we have a combination of all of the entity person with a value Object edges you could also imagine that this person has more than 100 because there is little more than 1 place and that might be of Mary of of and this is the so as long as we have 1 which is a domain object which is connected to a low level of detail that we are talking about and the area and at this point suggests normalization because in this book you talks about SQL database and otherwise the databases in the sense that this is for a lot of people in organizations is an educator in my experience a lot of people say that the plane but I but he said the only way you can do that normalization and we can use a very important trait of from before because not saying that our ability objects are mutable we can copy this many times as you want so if we say that we have a person and that this person lives in we can just put this entire enters into the person and so it won't matter because if we change this factors but we don't have to change the all edges of the signal because that would be weird when we when a person moves that not everyone the same poles as well all and so therefore we can use the normalization in this case but the thing about the case where we have a person who has more than 1 stressed that we can we only have to introduce it was 1 of was true and underscore lot but we may not know want to do with that so this becomes ugly really fast that we might need to take a value object and make it a given its own idea making an entity basically so Eric Evans describes this as a problem but of a problem that we need to face so we have but we have another alternative to doing that and this would be living certain
restrictions about the way we our modelling stuff so we could say that our 2 peoples are allowed to continue to people in our relations and and this would allow us to embed those addresses this unintelligible into the person we realized what might also say that we allow area or is this entire of at removing this need for order of all lines
and stuff like that which I find is discussed in much more so when people talk about no SQL but is much less important I think that the part that we have and that the index tuples into other people's attention area for example this is not true for because we now can take the both sentences and put them as an area into of the person and and and we have talk about spatial here
so let's say we have a space shuttle and the space shuttle consists of lot parts and then we have this
contains religion is going on so this is the part they are all of the value objects because of their might be a lot of different kinds of screws
and stuff like that in if you change 1 of them not all other change as well so they are understand the value objects for us so we can treat them like that 1 and week if we could now say that special chapel contains the parts and we can model that no database and then we will talk about documents source because documents always love you to not model at this table or model evidence and documents so in a document you can see and this is then just assigned an area of on those and should be known objects of those are if you are and many other entities that might run into problems because if you change an entity that is embedded into not another entity and you have to search through for all your different entities in the database and the adjustment so always think about this is that you and your value objects and on model it's according to to that and so it out the situation now we have documents called cut document with
everything about Alice we have document with everything was based on what we still need to model the relationship between those 2 things and I said I talked about before we might have something like a jointly or in the case of a document store a joint of the
is what exists but I made up of and so we might say that Alice has some idea of the special summit create of a document which has all of the genes in there and when we want to find out what's space which basically amongst Ellis then I we might want to do something called the joint
inducing the frame size was
that in the background there because I'm afraid of joins I admit that because I I I worked for some quite some time and university for
a chair that dust and social network analysis and so on and we did a lot of and and they were scared all knowledge of world and when you look into the commons believe and about those about those statements and there was a lot of interesting going on because a lot of people didn't understand more what what what was going on basically and this is a common phenomenon because if you start out of all the joint there OK there are nice they are quite easy to understand but they get more complicated very fast and then like some of them come to a point where you are joining the group bottom multiple letters levels and you get into recursive joints and then your brain starts to very bad 1 but I think there is and
intuitive that which is
modelling and as the graph that might be made is that not everything is about how some people argue that everything is a graph I would not agree but I think a lot of cases we see those
relationships we can see them as a graph and 1 of the things what why I see that is because people if if you want but if you ask the person that is not a program to to trawl what they're what they're thinking about what what they want to have that they often end up with something like this so they might be drawback of Alice and they might struggle with the space shuttle I and then they might draw some narrowing the between them and say it like that was on the special maybe it's an arrow pointing to the special adjusted owns more examples but something like this would happen I tried this with a lot of different people and this is what most people on so if you can model that your database and you talk talking what about the harm people have different definitions of what this isn't in almost as bad as people define myself but I think about this is just some database reinstall across in preventing some nice way this is from this might not be the hardest emission ever but I think it's quite good condition which applies to all the graph databases I know so that now we can't models of things but imagine that we still have a
spatial which its parts and and in a graph database what most people would do is take those parts out and then connected together with other edges between but the people and so that would be the space shuttle and the parts and then again the the
gradient of an entity from another which is but you have edges and so that I think it's a good idea to combine those 2 things so let's just say that and it is this the part of the specialist in so we can do all those things described before we can embed stuff and then we can have we can leave out certain documents and stuff like that so this is stood up and then we do some little straight and say that he actually also and this has nice comes because we can now do all kinds of stuff like this and we can say that the edge has an ownership what should I don't since sort of so we know that Alice owns the space shuttle since this year and then we can do queries like Give me all the neighbors and which has the oldest sins between itemsets 1780 so we know all the stations children owned in this in this uh that time sort and so if you can do both of those things and then you're talking about a multimodal animal model that this is just database that one's multiple models of databases but in my experience most of the multimodal interfaces combined government photographed and the reason for that is that the kind of that this combination of and the removes the the disadvantage is that each of the other other kind has because the document is quite that modeling relationships with between documents and that some of you have drastically the good at this but it's not that you would add up modeling the nested daytime because then you always have to go to the 2 to to the relations between those entities and stuff like that so if we look again at all or the problem at the beginning we had this disconnect
between all of that what they're doing 1st describing and with the world around and now let's look at this is that there's
an error here and the and see that because the light is right there is an error and so now we have a list of which is connected to the space of of identity and this edge itself
also has something to compare posted node to the active state this edge is since 2003 free for example and now we have a we know Milan I have this distance anymore because this is very close to what the person drop through their domain description so if you want to implement this kind of modeling is kind a way to explain to other people to work together with other people in your team along with your customers than the 1st step is to explain graph and I explain graphs a lot of people in extreme explaining graphs that is even more easily if you have a a piece of paper in front of you will you can draw them and strong edges and floors nodes and because it's very close to what people are having the so but I don't know how how many I expect but nobody had problems with the understanding that may strike the same thing with the entire table things and people had a much harder time correctly had around it as soon as we have references between cells of the tables but this is not a problem in the graph so this is the 1st that when you talk to your comments and then a 2nd wasn't so it's time to understand about the domain of where you have to learn about what is going on in this domain what are the words we using what is the space shuttle was an astronaut 1 is this airplane carrying this space shuttle we need to understand those words so we build up vocabulary that is right in the domain where we are solving a problem and this is very useful because then we can also talk to the customers of this pairs of of this domain expert and because they are using in the way and and then you are you working together to find a common language because now you know what happened words in a vocabulary and this that the other person has a new tools state of drawing graphs and so now together you can model model of language and talk about it and find of different words that everyone understands the and you can then have documents that describe what what you're talking about and what this means to is that you have 1 that everyone involved understands and this is extremely important in life because there's an excellent book 190 1 of my favorite technical books written off it's not that technical maybe and it's is designed things it's and what about people this faulty just themselves for 2 reasons states we're using devices when using the showers for example where everything is messed up on and the he describes that if everyone in your team has the same model in in their hat then this will reflect on the people that are using your model as well because that 1 problem that we have a lot of products both in this article entitled is that in your team you have no you don't have a consistent view on what you want your product is doing what it what language you're using to describe so but what what is also reflected the customer is a very what makes picture so you don't really know what the what that the customer doesn't really understand because some to using this 1 using that word describe the same so if everyone speaks the same language and use the same words then will then the customer will understand of the same language in the same way so everyone including the possible use of the same language which leads to a much better user experience and then you need to the of the model along implementation because what I just heard about the size like what a whole and then they have some design document which is 5 years old and discriminating modular system but describe something time so this is extremely important we have to involve all model because otherwise but this time with but we now have the tools that everyone in the team can involve model where we have a problem that says OK I know there's some error here on this doesn't work like that have to adapt our model but we also have the domain experts OK this that doesn't work like that our customers and something different we need to over 1 as well and then the implementation so those 2 people on job so this is quite but basically the recipe so 1st explain grass the about the domain
by the common language build 1 model for everyone involved in the whole model alongside the implementation and if you do that thing and you will read it will resolve the problem and we tried that with different customers work well so I think it's much for this and this is my guitar panel and my twitter and and if you want to try the database that does those multimodal tanks and jet ordering we have a lot of time for for questions so thank you for listening
1st and then we take some questions OK so you ask about that but the the performance of this kind that his actions which I have to repeat it for the k so that this is a very general question because there are different databases that moment on I don't see any downsides and performance in this area we compare around the need to pure documents for the moment there is no the performance difference so I don't think there is inherent in this kind of modeling but there's a big difference only this is the 1st of all you in the modelling or in the database but it the in the data it the OK so I I think there is model performs the small I I my experience it is OK yes the OK so the the question was whether we have a value objects that are embedded in different kinds of objects then we have petitioned and that's that's the question because you have to to reimplement for making something in your API because you are using different places where I think that is a problem because what what's in what you do in your code will is on you have some of object class for edges and this is used by the difference but different of at this kind thing so that that there's a lot of what we were just all the users and persons and in addition so on behalf of those 2 and then you have your arm that is faster than in your program you have to have a matter which I wouldn't means that all of the database it's maps the embedded addresses into all entries small edits on instances and then we have integrated can we use all code so in order to have not only problem with that approach of the errors can be a resource and so the question was about rests on and if it is a resource I think you ability object the new results are it is in the presence and so I think it is still a resource if is a young person it from the rest perspective the analysis of the source of the 1st so that you can do that and you can identify hot yeah along and there is no problem and you can have different at different URI pointing to the same representation because we know that all objects are in the same kind of computations many times as you want so maybe it's I don't understand the question entirely but again I don't know maybe so we to talk later about yes make the people in the light of new normalized yet SQL like maybe I yes so the yeah I think we can start with a sort of always forget to repeat so what you want and the domain expert changes of things from about but the problem like changing the zip code from for not just packages will and the database administrator sense of what is happening because I need to adjust things not right OK so yes so this this can still benefit right but I think we we can escape that on we will have this kind of those kinds of problems in each case we're doing demanded or if we don't do it or maybe a misunderstanding that because it could change if this person is doing is talking the domain and its could also change if the person's not talking the right so I think that only because when we are talking the same language that we can communicate so much easier to follow those kinds of issues because if the person for me a political is is always digits then this is now part of your domain description right and and if if something if this changes for some reason then everyone understands that this needs to change something else in the system I came here again I was sorry yes of course so that if you are embedding things then this is of course a higher yes I totally agree how much more depends on how big your projects so yeah but this bigger and agree OK there is a much more listening and having less than


  532 ms - page object


AV-Portal 3.9.2 (c7d7a940c57b22d0bc6d7f70d6f13fde2ef2d4b8)