Inheritance in database?

后端 未结 9 1091
醉话见心
醉话见心 2021-01-11 20:14

Is there any way to use inheritance in database (Specifically in SQL Server 2005)?

Suppose I have few field like CreatedOn, CreatedBy

9条回答
  •  长发绾君心
    2021-01-11 20:45

    There is no such thing as inheritance between tables in SQL Server 2005, and as noted by the others, you can get as far as getting help adding the necessary columns to the tables when you create them, but it won't be inheritance as you know it.

    Think of it more like a template for your source code files.

    As GateKiller mentions, you can create a table containing the shared data and reference it with a foreign key, but you'll either have to have audit hooks, triggers, or do the update manually.

    Bottom line: Manual work.

提交回复
热议问题