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

  • SEARCH
  • Home
  • 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 6107491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:11:39+00:00 2026-05-23T14:11:39+00:00

I have a table T1 with some fields like id,key_id ,name,date etc.. id is

  • 0

I have a table T1 with some fields like

id,key_id ,name,date etc..
  • id is a auto incrementing field
  • key_id is a value obtained from id like prefix/id
  • Prefix is constant for all the rows and just id changes which is the id for the corresponding row..

It looks like something like this

$sql = " ALTER TABLE T1 AUTO_INCREMENT = 1234567890, 
           ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT ";

UPDATE T1
   SET key_id = CONCAT('12.345','/',id)

Now due to some reasons i want to create a new table T2 which would be the parent of T1 and id would be the primary key T2 and Key_id would become primary key of T1. T2 should also include other two fields like key_id and name..

ok the main reason for parent table is : i might create another table T3 which will also have id and id should have different values for T1 and T3 so i want to maintain a master table which has id as a primary key and other child tables will fetch the ids only from master table..

How can I 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-05-23T14:11:39+00:00Added an answer on May 23, 2026 at 2:11 pm

    Why would you want to store a redundant data in another column “key_id”?

    Since the prefix is constant, the id is enough. Perform the concatenation in your code.

    Also, that way, you can have id as primary key for both tables and get the key_id by prefixing the “Prefix”.

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

Sidebar

Related Questions

i have some fields in my database table,and a field with phone name ,
I have table with some fields that the value will be 1 0. This
If I have a field in a table of some date type and I
I have a table with these fields: ID (Primary key) Name Some more data
I have a table that contains some blob fields that I don't want to
I have a table in database that is having some fields one of which
I have some char() fields in a DBF table that were left encrypted by
I have a table with three fields, FirstName, LastName and Email. Here's some dummy
I'm having some trouble comparing values found in VARCHAR fields. I have a table
I have a table with three fields, one an identity field, and I need

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.