MySQL表的简单分解
我不是数据库领域的专家,尤其是MySQL领域的专家——我在学习,所以我对术语有点困惑 我有一个内部数据库组织,它得到了一份新工作。 一个巨大的表产品,类别和不同的属性堆。 此表中的属性重复多次(即,非唯一)。 每个位置-表格的一行 有必要将其分成几个小部分(进行分解),以便在具有唯一内容的单独表中选择标题、类别和属性 最有可能的是,它应该清楚我想要什么,但仍然给出了结构 1。现有数据库的结构 主表MySQL表的简单分解,mysql,decomposition,Mysql,Decomposition,我不是数据库领域的专家,尤其是MySQL领域的专家——我在学习,所以我对术语有点困惑 我有一个内部数据库组织,它得到了一份新工作。 一个巨大的表产品,类别和不同的属性堆。 此表中的属性重复多次(即,非唯一)。 每个位置-表格的一行 有必要将其分成几个小部分(进行分解),以便在具有唯一内容的单独表中选择标题、类别和属性 最有可能的是,它应该清楚我想要什么,但仍然给出了结构 1。现有数据库的结构 主表 id int (10) unsigned NOT NULL AUTO_INCREMENT - (t
id int (10) unsigned NOT NULL AUTO_INCREMENT - (the unique ID of the position of the goods)
prod_name varchar (255) NOT NULL - the name of the position (non-unique)
prod_cat varchar (64) NOT NULL - the name of the category (non-unique)
prod_prop01 varchar (64) NOT NULL - name svoystva1 (non-unique)
prod_prop02 varchar (64) NOT NULL - name svoystva2 (non-unique)
id int (10) unsigned NOT NULL AUTO_INCREMENT - (the unique ID of the position of the goods)
prod_name int (10) - to the entry ID (unique)
prod_cat int (10) - PH category (unique)
prod_prop01 int (10) - Foreign svoystva1 (unique)
prod_prop02 int (10) - Foreign svoystva2 (unique)
2。我希望得到这样的结构
主表
id int (10) unsigned NOT NULL AUTO_INCREMENT - (the unique ID of the position of the goods)
prod_name varchar (255) NOT NULL - the name of the position (non-unique)
prod_cat varchar (64) NOT NULL - the name of the category (non-unique)
prod_prop01 varchar (64) NOT NULL - name svoystva1 (non-unique)
prod_prop02 varchar (64) NOT NULL - name svoystva2 (non-unique)
id int (10) unsigned NOT NULL AUTO_INCREMENT - (the unique ID of the position of the goods)
prod_name int (10) - to the entry ID (unique)
prod_cat int (10) - PH category (unique)
prod_prop01 int (10) - Foreign svoystva1 (unique)
prod_prop02 int (10) - Foreign svoystva2 (unique)
职位名称表
id int (10) unsigned NOT NULL AUTO_INCREMENT - (unique ID names)
name varchar (64) NOT NULL - the name of the position (unikalnoe!)
表也一样-类别Prop01和Prop02。
这只能在MySQL的帮助下完成吗?
如果没有,那么告诉我解决这个问题的一般算法。
感谢您关注这项简单的任务。如果我理解正确,您需要执行以下操作:
INSERT SELECT DISTINCT也将派上用场。在MySQL文档中查找INSERT并找到与SELECT一起使用的变体。选择DISTINCT查找唯一记录。不要删除这些列,而是使它们链接到新的数据库表。