简体   繁体   中英

MySQL best way to store data

Currently doing a school project. I currently have a simple database that stores transaction information.

there is one table named "transactions" with columns: id (key, auto inc.) itemID (int, about 500 unique id's) value (int, value of transaction) dateTime (dateTime, in which entry was added)

At the moment, it is all dumped into one table, would it be better to have a table for every itemID, and store all the transactions for that particular itemID? Or is that not good practice.

In terms of scalability you are doing it right. Consider a new item enters in play, you'll have to create a new table for it. Instead the way you are working now you just have to insert new item in items table and insert transaction associated to that item in transactions table calling it with the foreign key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM