When to use files to store data rather than a database? - ruby-on-rails-3

I am thinking when to use files instead of a database table for storage of data?
Example if you just have some backend settings, you could store them in a file..
Or is it best practise to have everthing in a DB?
I am using Rails as framework for my web applications.

If you are just looking to set some settings to be used in an app, why not just create a config or initializer file?

Related

How can I store large binary objects in azure sql db?

I have a local ASP.NET web site (database contains some pictures as binary objects) that I want deploy to Azure web services. How can I store pictures in Azure SQL DB?
I'm trying this query, but..
Is there another way to keep large binary object in Azure DB? Thanks for any replies!
you can use other way to do that. You can use SqlStream class written in C# code.
because bulk insert is not permit in sql database.
check these link, that have a way to do that:
https://azure.microsoft.com/en-us/blog/streaming-blobs-to-and-from-sql-azure/

Using Flat Files for authorization instead of using database tables

I have an mvc4 application which use sql database as back end. I am using asp.net identity for authentication and authorization. I have a need to move some of the user settings/configuration from database to flat files. The current system stores user configuration in tables which we do not want to share with customers. This information must be maintained in flat files and be written in the directory where the code is executed. I need to come up with a .NET MVC prototype which can store/retrieve user configuration from a flat file.
Basically, I need that instead of using the database for authorization for storing and checking what users have access to what features etc. I can store in a flat file and load that into memory and use that to check for authorization for granting users access to different features.
Also when the admin changes users authorization stuff it should update the file.
Can anyone please suggest me some scenario.
You can look into using files as Resources in your code. Resources can be accessed, read and updated at run time. And these will not be exposed to the users.
Some links which might help.
https://stackoverflow.com/a/1533984/689625
https://stackoverflow.com/a/20908560/689625
https://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.90%29.aspx

What is the best place to store user configurations settings

I am trying to develop a modular web aap using asp.net mvc 4. My question is that what is the best place to store the user settings, configuration and user access. Whether it is good to store it in db or good to store it in xml file.
I would prefer to go with XML.
Advantages in XML file :
No need to access in your database server.(Which is contains valuable data)
Anybody can understand and change the settings. (No need to know about SQL)
Platform independent.
Disadvanges in XML file :
Need to backup the file. To overcome this problem, Have to maintain the changes by history (It is a best way to revert it back).

ASP.NET MVC + EF: storing configurations and settings that dont fit in database

What is the best way to store (and later modify from the application itself) some variables that dont fit in the database?
For example: "string systemEmail" that is used to send emails when there are problems in the system.
Certainly using a table in the database for that is not ok, because I would have to use 1 registry in that table (eg. SystemConfigurations.First().SystemEmail)
Ended up using ConfigurationManager.AppSettings["settingName"] = settingValue
These are stored in web.config

What's the easiest/cheapest way to create a cloud-based SQL database?

I have a website that I've built (hosted on Amazon S3) and it works great. The only problem is that all of the data is static. I'd like to create a SQL database in the cloud that would allow me to store basic text data from users after they submit forms. I'm still a novice web-developer but I've used sqlite3 for several of my Java desktop apps and I'd like to use that SQL knowledge to create this online database. I guess what i'm asking (in my ignorance) is: how can I create a sqlite-type database that is stored in the cloud and that I can query against using javascript?
Where do I get started? Is there a service like Amazon AWS or Azure or something where I can create this database and then use some sort of jQuery/Javascript API to query data from it? I don't need a ton of storage space and my queries would be very basic SQL type stuff.
Any help would be greatly appreciated. Thanks in advance.
For more flexibility, less service lock-in, and cheaper scalability: I would suggest CouchDB (though you would likely still use a hosting service like Cloudant). CouchDB can host your website, and provides a HTTP API for storing data, to which your client-side JavaScript can make REST calls.
StackMob has a free package that you can use. You can use the JS SDK to write your HTML5 app and save stuff to the StackMob DB. You can host your HTML5 on StackMob for free and point your own domain to it as well. There is also S3 integration.
Some references:
JS SDK
JS SDK Tutorial
Hosting your HTML5
Custom Domains
Create a Postgres database on Heroku for free.
https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier
As you mentioned your website is hosted on Amazon S3 I am sure it is a static website with lots of JavaScript embedded HTML files. Due to having a static website, I can understand your requirement to use a database which can be connected from your static site and to be very honest there are not a lot options you have. Static website are considered to have no dependency on database so honestly you have very limited choice because what you are looking for is "A Database which is accessible over HTTP which you can call from scripting language withing HTML"
If you have ability to write back to S3 directly from your JavaScript code you can create a JavaScript based database within your static site which is complex but consider a choice.
In my thinking you are better off to have an extra-small instance in Windows Azure (or your choice of cloud service) and connect with a cloud based database which will be comparative cheaper and fit for your requirement.
Or unless Amazon can come up with a DB accessible from status content as S3, you really have no great choices here.
Since you are already familiar some of AWS's offerings, you should check out:
Amazon RDS - Managed Relational Database Service for MySQL or Oracle
Amazon DynamoDB - Fast, Predictable, Highly-scalable NoSQL data store
But to do what you are asking (access data via JavaScript), check out www.stackmob.com. You can host an HTML5 application with data access via backbone (javascript based framework) on StackMob.
Create a Virtual Private Server on Vultr.com. It's not the easiest way, but it's the best way for you to learn about Database Security, and it will be significantly cheaper than the other solutions, should your server begin to require more storage.
[vitrobridgedb] is free for hobby applications and pretty straight-forward to use
SQLite isn't really a good choice for web facing applications due to its scaling issues.
Both AWS and Azure support SQL databases. They also each support alternatives like MongoDB and Redis. For something as basic as you describe the only real difference is cost.