2

Sorry if my question is no appropriate for DA.

I have a State-city table with unique id for every town/city name. (id: town --> city --> State)

I also have a list of Store names associated to each town. (less than 20 Stores for each town). Call this table Stores

In my app, I want users to register. I will store them in another table call Users.

In my app I have a button allow users to take queue number for their selected town.

Now I don't know how to put these tables together for queue such that:

  • One can save (for 1 month) each day's queue table of each towns with all details.
  • One can add or remove a customer to each queue when Store is online,
  • The size of the database is important for me.

Do you recommend to take town of users when they register? I have no idea whether this is a useful information or not.

My idea is that for each day and each town I should create a table (probably using join but how to save this table?) with unique name e.g. id-of-town + date (so how can one add date to table name?) then add customers id, town id and store id to this table. What is your solution?

Edit: I expect the final database size to be less or around 1 GB. Also, my estimate of the number of stores is 1000 (within 1 year from launch) and ideally it would be up to 1.5 million stores. (after years). From the comments it looks like I need to create a table for each store.

7
  • 1
    @ITThugNinja: Done! my answer sets table name as 2022-12-18 . Is that Ok?
    – C.F.G
    Commented Dec 18, 2022 at 7:04
  • What controls "when Store is online"?
    – Rick James
    Commented Dec 18, 2022 at 16:59
  • "size of the database" -- Are you expecting billions of stores or users or queue entries? A million of anything is "small" in database usage.
    – Rick James
    Commented Dec 18, 2022 at 17:00
  • 1
    "each day and each town I should create a table" -- NO! Have a single table with columns for day and town.
    – Rick James
    Commented Dec 18, 2022 at 17:01
  • @RickJames: I mean size less than or around 1GB if that is possible. :)
    – C.F.G
    Commented Dec 18, 2022 at 18:08

1 Answer 1

1

Partial Answer: I find a query for creating a table with date as its name:

set @dynamicQuery = CONCAT('create table `', curdate(), '` as select ColName from TableName');
prepare st from @dynamicQuery;
execute st;
1
  • 1
    Please do not encourage a new table each day. It is really bad practice. (This is a common question; the answer is always "NO".)
    – Rick James
    Commented Dec 18, 2022 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.