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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:58:01+00:00 2026-06-02T05:58:01+00:00

I have a basic data model that I want to implement in MySQL. I

  • 0

I have a basic data model that I want to implement in MySQL. I will be using mysqldb and SQLalchemy to do the data part, taking some data from some XML.

I’m not really sure how to implement what I want to do, and I wondered if anyone could point me in the right direction.

I have a few tables, and each table holds a section of the data.

Table 1 - recordTitle, recordID, recordDate
Table 2 - recordProp1, recordProp2, recordProp3
Table 3 - recordPropA, recordPropB, recordPropC

All the tables are unique in their own space, but T1 can have many T2s and T3s, and T2/T3 can belong to many T1s. Make sense?

I figured the way to resolve this was to have a 4th table:-

Table 4 – T1ref, T2ref, T3ref

and have a new colunm in T1-3 that is called TnRef and is basically a primary key for that table.

  1. Does this sound like a sensible approach?
  2. I figured when populating the data, I need to check each table entry for uniqueness, if it is, I capture the TnRef value, and if its isnt I insert the new row and collect the TnRef value after that. Once I have the value I can populate the T4 row that links everything together.
  3. Is ORM the right tool to do this?
  • 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-02T05:58:03+00:00Added an answer on June 2, 2026 at 5:58 am
    1. For a many-to-many relationship like you described, yes I think it makes sense to have a fourth table linking T1 records with T2(s) and T3(s). I think you’ll want to add a key column to T2 and T3 though, to enable T4 to store the links correctly.

    2. I assume you mean that T2 and T3 will be expanding, and that your application will be fielding requests to (for example) add { recordProp1= someval, recordProp2= someotherval } to a given record in T1. If so, then yes, you would want to do the lookup on T2 first, then insert it into T4 based on the keys of T1 and T2.

    3. I think ORM is absolutely the right tool to do this. You’ll want to make sure all the foreign key relationships are correct in MySQL first, of course. But SqlAlchemy can handle many-to-many relationships. Take a look: http://docs.sqlalchemy.org/en/latest/orm/relationships.html#many-to-many

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

Sidebar

Related Questions

I have a basic database that I want to pull out sub data (related)
I have a very basic data class that is subclassed from NSObject. I declare
I have a basic windows service which does some conversions of data. There's decoupled
So, I'm trying to use Doctrine to retrieve some data. I have some basic
I have a data mart mastered from our OLTP Oracle database using basic Materialized
I have a number of tables containing some basic (business related) mapping data. What's
I want to build a fairly simple Android application. The basic data model of
I have blob data in my database and they are images that I want
I'm learning assembly and I have a very basic loop here segment .data msg:
I have a basic class that derived subclasses inherit from, it carries the basic

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.