Quantcast
Channel: Abstract classes in SQL Server. Are they even possible? - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 3

Abstract classes in SQL Server. Are they even possible?

$
0
0

I have a very specific question that I am surprised no one has yet asked. It involves a concrete class model and SQL Server 2016 DDL. The main point is:In my model, some classes inherit from a base class, let's say "BaseInfo".

This class is abstract. In SQL terms it means I do not (or do I?) want to create a separate table with rows (eg. CREATE TABLE "BaseInfo"..... I do however want some of my tables (actually quite a lot of them) to have the same columns (plus some of their own). In OOP terms I want some of my classes to inherit from that table definition. Is there a way to define this in DDL, or do I have to implement this manually?

Notes:

  1. I have read all the articles that are to be found on TPH, TPT, TPC. They are too simplistic, they all feature the same Person-Student-Educator Model and do not match my case. What I probably want to do is TPC, but I want changes made to BaseInfo table to automatically apply to all child classes.

  2. I will not be querying BaseInfo. I'd rather do a (rare) complex query involving some (or all) of the children.

  3. Changes made to BaseInfo DDL (ALTER TABLE BaseInfo...) have to be reflected to the children (preferably automatically).

  4. PostgreSQL shines here with the INHERITS statement. Is there any equivalent in SQL Server (I have done research and found nothing yet)?

  5. In case I get no answer or have some other breakthrough, I will go the manual approach. Save a code snippet with the BaseInfo DDL and add it to the CREATE TABLE statement of each child table.

  6. The answer must respect the conceptual model definition!


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images