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 4080458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:55:58+00:00 2026-05-20T17:55:58+00:00

Hello, I’m currently trying to apply the most efficient way to store an extend

  • 0

Hello,
I’m currently trying to apply the most efficient way to store an “extend” relationship between entities in a relational database.

For the sake of example, lets say we have the following simplified entities:

  • User
  • Student (extends User)
  • Teacher (extends User)

User contains attributes which apply to both Student and Teacher. Both Student and Teacher contain custom attributes which are unique to them.

The first thing that comes to mind is to create a single table with columns for all singular data (i.e. except one-to-many fields):

User
-------------
User ID
First name
Last name
Student class
Teacher office no.
Teacher description
...

This however won’t be very efficient from a storage perspective, because:

  • the majority of rows will contain students, with a small number of teachers
  • teachers will have much more unique columns, which would waste space in students’ rows

It would be more efficient to replicate relationships between the entities:

User
-------------
User ID
First name
Last name
...


Student
-------------
User ID
Student class
...


Teacher
-------------
User ID
Teacher office no.
Teacher description
...

So my questions are:

  1. Is the above concern taking it too far, i.e. should we leave storage efficiency to the database engine?
  2. Is splitting the entities into 3 tables still OK in terms of normalization?
  3. If it’s not a good approach, how would you recommend to treat “extend” relationships in a relational database?

Thank you.

  • 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-20T17:55:59+00:00Added an answer on May 20, 2026 at 5:55 pm

    If a user can’t be both a teacher and a student, then you’re looking at a straightforward supertype/subtype problem. (I’m using supertype and subtype in their relational database design sense, not in their object-oriented programming sense.) You’re right to store in “students” only those attributes that describe students, and to store in “teachers” only those attributes that describe teachers.

    -- Supertype: users
    create table users (
      user_id integer not null unique,
      user_type char(1) not null 
        check (user_type in ('T', 'S')),
      -- other user columns
      primary key (user_id, user_type)
    );
    
    -- Subtype: students
    create table students_st (
      user_id integer not null,
      user_type char(1) not null default 'S'
        check (user_type = 'S'),
      locker_num integer not null unique 
        check (locker_num > 0),
      -- other student columns
      primary key (user_id, user_type),
      foreign key (user_id, user_type) 
        references users (user_id, user_type) 
        on delete cascade
    );
    
    -- Subtype: teachers
    create table teachers_st (
      user_id integer not null,
      user_type char(1) not null default 'T'
        check (user_type = 'T'),
      office_num char(4),
      -- other teacher columns
      primary key (user_id, user_type),
      foreign key (user_id, user_type) 
        references users (user_id, user_type) 
        on delete cascade
    );
    
    create view teachers as 
    select u.user_id,
           u.user_type,
           -- other user columns
           t.office_num
           -- other teacher columns
    from users u
    inner join teachers_st t on (u.user_id = t.user_id);
    
    create view students as 
    select u.user_id,
           u.user_type,
           -- other user columns
           s.locker_num
           -- other student columns
    from users u
    inner join students_st s on (u.user_id = s.user_id);
    

    At this point, you’d also do whatever your dbms requires to make these two views updatable—triggers, rules, whatever. Application code inserts, updates, and deletes from the views, not from the base tables.

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

Sidebar

Related Questions

Hello , I am currently working on the student association's website. The student's association
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello I was writing a Regular Expression (first time in my life I might
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello there and Merry Christmas !!! I am new to WPF and I am
Hello we have an SQL server application running over a low bandwith connection. We

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.