简体   繁体   English

将数据存储在数据库或文件中?

[英]Store data in database or files?

I have some doubts, im developing a web application in GWT using MVP model.我有一些疑问,我正在使用 MVP model 在 GWT 中开发 web 应用程序。 Let assume that im implementing a forum,so users could post comments, im wondering how to keep this data?假设我正在实施一个论坛,因此用户可以发表评论,我想知道如何保留这些数据?

For example,a post could have 2000.. 3000 chars, im thinking about files.. every category has it own posts, so i could store category per file.. Or other idea is to hash the data..例如,一个帖子可能有 2000.. 3000 个字符,我在考虑文件.. 每个类别都有自己的帖子,所以我可以为每个文件存储类别.. 或者其他想法是 hash 数据..

I would be glad to know more opinions and approaches..我很高兴知道更多的意见和方法..

Thanks guys.多谢你们。

Edit.编辑。

I see from the comments that database is the right decision, but should i insert the posts direct or do rework it somehow and then insert?我从评论中看到数据库是正确的决定,但是我应该直接插入帖子还是以某种方式对其进行返工然后插入?

Database.数据库。 Without options.没有选项。

Moreover, database provides a much easier way to search, index and extend the data without any limits.此外,数据库提供了一种更简单的方法来搜索、索引和扩展数据,没有任何限制。 For example if you decide that each post can have it's smiley face - it is a question of 1 extra column in database.例如,如果您决定每个帖子都可以有它的笑脸 - 这是数据库中 1 个额外列的问题。 However with files it will become a real pain to convert all files to new format.但是,对于文件,将所有文件转换为新格式将变得非常痛苦。

Also, what about relative data?另外,相对数据呢? As @The Elite Gentlemen mentioned, storing relative data in files is also painful.正如@The Elite Gentlemen 提到的,将相关数据存储在文件中也很痛苦。 Yes, you will index the posts in categories by directory names, but how will you save the Author of the post?是的,您将按目录名称对帖子进行分类索引,但是您将如何保存帖子的作者? Link to his profile?链接到他的个人资料? Number of posts the author has or his avatar?作者拥有的帖子数量或他的头像?

In your place I would not to place the data in files.在您的位置,我不会将数据放在文件中。 For a simple reason - you once again write another database.出于一个简单的原因 - 您再次编写另一个数据库。 What's more if you use files, you will need time to keep this system.更重要的是,如果你使用文件,你将需要时间来保持这个系统。 Databases is checked and tested, so you have need less time for maintenance.数据库经过检查和测试,因此您需要更少的维护时间。 In the case of a forum you consider multi-level the cache.在论坛的情况下,您考虑多级缓存。

First level in database - ex.数据库中的第一级 - 例如。 using for some table memory (but with risk), procedural language in database, and standard tools as index etc.用于某些表 memory(但有风险),数据库中的过程语言以及标准工具作为索引等。

Second level in http - if you using gwt, you may cache threads from forum. http 中的第二级 - 如果您使用 gwt,您可以缓存来自论坛的帖子。 For this you don't need gwt mechanism, only need special server configuration.为此您不需要gwt机制,只需要特殊的服务器配置。

Third level - this is gwt/javascripts - in gwt browse client level, you may keep newly created forum threads.第三级 - 这是 gwt/javascripts - 在 gwt 浏览客户端级别,您可以保留新创建的论坛线程。

just enough to quickly...刚刚够快...

Saving data in files will cause run-time error because of CPU overloading.USing datbase is the only way actually由于 CPU 过载,将数据保存在文件中会导致运行时错误。使用数据库实际上是唯一的方法

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

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