如何在1and1服务器上设置数据库表? [英] How to setup a database table on 1and1 server?

查看:105
本文介绍了如何在1and1服务器上设置数据库表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的托管提供商是1and1,我需要知道如何在创建新数据库后为数据库创建一个新表。对于这个数据库,我将称之为Interactive Map(或者如果我不允许空格或大写,我将简单地删除/替换,例如;'interactivemap'),然后创建一个名为Btn Data的表关于资本和空间)。



                  对象               ;                  Shared On                           / strong>     

                                        Facebook >
> 推荐

           ; 澳大利亚                  1242       420       4281& kbd> 643     1072           3452       



上表包含以下内容:




  • $ b
  • / li>
  • Twitter

  • Google +


  • / would

    • 喜欢

    • 过了

    • 计划去

    • 推荐




  • 首先,我不知道数据库表可以看起来像这样,我不知道什么是数据库格式应该是什么样的,我只能假定判断通过一个数据库我加载了一段时间,看着表中的Excell。它是要记录关于我设置的页面的信息,它有多个选项卡,不仅将澳大利亚在桌子上。



    我想知道如何设置一个MySql数据库表类似的一个我已经做了一个标记上面和如何从我的页面创建按钮,如果对象不存在,额外的行,或手动添加对象到我的表。



    我唯一可以真正地说,我明白是如何创建一个新的数据库,并输入PHPMyAdmin页面进入该数据库,没有帮助,我真的会斗争。 p>

    感谢您随时用于跟进我的问题以及任何帮助和/或建议。



    最好的问候,



    Tim



    编辑1:

      SQL查询:

    CREATE TABLE`objects`(

    `id` INT UNSIGNED NOT NULL,
    `name` VARCHAR(255)UNSIGNED NOT NULL,
    UNIQUE(
    `id`

    )TYPE = MYISAM


    解决方案

    你表肯定不能像这样。好吧,它可能是,但它将很难以各种方式管理它,所以放弃一个表的想法。



    您将需要至少3个表,与彼此的关系。但是,您应该熟悉MySQL原理和关系,以便继续管理数据库,而不是只创建一次而永远。



    而不是只有简单的字符串



    示例:
    数据库 interactivemap



    对象

      id |名称| 

    1 |澳大利亚|
    2 | Aughanistan |

    shared_on

      id | object_id | shared_on |计数| 

    1 | 1 | 1 | 100 |
    2 | 1 | 2 | 500 |
    3 | 2 | 1 | 200 |
    3 | 2 | 3 | 40 |

    social_types

      id |社会| 

    1 | Facebook |
    2 | Twitter |
    3 | GooglePlus |

    action_types

      id | action_type | 

    1 |喜欢|
    2 |是|
    3 | Plan_To |
    4 |推荐|

    actions

      id | object_id | social_id |什么|计数| 

    1 | 1 | 1 | 1 | 500 |
    2 | 1 | 1 | 2 | 300 |
    3 | 1 | 1 | 3 | 100 |

    这意味着每个对象都有自己的ID。
    每个社交网络都有自己的ID
    每个Action都有自己的ID



    因此在表shared_on中,第一行你有object_id = 1 (关于表Objects.ID = 1,这是澳大利亚),这是shared_on(在Social.ID = 1相关)是Facebook,100次(计数)
    第二行,相同的对象,但共享2 (Twitter)500次。
    第三行,对象2(Aughanistan),共享在1(Facebook),200次。



    在表操作中,您有关系:
    Object_id to Objects.ID
    Social_id to Social_types.ID
    what to action_type.ID



    所以,在第一行你有:
    Object.ID = 1(Australia),on Social.ID = 1(Facebook),有What = 1(Likes) - > 500(count)



    可以在相同的关系上插入行。使用选项卡插入phpMyAdmin



    要使用连接值的查询,可以使用ie:

      SELECT tb1.name,tb2.social,tb3.action_type,tb4.count 
    FROM`objects` AS tb1
    INNER JOIN`actions` AS tb4
    ON tb1.id = tb4.object_id
    INNER JOIN`social_types` AS tb2
    ON tb4.social_id = tb2.id
    INNER JOIN`actions_types` AS tb3
    ON tb4.what = tb3.id
    WHERE tb3.action_type ='Been';

    将输出:

      name |社会| action_type |计数| 

    澳大利亚| Facebook |是| 300 |

    如果对象不存在,则不需要列或表。所有的逻辑应该在PHP中定义,如果对象在对象中不可见,则不允许INSERTs


    My hosting provider is with 1and1 and I need to know how to create a new table for a database after creating a new database. For this database, I will be calling it 'Interactive Map' (or if I am not allowed spaces or capitals, I will simply remove/replace, eg; 'interactivemap') and then create a table called 'Btn Data' (same applies regarding capitals and spaces).

                  Object                               Shared On                     Like/Been to/Plan to/Recommend     
                                           FacebookTwitterGoogle+LikeBeenPlan ToRecommend
                 Australia                1242       420     4281   435  643   1072        3452      

    The table above consists of the following;

    • Object What is being shared/liked/whatnot
    • Shared on
      • Facebook
      • Twitter
      • Google+
    • I do/have/would
      • Like
      • Been
      • Plan To Go
      • Recommend

    Firstly, I do not know if a database table can look like this, I have no idea on what a database format should be like, I can only presume judging by a database I loaded a while ago, looking at the table in Excell. It is to record information about a page I am setting up, it has multiple tabs and will not only have Australia on the table.

    I would like to know how to set up a MySql database table alike the one I have made a mark up for above and how to either from my page creating buttons, make an additional line if the object does not exist, or to manually add the objects into my table.

    The only thing I can truly say I understand is how to create a new database and enter the PHPMyAdmin page to enter that database and without help, I am really going to struggle.

    Thank you for any time spent in following up my question and for any help and/or advice.

    Best Regards,

    Tim

    Edit 1:

    SQL query:
    
    CREATE TABLE  `objects` (
    
    `id` INT UNSIGNED NOT NULL ,
    `name` VARCHAR( 255 ) UNSIGNED NOT NULL ,
    UNIQUE (
    `id`
    )
    ) TYPE = MYISAM
    

    解决方案

    You table definately cannot look like this. OK, it might be, but it will be very hard to manage it in every way, so drop the idea of one table.

    You will need at least 3 tables, with relations to each other. However, you should have got familiar with MySQL principles and relation in order to continue managing your database instead of creating it only once and forever.

    Instead of only simple strings, you need indexes, on which will relate the things.

    Example: Database interactivemap

    Table objects

    id  |   name        |
    
    1   |   Australia   |
    2   |   Aughanistan |
    

    Table shared_on

    id  |   object_id   |   shared_on   |   count   |
    
    1   |   1           |   1           |   100     |
    2   |   1           |   2           |   500     |
    3   |   2           |   1           |   200     |
    3   |   2           |   3           |   40      |
    

    Table social_types

    id  |   social      |
    
    1   |   Facebook    |
    2   |   Twitter     |
    3   |   GooglePlus  |
    

    Table action_types

    id  |   action_type |
    
    1   |   Like        |
    2   |   Been        |
    3   |   Plan_To     |
    4   |   Recommended |
    

    Table actions

    id  |   object_id   |   social_id   |   what    |   count   |
    
    1   |   1           |   1           |   1       |   500     |
    2   |   1           |   1           |   2       |   300     |
    3   |   1           |   1           |   3       |   100     |
    

    It means every object has its own ID. Every Social network has its own ID Every Action has its own ID

    So in table shared_on, on the first row you have object_id = 1 (related to table Objects.ID = 1 which is Australia), which is shared_on (related on Social.ID = 1) which is Facebook, 100 times (count) Second row, the same object, but shared on 2 (Twitter) 500 times. Third row, Object 2 (Aughanistan), shared on 1 (Facebook), 200 times.

    In table actions you have relations: Object_id to Objects.ID Social_id to Social_types.ID what to action_type.ID

    So, on the first row you have: Object.ID = 1 (Australia), on Social.ID = 1 (Facebook), has What = 1 (Likes) -> 500 (count)

    Basically, you can insert rows, on the same relation. Use the tab Insert in phpMyAdmin

    To have a query which joins the values, you can use i.e.:

      SELECT tb1.name, tb2.social, tb3.action_type, tb4.count
    FROM `objects` AS tb1 
    INNER JOIN `actions` AS tb4 
    ON tb1.id = tb4.object_id
    INNER JOIN `social_types` AS tb2
    ON tb4.social_id = tb2.id
    INNER JOIN `actions_types` AS tb3
    ON tb4.what = tb3.id
    WHERE tb3.action_type = 'Been';
    

    which will output:

    name        |   social      |   action_type |   count   |
    
    Australia   |   Facebook    |   Been        |   300 |
    

    No columns or tables are needed if object does not exist. All the logic should be defined in PHP and don't let INSERTs if the object is not presentable in objects table

    这篇关于如何在1and1服务器上设置数据库表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆