---
title: Inheritance in Database Design
description: Inheritance in Database Design
image: https://blog.e-zest.com/hs-fs/file-3441636432-png/blog-files/database-tables-for-concrete-table-inheritance.png
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/inheritance-in-database-design/#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [News](https://blog.e-zest.com/news)
- [Podcasts](https://www.e-zest.com/podcasts)
- [Healthcare](https://blog.e-zest.com/healthcare)
- [CSR](https://blog.e-zest.com/csr)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [Media Kit](https://www.e-zest.com/media-kit)

# Inheritance in Database Design

[Madhura Oak](https://blog.e-zest.com/author/madhura-oak)  Oct 29, 2013

[Java](https://blog.e-zest.com/topic/java) [Technology](https://blog.e-zest.com/topic/technology)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/inheritance-in-database-design/&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/inheritance-in-database-design/&text=Inheritance%20in%20Database%20Design>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/inheritance-in-database-design/>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/inheritance-in-database-design/>

How do you design a Domain Model and the related database tables? People usually follow one of the following two approaches:

1. Design relational database first and then proceed with creating classes (of course, if you are using object-oriented technologies)
2. Design domain model first followed with the database design

While both approaches lead to the same outcome i.e. database + domain model design, there are advantages of following the second approach.

Inheritance is one of the feature of object-oriented programming. It is used to define “is-a” relationship between objects. However, relational databases don’t support inheritance. Hence, when we do database design first, we might end up with designing tables without considering their inheritance. Let’s see an example.

I have to store an information for two types of statements such as bank account statement and credit card statement for a user. I can create a table for each type of statement which will have all the attributes related to it. Thus, I can create two tables – AccountStatement and CreditCardStatement – as shown in Figure 1 (only few columns are added for simplicity).

[![Database tables for Concrete Table Inheritance](https://blog.e-zest.com/hs-fs/file-3441636432-png/blog-files/database-tables-for-concrete-table-inheritance.png?width=300&height=350&name=database-tables-for-concrete-table-inheritance.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Database-tables-for-Concrete-Table-Inheritance.png)

Figure 1. Database tables for Concrete Table Inheritance.

The database design for these tables does not use inheritance. However, when I create the domain model, instead of creating two non-related classes AccountStatement and CreditCardStatement, I would create an abstract Statement class as a base class for these two classes as shown in Figure 2. In this way, I would be using the *Concrete Table Inheritance* or *Table per Concrete Class Strategy* of JPA 2.0.

[![Domain Model](https://blog.e-zest.com/hs-fs/file-3441636442-png/blog-files/domain-model.png?width=300&height=350&name=domain-model.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Domain-Model.png)

Figure 2. Domain Model

There is a disadvantage of using this database design. The tables AccountStatement and CreditCardStatement are not related to each other. We can create records in these tables using the same primary keys. For e.g. we can have an AccountStatement record with the primary key value 1002 and also a CreditCardStatement record with the same primary key value 1002. However, when we use the domain model in Figure 2 logically we should not have more than one Statement objects with the same primary key value. Thus, primary key management is one of the disadvantages of using this strategy.

Moreover, the *Table per Concrete Class Strategy* has poor support for polymorphic queries and its support is optional in JPA 2.0 which means that not all persistence providers provide its support.

 Thus, a better way to design this database is to use a Statement table which contains the common attributes. When we do this database design first, we can end up using a “has a” relationship as shown in Figure 3. Note that the AccountStatement and CreditCardStatement tables contain a primary key as well as a foreign key to the Statement table.

[![Database design which uses a “has a” relationship](https://blog.e-zest.com/hs-fs/file-3586010035-png/blog-files/database-design-which-uses-a-%E2%80%9Chas-a%E2%80%9D-relationship.png?width=300&height=350&name=database-design-which-uses-a-%E2%80%9Chas-a%E2%80%9D-relationship.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Database-design-which-uses-a-“has-a”-relationship.png)

Figure 3. Database design which uses a “has a” relationship

The domain model for this database design is shown in Figure 4. You can see that the inheritance is not used in this domain model design as it includes a statement property within the subclasses. Thus, the domain model also uses a “has a” relationship.

[![Domain Model for database design using “has a” relationship](https://blog.e-zest.com/hs-fs/file-3586010045-png/blog-files/domain-model-for-database-design-using-%E2%80%9Chas-a%E2%80%9D-relationship.png?width=300&height=350&name=domain-model-for-database-design-using-%E2%80%9Chas-a%E2%80%9D-relationship.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Domain-Model-for-database-design-using-“has-a”-relationship.png)

Figure 4. Domain Model for database design using “has a” relationship

To use a “is a” relationship, we need to use the domain model design given in Figure 5.

[![Using “is a” relationship in domain model](https://blog.e-zest.com/hs-fs/file-3586010055-png/blog-files/using-%E2%80%9Cis-a%E2%80%9D-relationship-in-domain-model.png?width=300&height=350&name=using-%E2%80%9Cis-a%E2%80%9D-relationship-in-domain-model.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Using-“is-a”-relationship-in-domain-model.png)

Figure 5. Using “is a” relationship in domain model

The Joined Subclass Strategy of JPA allows the use of “is a” relationship in domain model as well as the underlying database design. The database design which uses the “is a” relationship is given in Figure 6. The statementId column in both AccountStatement and CreditCardStatement tables is as a primary key as well as the foreign key to the Statement table.

[![Database design using “is a” relationship](https://blog.e-zest.com/hs-fs/file-3586010065-png/blog-files/database-design-using-%E2%80%9Cis-a%E2%80%9D-relationship.png?width=300&height=350&name=database-design-using-%E2%80%9Cis-a%E2%80%9D-relationship.png)](https://blog.e-zest.com/wp-content/uploads/2013/10/Database-design-using-“is-a”-relationship.png)

Figure 6. Database design using “is a” relationship

To summarize, for the correct use of inheritance in domain model, the database design also needs to use inheritance. Since RDBMS does not support inheritance, we could end up using the “has a” relationship if we do database design first followed by the domain model design. If we do the domain model design first followed by the database design, the chances of using inheritance accurately are high. Though you can follow any approach, you should consciously design your database to use inheritance if you do the database design first.

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/inheritance-in-database-design/&text=Inheritance%20in%20Database%20Design>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/inheritance-in-database-design/>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/inheritance-in-database-design/&title=&summary=&source=>

### Similar Blog

[![How to Create Own Custom JMeter Template?](https://blog.e-zest.com/hubfs/How%20to%20Create%20Own%20Custom%20JMeter%20Template%201280x667%202560x1334.jpg) How to Create Own Custom JMeter Template? We frequently need to construct Test Plans with a similar format when working on web application performance testing using Apache ... By Kishore Bhamare Feb 28, 2023](https://blog.e-zest.com/how-to-create-own-custom-jmeter-template)

[![Hoisting in JavaScript](https://blog.e-zest.com/hubfs/Blog_Files/Hoisting%20in%20JavaScript-190225.png) Hoisting in JavaScript Generally, we all have heard of the term ‘hoisting’ with reference to flag hoisting. By Ajit Sakhare Feb 26, 2019](https://blog.e-zest.com/hoisting-in-javascript)

[![OWASP ZAP Modes](https://blog.e-zest.com/hubfs/OWASP%20ZAP%202.5.0.png) OWASP ZAP Modes OWASP ZAP is an open-source web security testing tool, used for detecting vulnerabilities in web applications.ZAP provides you ... By Kishore Bhamare Dec 22, 2016](https://blog.e-zest.com/owasp-zap-modes)

[![Automation using Selenium WebDriver Frameworks](https://blog.e-zest.com/hubfs/Selenium_blog_image.png) Automation using Selenium WebDriver Frameworks Frameworks help to structure our code and make the maintenance process easy. Without frameworks we will place all our code and ... By Uddhav Naik Sep 26, 2016](https://blog.e-zest.com/automation-using-selenium-webdriver-frameworks)

[Tutorial: Elasticsearch Integration in a Java Application The whole world relies on search to get access to relevant information and data. Handling this large amount of data presents a ... By Jyoti Agrawal Jun 11, 2015](https://blog.e-zest.com/tutorial-elasticsearch-integration-in-a-java-application/)

[Oracle NoSQL Database (ONDB) Relational databases have been around us for more than 20 years now. Needless to say, they are mature and an obvious choice for ... By Madhura Oak Dec 24, 2013](https://blog.e-zest.com/oracle-nosql-database-ondb/)

[Session State Isolation Techniques Isolation of data in a session is the trickiest part of session management. A session may constitute of multiple requests. ... By Madhura Oak Dec 02, 2013](https://blog.e-zest.com/session-state-isolation-techniques/)

[Session Management There are three ways of session management in n-tier applications: By Madhura Oak Nov 27, 2013](https://blog.e-zest.com/session-management/)

[Transaction and Query timeout Performance is one of the non-functional requirements of an application. It defines the acceptable maximum response time for ... By Madhura Oak Nov 25, 2013](https://blog.e-zest.com/transaction-and-query-timeout/)

[![Multiple Inheritance in Domain Model Design](https://blog.e-zest.com/hs-fs/file-3586010320-png/blog-files/uml-class-diagram-%E2%80%93-bridge-pattern.png) Multiple Inheritance in Domain Model Design While using multiple inheritance in domain model design you need to be cautious as programming languages such as Java do not ... By Madhura Oak Nov 13, 2013](https://blog.e-zest.com/multiple-inheritance-in-domain-model-design/)

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.