Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How create table in mySQL?
Started by anaqim Jan 11 2019 01:03 PM

4 replies to this topic

Best Answer Benzeliden , 14 January 2019 - 11:13 AM

Hello

Having 1 table per user sounds strange, but if you really wish to do this:

1) create separate database on server

2) use core.mysql.query( db_name, query_str ), specify database and write your script ("Create table something .... ")

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 743 posts
  • Corona SDK

hi,

 

so i suddenly find myself in need of being able to create new server side mysql tables in code, similar to how its done locally in sqlite3.

 

when user register in my app, a separate user table needs to be created.

 

does anyone know of a way to do that in coronium?

 

 

 



[TOPIC: post.html]
#2

Benzeliden

[GLOBAL: userInfoPane.html]
Benzeliden
  • Enthusiast

  • 79 posts
  • Corona SDK

  Best Answer

Hello

Having 1 table per user sounds strange, but if you really wish to do this:

1) create separate database on server

2) use core.mysql.query( db_name, query_str ), specify database and write your script ("Create table something .... ")


  • anaqim likes this

[TOPIC: post.html]
#3

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 743 posts
  • Corona SDK

Hi,

 

Thank you for your reply.

Now that i see it I should have realized :)

 

A table per user has advantages and there is no limit to the number of tables mySQL supports.

It can help improve security by not making other users tables exposed to a malicious user.

I'd save some space by not needing a user id column (a CHAR 36 type)

I suspect performance may improve a little too, and certainly not be worse.

One possible downside is i suspect RAM need will increase a little, but need to test that one to be sure.

 

Thanks again!



[TOPIC: post.html]
#4

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 743 posts
  • Corona SDK

I'll also be looking into mysql table partitioning as an alternative, so nothing is set in stone yet.



[TOPIC: post.html]
#5

Develephant

[GLOBAL: userInfoPane.html]
Develephant
  • Corona Geek

  • 1,449 posts
  • Corona SDK

Hi,

 

Late reply, but I would look into table joins, etc. as an alternative to separate tables per user. Each table will consume more memory, where as an ID data field will take a negligible amount.

 

If your user base becomes very large you will be facing an issue in my opinion.

 

-dev




[topic_controls]
[/topic_controls]