English 中文(简体)
MySQL 数据库创建/设计 - 不知道在数据像这样时如何组织数据
原标题:mySQL Database Creation/Design - Not Sure How to Organize Data When it s Like This

通常我可以简单地用一个问题搜索谷歌 找到答案, 但我完全不知道关于我的SQL数据库, 所以我从头开始。

我的问题是如何格式化/组织我拥有的数据,当它不象电子表格那样简单时。我认为它的格式化方式将导致数十万个单项表格,这似乎不正确。这是我掌握的数据,也许有人可以指示我如何将它组织成一个 MySQL 数据库,以便它不仅有组织,而且有可能根据每个数据“点”生成报告:

我从一个网站的具体 URL 中提取了产品评论。 举例来说,亚马逊就是例子。 我需要按照亚马逊的顺序来保存这些评论。

简而言之,我会说,我从亚马逊的三个不同的 URL中提取了产品评论:

http://amazon.com/product/12345-x
http://amazon.com/product/12345-y
http://amazon.com/product/12345-z

所以从这三个URL中,每个URL上都有3个不同的人 留下一个审查。 所以我怎么认为它会存储在一个数据库里(这不可能是正确的) 是这样的:

          TABLE FOR PRODUCT 12345-X
REVIEW NUMBER    REVIEWER     THEIR REVIEW     NAME OF PRODUCT   PRODUCT PRICE   REVIEW LEFT ON
1                username     great product    some product      $399            monday
2                username     crappy product                                     wednesday
3                username     okay product                                       wednesday


          TABLE FOR PRODUCT 12345-Y
REVIEW NUMBER    REVIEWER     THEIR REVIEW     NAME OF PRODUCT   PRODUCT PRICE   REVIEW LEFT ON ON
1                username     great product    some product      $399            monday
2                username     crappy product                                     wednesday
3                username     okay product                                       wednesday


          TABLE FOR PRODUCT 12345-Z
REVIEW NUMBER    REVIEWER     THEIR REVIEW     NAME OF PRODUCT   PRODUCT PRICE   REVIEW LEFT ON ON
1                username     great product    some product      $399            monday
2                username     crappy product                                     wednesday
3                username     okay product                                       wednesday

既然我掌握了数千种产品的数据, 这显然会导致上千张表格, 这不可能是组织事物的正确/最佳方法。

更糟糕/更复杂的是,有时同一产品的价格会改变,因此它以两种不同价格(实际上,许多不同价格)出售。 我也希望能够获得以不止一种价格出售的每件“相同产品”的“平均价格 ”, 并显示每日评论最常留下的每件产品全印章。

所以,你可以看到,我不仅需要能够生成关于每个产品的报告,而且需要能够生成关于每个产品中每一“栏”的数据...这将导致更多的表格。

有人能指示我正确的方向吗? 如何在数据库中组织这些数据?

我道歉,如果我要求的太荒谬了无法回答, 我只是不知道如何在数据库里组织这个活动, 甚至不知道从哪里开始(输入谷歌的词组) 。

最佳回答

if I got you right you want to store threr diffent things: 1 Products 2 Reviews for each product 3 Data of the person how rowted the review like name ...

所以,你需要的就是这些桌子。

TABLE FOR PRODUCT
ProductID  P_Price   P_Name
1          399       Name X
2          299       Name y
3          199       Name z

TABLE FOR Review
ReviewID  ProductID  Review            R_Date           UserID
1         2          Review for y      1/1/2012         1
2         1          Review for x      1/1/2010         2
3         3          Review for z      4/4/2009         2


Table for User
UserID    U_Name
1         Peter
2         Simon

So now you can e.g. see that Simon wrote a Rewiev for X and Z. And that each product has one review. In general, you do someting realy worng if you have to create a table during runtime. The Tabes are always a fix struktur that is only changed if you decide make some big changes, like adding a Password to each user. When u add a new information like a new review, u always only add one ore more entrys.

我想你应该得到一本书 或一个关于MySQL(或你曾经使用过什么)的长篇教程。 在那里,幻想是有关数据组织的大篇章。

我希望我能帮你

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签