Two tables with same columns or one table with additional column?

前端 未结 3 866
清歌不尽
清歌不尽 2021-01-12 04:12

Say I have two tables (Apples and Oranges) with the same columns and just a different table name. Would there be any advantages/disadvantages to turning this into one table

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 04:49

    The advantage would be normalization. Your tables would then be in 2NF (second normal form). Your fruit type would be a foreign key to a table with those fruits like so:

    CREATE TABLE fruit_type (type varchar(15))
    
    CREATE TABLE fruits (id int, weight int, variety varchar(255), type varchar(15))
    

提交回复
热议问题