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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:31:43+00:00 2026-05-16T18:31:43+00:00

There are two methods which I noticed while designing child tables Method 1 Example:

  • 0

There are two methods which I noticed while designing child tables

Method 1 Example:


Master Table >>Order Table (order_id pk)
Child Table >>order_products 
table (order_id,product_id, quantity,PK (order_id,product_id))

Method 2 example:


Master Table >>Order Table (order_id pk)
Child Table >>order_products table (order_product_id PK, order_id,product_id, quantity)

Question:
Notice that We are using addition order_product_id in the second method. That is my question, is it goo to use combined primary key or introduce a new column like in method 2?

what are pros and cons.
is the anwer depends on the relationship? (in case of one-to-many method 1 is better or in case of many-to-many method 2 is better etc)

  • 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-16T18:31:44+00:00Added an answer on May 16, 2026 at 6:31 pm

    the second one’s the choice to go since you have a composite primary key in the first one:

    PK (order_id,product_id)
    

    so you always need these two values to refer to a record.

    I’d recommend the second one and if you need some restrictions create a unique index on order_id and product_id.

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

Sidebar

Related Questions

Which one of these two method invocations is considered most pythonic? some_method(that_has, very_many, aurguments=None,
In EXT.Panel, there are two methods for collapsing/expanding a Panel. collapse(Boolean animate) and expand
I wrote two methods to check there performance public class Test1 { private String
I have these two methods on a class that differ only in one method
I've noticed that there are two different ways to load nib/xib files: via the
So I've been reading Effective Java by Joshua Bloch and noticed two points which
I saw there are two methods for getting data from the datastore: fetch() and
I have a stateless session bean which is exposed as webservice. There are two
These two methods appear to behave the same to me public IEnumerable<string> GetNothing() {
So these two methods have the same signature but different constraints public static void

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.