Master of my domain quotes8/18/2023 You can have common features in a common table, and separate features in a separate table, and do a join to reconstruct a single object. You'd have CaseMessage and QuoteMessage also, to follow the distinction forward. You do not have to rely on inheritance you can have disjoint tables for each set of relationships. If you need all properties - a union of CaseProperty and QuoteProperty, then this can work out. This works when you often have to produce a union of the various subclasses. You have several ways to implement class hierarchies and "is-a" relationships.Īs you've suggested with type discriminators to show which subclass this really is. You have a prominent is-a pair of relationships: Case IS-A Property and Quote IS-A Property. Reusing a structure can be important, but less so. Indeed, the major purpose of inheritance is to reuse code. In some cases, too much abstraction leads to a too-complex relational model. The trick with DDD is to recognize that abstraction is not always your friend. The only way I can think of to relate a Message table back to the Case and Quote tables is to have both a RelationID and RelationType field, but there's no obvious way to tell SQL server how that relationship works, so I won't have any referential integrity. They'd all have their own sequential IDs, and the Case and Quote would be related back to Property by a PropertyID field. My initial thoughts were to have four tables: Property, Case, Quote and Message. I'm thinking of using the Entity Framework to get my Models in and out of the database. So essentially, I can have a Property that has a few Quotes and Cases and a load of Messages that can belong to either of those.Ī PropertyObject has a Reference property (and therefore so do Quote and Case) so any Message object can be related back to a Quote OR Case by it's Reference property. So Property has an Items property of type List which can contain both Case and Quote objects. Message - simple class that has properties Reference, Text and SentDateĬase and Quote have a lot of similar properties, so I also have a PropertyObject abstract base class that they inherit from. I have the following object model hierarchy: Property - has properties such as Address and Postcode I'm building a web application in ASP.NET MVC, although I don't think the platform matters that much. Now I'm having difficulty deciding the best way to build my tables in SQL Server to match the models. Okay, I'll be straight with you guys: I'm not sure exactly how Domain Driven my Design is, but I did start by building Model objects and ignoring the persistence layer altogether.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |