Database Table Schema and Aggregate Roots

Posted by bretddog on Stack Overflow See other posts from Stack Overflow or by bretddog
Published on 2011-01-15T15:30:53Z Indexed on 2011/01/15 20:53 UTC
Read the original article Hit count: 222

Filed under:
|
|
|
|

Hi,

Applicaiton is single user, 1-tier(1 pc), database SqlCE. DataService layer will be (I think) : Repository returning domain objects and quering database with LinqToSql (dbml). There are obviously a lot more columns, this is simplified view.

http://img573.imageshack.us/img573/3612/ss20110115171817w.png

alt text

This is my first attempt of creating a >2 tables database. I think the table schema makes sense, but I need some reassurance or critics. Because the table relations looks quite scary to be honest. I'm hoping you could;

  • Look at the table schema and respond if there are clear signs of troubles or errors that you spot right away.. And if you have time,

  • Look at Program Summary/Questions, and see if the table layout makes makes sense to those points.

Please be brutal, I will try to defend :)

Program summary:

a) A set of categories, each having a set of strategies (1:m)

b) Each day a number of items will be produced. And each strategy MAY reference it. (So there can be 50 items, and a strategy may reference 23 of them)

c) An item can be referenced by more than one strategy. So I think it's an m:m relation.

d) Status values will be logged at fixed time-fractions through the day, for: - .... each Strategy.....each StrategyItem....each item

e) An action on an item may be executed by a strategy that reference it. - This is logged as ItemAction (Could have called it StrategyItemAction)

User Requsts

b) -> e) described the main activity mode of the program. To work with only today's DayLog , for each category. 2nd priority activity is retrieval of history, which typically will be From all categories, from day x to day y; Get all StrategyDailyLog.

Questions

  1. First, does the overall layout look sound? I'm worried to see that there are so many relationships in all directions, connecting everything. Is this normal, or does it look like trouble?

  2. StrategyItem is made to represent an m:m relationship. Is it correct as I noted 1:m / 1:1 (marked red) ?

  3. StrategyItemTimeLog and ItemTimeLog; Logs values that both need to be retrieved together, when retreiving a StrategyItem. Reason I separated is that the first one is strategy-specific, and several strategies can reference same item. So I thought not to duplicate those values that are not dependent no strategy, but only on the item. Hence I also dragged out the LogTime, as it seems to be the only parameter to unite the logs. But this all looks quite disturbing with those 3 tables. Does it make sense at all? Or you have suggestion?

  4. Pink circles shows my vague attempt of Aggregate Root Paths. I've been thinking in terms of "what entity is responsible for delete". Though I'm unsure about the actual root. I think it's Category. Does it make sense related to User Requests described above?

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql