Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 625387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:18:14+00:00 2026-05-13T19:18:14+00:00

I have two classes Parent and Child . class Child extends Parent { private

  • 0

I have two classes Parent and Child.

class Child extends Parent {
    private String extraField1;
    private String extraField2;
    ...
}

Child class has 2 extra fields extraField1 and extraField2.

Q1. Should I make two diff. tables in the databse: one for Child and other for Parent?

or

Q1. Should I add two columns in the Parent table (each column for one extra field) and store the Child in the Parent table.

=============================== EDITED =======================================

Yes, Child and Parent are classes in the same hierarchy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:18:14+00:00Added an answer on May 13, 2026 at 7:18 pm

    Should there be 2 datatables for a Parent and Child class in Java?

    There is no universal answer to this question. There are actually several techniques to map an inheritance hierarchy into a relational database and they all have advantages and disadvantages. Choosing one or the other depends on your context.

    Scott Ambler details the various approaches in the section 2. Mapping Inheritance Structures of his famous paper Mapping Objects to Relational Databases: O/R Mapping In Detail that I’m quoting below:

    (…) In this
    section you’ll see that there are
    three primary solutions for mapping
    inheritance into a relational
    database, and a fourth supplementary
    technique that goes beyond inheritance
    mapping. These techniques are:

    • Map the entire class hierarchy to a single table
    • Map each concrete class to its own table
    • Map each class to its own table
    • Map the classes into a generic table structure

    For a full comparison (with advantages, disadvantages and a recommendation on when to use), have a look at the section 2.6 Comparing The Strategies.

    I can’t do a better job than him so there is no point at paraphrasing him, just refer to the original paper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 355k
  • Answers 355k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Visual Studio devenv.exe executable is indeed a native program.… May 14, 2026 at 8:37 am
  • Editorial Team
    Editorial Team added an answer Put the .cpp file as the first argument. g++ mplsh-run.cpp… May 14, 2026 at 8:37 am
  • Editorial Team
    Editorial Team added an answer You can delay showing the loading gif for a quarter… May 14, 2026 at 8:37 am

Related Questions

I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract
Back when I was learning HTML, I loved how easy it to build pages
I have two classes: public class Parent { public virtual long? ID { get;
I have two classes in an owned one-to-many relationship. The parent is Map, and
I have two tables that I want to fetch data from. Lets call them

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.