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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:32:47+00:00 2026-05-29T21:32:47+00:00

I’m new to MySQL, and just learned about the importance of data normalization. My

  • 0

I’m new to MySQL, and just learned about the importance of data normalization. My database has a simple structure:

I have 1 table called users with fields:

userName (string)
userEmail (string)
password (string)
requests (an array of dictionaries in JSON string format)
data (another array of dictionaries in JSON string format)
deviceID (string)

Right now, this is my structure. Being very new to MySQL, I’m really not seeing why my above structure is a bad idea? Why would I need to normalize this and make separate tables? That’s the first question-why? (Some have also said not to put JSON in my table. Why or why not?)

The second question is how? With the above structure, how many tables should I have, and what would be in each table?

Edit:
So maybe normalization is not absolutely necessary here, but maybe there’s a better way to implement my data field? The data field is an array of dictionaries: each dictionary is just a note item with a few keys (title, author, date, body). So what I do now is, which I think might be inefficient, every time a user composes a new note, I send that note from my app to PHP to handle. I get the JSON array of dictionaries already part of that user’s data, I convert it to a PHP array, I then add to the end of this array the new note, convert the whole thing back to JSON, and put it back in the table as an array of dictionaries. And this process is repeated every time a new note is composed. Is there a better way to do this? Maybe a user’s data should be a table, with each row being a note-but I’m not really sure how this would work?

  • 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-29T21:32:48+00:00Added an answer on May 29, 2026 at 9:32 pm

    The answer to all your questions really depends on what the JSON data is for, and whether you’ll ever need to use some property of that data to determine which rows are returned.

    If your data truly has no schema, and you’re really just using it to store data that will be used by an application that knows how to retrieve the correct row by some other criteria (such as one of the other fields) every time, there’s no reason to store it as anything other than exactly as that application expects it (in this case, JSON).

    If the JSON data DOES contain some structure that is the same for all entries, and if it’s useful to query this data directly from the database, you would want to create one or more tables (or maybe just some more fields) to hold this data.

    As a practical example of this, if the data fields contains JSON enumerating services for that user in an array, and each service has a unique id, type, and price, you might want a separate table with the following fields (using your own naming conventions):

    serviceId (integer)
    userName (string)
    serviceType (string)
    servicePrice (float)
    

    And each service for that user would get it’s own entry. You could then query for users than have a particular service, which depending on your needs, could be very useful. In addition to easy querying, indexing certain fields of the separate tables can also make for very QUICK queries.

    Update: Based on your explanation of the data stored, and the way you use it, you probably do want it normalized. Something like the following:

    # user table
    userId (integer, auto-incrementing)
    userName (string)
    userEmail (string)
    password (string)
    deviceID (string)
    
    # note table
    noteId (integer, auto-incrementing)
    userId (integer, matches user.userId)
    noteTime (datetime)
    noteData (string, possibly split into separate fields depending on content, such as subject, etC)
    
    # request table
    requestId (integer, auto-incrementing)
    userId (integer, matches user.userId)
    requestTime (datetime)
    requestData (string, again split as needed)
    

    You could then query like so:

    # Get a user
    SELECT * FROM user WHERE userId = '123';
    SELECT * FROM user WHERE userNAme = 'foo';
    
    # Get all requests for a user
    SELECT * FROM request WHERE userId = '123';
    # Get a single request
    SELECT * FROM request WHERE requestId = '325325';
    
    # Get all notes for a user
    SELECT * FROM note WHERE userId = '123';
    # Get all notes from last week
    SELECT * FROM note WHERE userId = '123' AND noteTime > CURDATE() - INTERVAL 1 WEEK;
    
    # Add a note to user 123
    INSERT INTO note (noteId, userId, noteData) VALUES (null, 123, 'This is a note');
    

    Notice how much more you can do with normalized data, and how easy it is? It’s trivial to locate, update, append, or delete any specific component.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.