How do you effectively model inheritance in a database?

后端 未结 9 1593
南旧
南旧 2020-11-22 05:37

What are the best practices for modeling inheritance in databases?

What are the trade-offs (e.g. queriability)?

(I\'m most interested in SQL Server and .NET,

9条回答
  •  不要未来只要你来
    2020-11-22 06:26

    Note that some database engines already provides inheritance mechanisms natively like Postgres. Look at the documentation.

    For an example, you would query the Person/Employee system described in a response above like this:

      /* This shows the first name of all persons or employees */
      SELECT firstname FROM Person ; 
    
      /* This shows the start date of all employees only */
      SELECT startdate FROM Employee ;
    

    In that is your database's choice, you don't need to be particularly smart !

提交回复
热议问题