如何管理数据量有限的数据库

发布于 2024-11-29 14:07:59 字数 429 浏览 0 评论 0原文

您好,我正在 Dreamweaver 中构建一个社交网络,使用 php 和 sql 作为我的服务器语言来与我的数据库进行交互。我将使用 godaddy.com 来托管我的网站,他们说他们会给我无限的 mysql 数据库,但每个数据库只能是 1GB。我希望有一个数据库专门用于存储用户信息,例如姓名和电子邮件,这些信息将包含在一张巨大的表中。然后在数据库 2 中,我想为每个用户提供自己的表,其中包含他们的所有评论。每一条评论我都会添加一行数据。很快我就会用完数据库 2 上的空间,并且必须创建一个充满评论的数据库 3。每当我用完旧数据库上的数据时,我都会继续创建新数据库的过程。问题是数据库 2 上的人们仍在发表评论,并且仍在创建更多数据供我存储。我不想限制人们可以存储的评论数量。我希望他们能够创建任意数量的评论,而无需删除旧评论。关于做什么或从这里去哪里的任何建议。我该如何解决这个问题?另外,有没有办法通过代码找出数据库还剩多少存储空间。

Hi I am building a social network in dreamweaver using php and sql as my server languages to interact with my databases. I am going to use godaddy.com to host my website and they say that they will give me unlimited mysql databases, but they can only be 1gb each. I would like to have one database designated for just user information like name and email that would be contained in one huge table. Then in database 2, I would like to give each user their own table that contains all of their comments. Every comment I would just add a row of data. Pretty soon I would run out of space on database 2 and have to create a database 3 full of comments. I would continue this process of creating a new database everytime I ran out of data on the old one. The problem is that people on database 2 are still making comments and are still creating more data for me to store. I don't want to put a limit on how many comments people can store. I want them to be able to create as many comments as they want without deleting the old comments. Any suggestions on what to do or where to go from here. How can I solve this problem? Also, is there a way to find out how much storage a database has left through code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木有鱼丸 2024-12-06 14:07:59

您可以运行以下 sql 语句来确定数据库大小(以 MB 为单位)。

SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024 
"Data Base Size in MB" FROM information_schema.TABLES 
where table_schema='apdb'
GROUP BY table_schema ;

+----------------+----------------------+
| Data Base Name | Data Base Size in MB |
+----------------+----------------------+
| apdb           |          15.02329159 |
+----------------+----------------------+
1 row in set (0.00 sec)

在上面的示例中,apdb 是数据库的名称。

You can run the following sql statement to determine the database size in MB.

SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024 
"Data Base Size in MB" FROM information_schema.TABLES 
where table_schema='apdb'
GROUP BY table_schema ;

+----------------+----------------------+
| Data Base Name | Data Base Size in MB |
+----------------+----------------------+
| apdb           |          15.02329159 |
+----------------+----------------------+
1 row in set (0.00 sec)

In the above example, apdb is the name of the database.

他是夢罘是命 2024-12-06 14:07:59

我认为 1Gb 的数据对于您的社交网络来说应该绰绰有余。如果您的网络变得非常非常大,您始终可以将应用程序转移到其他地方。

我们来计算一下:
说:从 10,000 个用户开始(与 Facebook 相比,这似乎很低,但你需要很长时间才能获得 10,000 个用户注册)。

10.000 x 500(?) bytes of information = 5Mb of data

每个用户发表 100 条评论。一条评论的平均大小为 100 字节。这也假设有一个活跃的社区。

10.000 x 100 x 100 = 100Mb of data

您仍然在 1Gb 数据库限制之内。

一旦达到 1Gb:更换托管提供商,或开始付费...

I think that 1Gb of data should be more than enough to start with for your social network. And if your network grows really really really big you can always move your application elsewhere.

Let's make the calculation:
say: 10.000 users to start with (this seems low compared to Facebook, but it will take you a long time to get 10.000 users to sign up).

10.000 x 500(?) bytes of information = 5Mb of data

each user makes 100 comments. The average size of a comment is 100 bytes. This also presumes an active community.

10.000 x 100 x 100 = 100Mb of data

You're still well within your 1Gb database limit.

As soon as you hit the 1Gb: change hosting provider, or start paying...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文