admin管理员组文章数量:1400211
Short Story: I downloaded a java/flash uploader and one of the files was a .db. After some research I found that is a database. Which prompted the question. Can I make a database (.db) file and save it in a folder in my root directory instead of having to rely on another server and sql query's? Thereby theoretically speeding up my website by accessing only local files.
The Problem: I have done lots of research and found no answer. Mainly I think because I have never dealt with this before so i don't know where to look.
The Question: Has anyone ever heard of such a thing? And if so, could you refer me to a tutorial website or provide a brief definition/ explanation/ example of how this would work and what type of munication language would be used between the files? SQL? something else? I just don't know!
Thank you all for your help.
Short Story: I downloaded a java/flash uploader and one of the files was a .db. After some research I found that is a database. Which prompted the question. Can I make a database (.db) file and save it in a folder in my root directory instead of having to rely on another server and sql query's? Thereby theoretically speeding up my website by accessing only local files.
The Problem: I have done lots of research and found no answer. Mainly I think because I have never dealt with this before so i don't know where to look.
The Question: Has anyone ever heard of such a thing? And if so, could you refer me to a tutorial website or provide a brief definition/ explanation/ example of how this would work and what type of munication language would be used between the files? SQL? something else? I just don't know!
Thank you all for your help.
Share Improve this question edited Jan 22, 2013 at 18:58 user1637281 asked Jan 22, 2013 at 18:54 krosekrose 4101 gold badge7 silver badges20 bronze badges 3- I'd suggest using sqlite. It uses a local file database and is the easiest to get up to speed with. However, be careful thinking that this will speed things up. – Mike B Commented Jan 22, 2013 at 18:56
- Say "hello" to SQLite. – salathe Commented Jan 22, 2013 at 18:57
- if your database is on the same server, basically all it does is storing your data in a subfolder of your root's directory. Did you mean you wanted to store the data at the client's side or at the location the php files are? – Sebas Commented Jan 22, 2013 at 18:57
6 Answers
Reset to default 3[The good part] Theoretically, yes, you can do it. One example would be sqlite database. This database is a single file that you store wherever you want. If you're coding in PHP, you'll need to have the corresponding extension installed with your PHP to access/query this database.
[The bad part] This only makes sense if you're dealing with small amounts of data and your queries are relatively simple. Sqlite databases are slow and support only a limited set of sql operations. They also don't have support for many standard datatypes and lack a lot of built-in functions that you may rely on. Sqlite databases are very good if you want a simple db support in a standalone app (e.g. mobile application with local data), but not very good for storing large amounts of transactional data.
[The verdict] If you're looking to speed up your web application, switching from a proper database to sqlite will probably only hinder your app, not help it.
SQLlite can provide a database that works without using a server. It provides a standard SQL interface like you would use with a reguar sql server (MySQL etc). Its probably not going to be faster as it will rely on a lot more disk I/O than a standard database server.
What I really think you're asking about is a flat file database.
http://www.databasedev.co.uk/flatfile-vs-rdbms.html
Almost any database solution that you can name relies on files as the storage mechanism, so just having data stored in a file does not convey any inherent performance bonus to your application. Server-less databases like SQLite do exist, but the reasons for selecting them rarely have to do with performance, but rather portability.
You can run local instances of MySQL or other databases to eliminate the over-the-wire transmission cost. If properly configured they would outperform something like SQLite in most every case, as MySQL relies on in-memory storage in addition to on-disk storage.
Since it sounds like you are pretty new to this sort of stuff, I would give a word of caution about trying to worry about these sort of premature performance optimizations. Perhaps start with a traditional relational database (like MySQL) on the same server as your web server.
Once you get to the point where you have enough traffic to where you need to separate the database onto a different server (to allocate more resources to either the database or the web application, or to be able to allow for multiple load-balanced web application servers talking to a single backend database) then you can start worrying more about these sorts of performance tweaks.
SQlite is serverless. It's well documented. PHP has an extension to work with it too. But if you really want to speed things up you should look at memcached, redis, MongoDB and such.
It seems like what you are talking about is simply running a server on the same puter where the client is. That of course is possible.
The advantage is that it would still use SQL, and even network protocols, but be self contained on the same puter. Later switching to a production environment would be a minimal configuration change.
It would not actually use the network, but would instead would make all the network calls in memory. This would run very fast, and is a good development environment.
本文标签: phpIs it possible to have an offline databaseStack Overflow
版权声明:本文标题:php - Is it possible to have an offline database - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744249516a2597182.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论