I was talking with a programmer pal of mine about inheritance and its use in designing models. He's a big proponent and I'm a little more tepid. Mostly because I tend to design systems from the bottom up: Database -> Application -> Presentation (honestly, I'm not much of a front-end guy, so I often leave presentation entirely to someone else). I find that relational database systems don't support inheritance without a lot of 1-to-1 relationships to other tables.
If I'm designing from a conceptual standpoint, an Administrator is a User is a Person. Starting from the database up, an Administrator is a User with UserType = "Administrator". Reconciling these approaches seems difficult to me, and therefore I only use inheritance with non-persisted objects.
What's wrong with my thinking? Why is inheritance such an oft-celebrated aspect of OO if it has these inherent incompatibilities with traditional relational structures? Or, is it me who's not mapping inheritance properly to relational data? Is there some guidance out there that might clear this up for me?
Sorry for the rambling question and thanks in advance for your answers. If you include code in your response, C# is my "native language".
Lots of programs don’t use a RDBMS.
– 26 августа 2009, 22:06Администратор - это пользователь - это человек (смотри, ма - без наследования) отлично работает до тех пор, пока у пользователя не будет идентификатора пользователя / пароля / подсказки / любых свойств, которых нет у человека, а у администратора должен быть даже более конкретный материал. Как это сделать в своей базе данных? Та же таблица с множеством столбцов, допускающих NULL? Отдельные таблицы, связанные (о нет) один к одному? Угадайте, оба подхода можно сопоставить с стратегиями наследования :-)
– ChssPly7626 августа 2009, 22:11