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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:12:18+00:00 2026-06-17T17:12:18+00:00

I have a database with two tables that currently has 3 columns each. Table_A

  • 0

I have a database with two tables that currently has 3 columns each.

Table_A: id, uid, url

Table_B: id, uid, url

The id is the primary key that auto increments by 1 on each new row inserted.

The question I have is do I need a primary key still. I will never query the db for id.
The uid column is simply to separate per user so it’s not unique per row.
Table_A and Table_B will be compared by uid often.
I have uid, url indexed and I expect the table to grow possible in the billions and I don’t want to waste space on a id.

  • 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-17T17:12:20+00:00Added an answer on June 17, 2026 at 5:12 pm

    If you use InnoDB, and don’t declare a primary key column, InnoDB will create one for you, using a 6-byte integer. So the only thing you’re gaining by dropping the id column is possibly trading an 8-byte BIGINT for the 6-byte implicit PK column.

    The reason is that InnoDB tables are stored as a B-tree, a clustered index based on the primary key. Every table must have a column it uses to organize this B-tree, even if it’s an implicitly created column.

    You can also declare a table with a compound primary key:

    CREATE TABLE Table_A (
      uid INT NOT NULL,
      url VARCHAR(100) NOT NULL,
      PRIMARY KEY (uid, url)
    );
    

    In this case, the requirement for a primary key is satisfied, and InnoDB creates no implicit column.


    Re your comments:

    I try not to use MyISAM. MyISAM is more susceptible to data corruption than InnoDB, and usually InnoDB performs better because it caches both data and indexes. It’s true there are some cases where MyISAM can use less disk space, but disk space is cheap and I’d much rather get the benefits of InnoDB.

    Regarding indexes, if you have PRIMARY KEY(uid, url) then you automatically have a compound index over those two columns. No need to create an extra index on uid.

    But if you have queries that search for url alone, without looking for a specific uid, then you need a separate index on url.

    I talk more about index design in my presentation: How to Design Indexes, Really

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

Sidebar

Related Questions

I have a database two tables and a linking table that I need a
Basically I have a database with two tables, that is, Updates table and Images
I have a database that which contains two tables, links and tour. Tour is
I have two tables in my database schema that represent an entity having a
I have two tables in my database that look like that: Customer: C_ID city
I have a very simple database table that joins two other tables in a
I have two separate sets of tables in the same database that model the
Hello there I have a database that has 2 tables in it, one is
I have two tables (A and G) in an Oracle database that can be
OK I have a table that has two columns, userID and courseID. It is

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.