简体   繁体   中英

INVENTORY SYSTEM! Problems with tables

(当前数据库架构的屏幕截图)[请单击]

Hello guys! The picture attached is a screenshot of our current database design in MySql Workbench. We presented it into our professor and said that our schema was wrong particularly in the Product Categories (Cakes, Cupcakes, Pies), because it should've been inside the products table.

Can you help me improving this kind of schema by adding more tables and not just 5?

Since your other tables (cakes, pies, etc.) don't add any new attributes, it's hard to envision why you need them. Wouldn't a row in cakes just be an exact duplicate of the row it references in products ?

If you need to distinguish between product category, just add a column to your products table for the category.

PS Please don't get into the habit of prefixing all your table names with "tbl." This is redundant, because it's obviously a table if you can query from it. Just skip the "tbl." Likewise don't encode the data type in your column names. What if you need to change the data type someday? It would break all your queries.

PPS Don't use FLOAT for currency—use NUMERIC .
See https://twitter.com/billkarwin/status/347561901460447232

Also read What Every Computer Scientist Should Know About Floating-Point Arithmetic .

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