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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:26:12+00:00 2026-06-15T18:26:12+00:00

Please consider the following example. Let’s say we are building a DB for an

  • 0

Please consider the following example. Let’s say we are building a DB for an online book store. We have a Book table contains n records and a Type table contains m records. n is a very large number. m is small.

--------
Book
---------
BookId
BookName
BookType
---------

-------
Type
--------
TypeId
TypeName
---------

The traditional way to join these 2 table would be creating a 3rd table called BookType

---------- 
BookType
---------- 
BookTypeId 
BookId 
TypeId
----------

If we want to retrieve a book record with type, we can do:

select B.*, T.Name from Book B
inner join BookType BT on B.BookId = BT.BookId
inner join Type T on BT.TypeId = T.TypeId

Since the Book table is very large, so the BookType table is even larger. Since DB index is using B-Tree-like algorithms, the time cost will be: 2log(n) + Cm. Right? (With Book table and BookType table indexed)

However, if we can store the TypeId as a JSON array and use it for join, then we can get the data in one trip. The time will be log(n) + Cm which is at least twice as fast. The syntax can be something like:

select B.*, T.Name from Book B
inner join Type T on ParseJsonAsIntArray(BookType) = T.TypeId

I couldn’t find a MySQL function like ParseJsonAsIntArray(). Why aren’t they doing this? Apology if I am missing the obvious.

  • 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-15T18:26:13+00:00Added an answer on June 15, 2026 at 6:26 pm

    No, there’s no builtin function for parsing JSON in MySQL. The closest thing is ExtractValue() for XML data. This function uses an Xpath expression to pick out an element of an XML document. But regardless, there is no support in MySQL for indexing the elements within a semi-structured blob like XML or JSON. It’s bound to be an inefficient query.

    But first things first. You’re trying to use denormalization to solve a problem which is actually an advantage of relational databases. The BookType table will be long, but the rows are individually pretty small. So it won’t be as bad as you think.

    It’s a huge advantage for BookType to support indexed searches either by Book or by Type. When you denormalize, you basically make one of those lookups efficient, but you sacrifice the other lookup.

    Also see my answer to Is storing a comma separated list in a database column really that bad?

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

Sidebar

Related Questions

Please consider the following example code (from the lm doc): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt
Please consider the following three .NET types: I have an interface, an abstract class,
Please consider the following SQL Server table and stored procedure. create table customers(cusnum int,
Consider the following table: People FirstName nvarchar(50) LastName nvarchar(50) Let's assume for the moment
Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Please consider the following example struct Foo { int bar; Foo(int i):bar(i){cout << real
Let's consider the following table models for sqlalchemy in python. class Worker(Base): id Column(Integer,
Please consider following example: The source image consists of 6 areas that need to
Please consider the following example def foo(a: Int, b: Int = 100) = a
Please consider the following simplified MySQL table: id | docID | docTypeID | makeID

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.