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

  • SEARCH
  • Home
  • 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 8179397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:59:30+00:00 2026-06-06T23:59:30+00:00

I am trying to implement some tables that mimic inheritance in a relational (sqlite)

  • 0

I am trying to implement some tables that mimic inheritance in a relational (sqlite) database. My goal is to have one master table with general fields, and some child tables with specialized fields. Every record in the master table will have exactly one counterpart in exactly one of the specific tables. What I want looks like this:

Master table:

id (PK) #Your average web2py unique auto-incrementing int field
#Some general fields

Child tables:

id (PK, FK referencing the PK of the master table)
#Some specialized fields

Having a default “id” PK for each child table has no use to me. All I need is an FK reference to the master table, which can serve as the PK for the child tables. This means that the PK of the child tables will be unique, but will contain gaps. This is because a child table will only reference some of the records of the master table.

I get the impression that doing this (not giving the child tables the regular “id” PK) is against the Web2py way. So my questions are as follows:

  1. Is this a Bad Idea™? If so, why?
  2. How would I implement this? Can Web2py handle tables that don’t have an auto-incrementing int as PK?

It’s very important for me to apply the correct style and practice when writing code. I am open to alternative approaches.

Thank you for your help.

  • 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-06-06T23:59:31+00:00Added an answer on June 6, 2026 at 11:59 pm

    See the book section on keyed tables. If this is a database specifically for use with web2py, I suggest you stick with the standard web2py approach:

    db.define_table('master', ...)
    
    db.define_table('child', Field('master', db.master))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to implement unit testing and currently have some code that does
Trying to implement some nested loops that are spitting out good old nested html
I want to implement some sort of lookup table in C++ that will act
I have a three different tables that I'm trying to join up correctly but
I am trying to implement hibernate on a legacy database (that still has a
First, some background: I am trying to implement a master-detail interface in Cocoa (for
We have a set of views (quite a few) that we're trying to implement
I'm trying to implement Search Engine. I have web application that displays list of
I'm trying to implement some authorization with cancan where a user will have the
I trying to implement some relatively simple 2D sprite batching in OpenGL ES 2.0

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.