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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:33:21+00:00 2026-06-11T10:33:21+00:00

I have a table in mysql: user_item_text username, item, text I want to normalize

  • 0

I have a table in mysql:

user_item_text
    username, item, text

I want to normalize the data into three tables:

users
    user_id, username

items
    item_id, item_name

text
    text_id, text_name

How can I use the existing user_item_text table to create the three tables as described? There are around 800000 records.

  • 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-11T10:33:22+00:00Added an answer on June 11, 2026 at 10:33 am

    Here is the example how to handle one table “user”:

    create table users(
       user_id int not null auto_increment, 
       username varchar(50), 
       primary key(user_id), 
       index ind_user_username(username)
    ) engine = XXX;
    
    insert into users(username) select distinct username from user_item_text
    
    alter table user_item_text add user_id integer null
    
    update user_item_text uit join users u on uit.username = u.username
    set uit.user_id = u.user_id
    
    alter table user_item_text drop column username
    

    maybe you will be need to add the following steps before runing the last update:

    1. adding index on user_item_text.username field to make update run faster
    2. unique index on users.username instead of ordinary index
    3. user_item_index.user_id should have FK

    Hope it helps.

    ps. i didn’t test query. They just showing you general approach.

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

Sidebar

Related Questions

I have this mysql orders table: (id,user_id,skin,item,date,reference,price,to_who) I need to select all users, with
I have a table generated by PHP/mysql, I want a user to click the
I have two MySQL tables something like this: tool_owners: tool_owners_id | user_id | ...
i have a problem with joining three tables in mysql. lets say we have
I have table xyz (to store the relations between user and item) | user_id
I have the following tables: users (id,name) items (id,title) users_items (user_id,item_id) users and items
I have a MYSQL-Table which stores scores. Every time a user improves a new
I am using mysql and have a table (Log_Table) storing user login dates, a
I have mysql table that has a column that stores xml as a string.
I have a table in MYSQL, with the fields, id, size and color. An

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.