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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:30:32+00:00 2026-06-14T00:30:32+00:00

let say i have two table, User and Language user (Table Name) —————– user_id

  • 0

let say i have two table, User and Language

user (Table Name)
-----------------
user_id (PK)
user_name
mobile
...
....

language (Table Name)
---------------------
lang_code (PK)
lang_name
...
....

The Question is, if i want to add relationship between user and language table(Many to many) which is a right way ?

solution 1

user_language (Table Name)
--------------------------
user_id (FK)
lang_code (FK)


or solution 2

user_language (Table Name)
--------------------------
user_id (PK)
lang_code (PK)


or solution 3

user_language (Table Name)
--------------------------
user_lang_id (PK)
user_id (FK)
lang_code (FK)

i saw many people add primary key on many to many table, but i think that not important and wasting space. so which is right ?

btw i’m using PostgreSQL

  • 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-14T00:30:33+00:00Added an answer on June 14, 2026 at 12:30 am

    Personally, I would go with solution 4:

    user_language
    ---------------
    user_id (FK)
    lang_code (FK)
    
    with composite PRIMARY KEY (user_id, lang_code)
    

    I don’t think adding the surrogate key (user_lang_id in solution 3) really adds any value to the schema and simply adds another column to have to worry about. The primary key is a good idea though to maintain uniqueness – without it, you could add the same user_id/lang_code combination multiple times.

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

Sidebar

Related Questions

Let's say I have a table with two columns, where a user places a
I have two tables with similar columns - let's say table A with column
Let's say I have a USER table, and each my database is to handle
Let's say I have two SQL tables: QYZ: id, uid<user id, FK*>, somedatacolumn USERS:
Okay, so let's say I have a mysql database table with two columns, one
Let's say I have a table which can contains data like this: id name
Let's say we have two tables, user and domain . User may have one
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let's say I have two tables, users and notes. Let's say the schemas look
Let's say I have two tables lnglngdef: lngId | lngName 1 Korean 2 Spanish

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.