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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:04:07+00:00 2026-06-10T14:04:07+00:00

In my database I have a list of users with information about them, and

  • 0

In my database I have a list of users with information about them, and I also have a feature which allows a user to add other users to a shortlist. My user information is stored in one table with a primary key of the user id, and I have another table for the shortlist. The shortlist table is designed so that it has two columns and is basically just a list of pairs of names. So to find the shortlist for a particular user you retrieve all names from the second column where the id in the first column is a particular value.

The issue is that according to many sources such as this Should each and every table have a primary key? you should have a primary key in every table of the database.

According to this source http://www.w3schools.com/sql/sql_primarykey.asp – a primary key in one which uniquely identifies an entry in a database. So my question is:

  1. What is wrong with the table in my database? Why does it need a primary key?

  2. How should I give it a primary key? Just create a new auto-incrementing column so that each entry has a unique id? There doesn’t seem much point for this. Or would I somehow encapsulate the multiple entries that represent a shortlist into another entity in another table and link that in? I’m really confused.

  • 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-10T14:04:09+00:00Added an answer on June 10, 2026 at 2:04 pm

    If the rows are unique, you can have a two-column primary key, although maybe that’s database dependent. Here’s an example:

    CREATE TABLE my_table
    (
    col_1 int NOT NULL,
    col_2 varchar(255) NOT NULL,
    CONSTRAINT pk_cols12 PRIMARY KEY (col_1,col_2)
    )
    

    If you already have the table, the example would be:

    ALTER TABLE my_table
    ADD CONSTRAINT pk_cols12 PRIMARY KEY (col_1,col_2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of e-mails from one database which I want to check
I have a database of Employees and a dropdown list which I generated with
I have a project which provides users with a list of current tasks that
In my database I have a list of cases: { Id: 1, Owner: guid1,
I have a list of ordered objects stored in the database and accessed through
I have a list of categories that I publish to a UI from database.
Say I have a list of items from a database. Next to each item
Assume that I have a list of employee names from a database (thousands, potentially
I have a database containing a list of status updates and time stamp. by
have a database with a list of business leads. They are all given a

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.