简体   繁体   English

设置我的数据库表

[英]Setting up my Database Table

All feeds will be updated in my administration panel of which I hope to have quite a large archive in the prosperous future, however on my main page only the five most recent are to be shown per category chosen via the tab switcher.所有提要将在我的管理面板中更新,我希望在繁荣的未来拥有相当大的存档,但是在我的主页上,每个通过选项卡切换器选择的类别只显示最近的五个。 Here is a screenshot of the main page for illustration.这是用于说明的主页的屏幕截图

Now presumably using a database is the correct course of action.现在大概使用数据库是正确的做法。 This page on runescape.com is my best reference for how I aspire to have my site look in the future. runescape.com 上的这个页面是我希望将来如何让我的网站看起来的最佳参考。

I've established a database, however I now need to set up a table to hold the following information:我已经建立了一个数据库,但是我现在需要建立一个表来保存以下信息:

  1. Title标题
  2. Date日期
    • Day
    • Month
    • Year
  3. Cover Image封面图片
  4. Short Description简短的介绍
  5. View More link查看更多链接

Looking into doing this, I see syntax such as VARCHAR but I do not know how to correctly use them.考虑这样做,我看到了诸如VARCHAR语法,但我不知道如何正确使用它们。 This is my attempt to create the table:这是我创建表的尝试:

CREATE TABLE Feed (
    Title VARCHAR(???),
    day CHAR(2),
    month CHAR(2),
    year CHAR(4),
    short description VARCHAR(???),
    see more VARCHAR(???);

I get the syntax error below but I don't understand how to fix it;我收到下面的语法错误,但我不明白如何修复它; how do I choose the width of the VARCHAR column?如何选择VARCHAR列的宽度?

ERROR 1064 (42000): You have an error in your SQL syntax; ERROR 1064 (42000):您的 SQL 语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '???), day CHAR(2), month CHAR(2), year CHAR(4), short description VARCHAR(???), ' at line 1检查与您的 MySQL 服务器版本相对应的手册,以获取在 '???)、日 CHAR(2)、月 CHAR(2)、年 CHAR(4)、简短描述 VARCHAR(???) 附近使用的正确语法, ' 在第 1 行

What you are asking about is the data types that MySQL supports.您要问的是 MySQL 支持的数据类型。 What you will need to figure out is what is the best data type for each of your desired fields (which will become columns in the database table).您需要弄清楚每个所需字段(将成为数据库表中的列)的最佳数据类型是什么。 Here is a link to the MySQL documentation about data types: http://dev.mysql.com/doc/refman/5.0/en/data-types.html这是有关数据类型的 MySQL 文档的链接: http : //dev.mysql.com/doc/refman/5.0/en/data-types.html

Here is another good source on database normalization, which is important when you're designing any database: http://www.studytonight.com/dbms/database-normalization.php这是数据库规范化的另一个很好的来源,这在您设计任何数据库时都很重要: http : //www.studytonight.com/dbms/database-normalization.php

The trickiest one is going to be the image.最棘手的将是图像。 Although you could technically store the image in the database, it isn't recommended.尽管技术上可以将图像存储在数据库中,但不建议这样做。 Instead, what I would do is store the path to the image on the file system.相反,我要做的是将图像的路径存储在文件系统上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM