How Couchbase Lite use SQlite for NoSQL data - sqlite

While SQLite is for relationnal database, how couchbase use it for NoSQL data queryable ?

Couchbase Lite can use different storage engines internally.
In the SQLite case, the main document body is stored as a blob. Most of the data in the tables actually has to do with tracking revisions, views, supporting sync (replication), and so on. (This is as of version 1.4.0.)
So, to answer what I think is the main point of your question, CBL isn't turning documents into tables the way you would if you were trying to store the data directly in SQLite.
These are, of course, implementation details you should not rely on. If you're interested in finding out more, you can look at the source (Couchbase is open source) and use standard SQLite tools to examine the database itself.

Related

Monotouch Sqlite-net or ADO.Net

I would like to use Sqlite database in my Monotouch app. From http://docs.xamarin.com/recipes/ios/data/sqlite i see two options.
Sqlite-net
ADO.NET
Doing research i found that Sqlite-net is easy to use, works on both ios and android but does not support foreign key concept. My need is to have relations in my db. Student table is linked to classes, professor, assignments table. Not so complicated!!!
Does Sqlite-net supports such relations? Which one is better choice Sqlite-net or ADO.Net.
Appreciated...
Thanks
ADO.Net doesn't give you out of the box support for relationships either. It only gives you raw classes like SQLCommand and SQLDataReader.
I would highly recommend sqlite-net, as it is a huge timesaver in being an ORM.
You can setup foreign keys by calling manual SQL statements in sqlite-net, which is the same you would do with ADO.Net anyway.
So with sqlite-net, there are several ways you could setup your database:
Call sqlite-net's APIs for creating tables based on your C# classes, then add things it doesn't support with manual SQL like foreign keys and indexes
Include an empty database with your app with the full schema already setup
Create the entire database with a raw SQL script
I tend to go with option #2 if I want full control of the database schema (and it's a little easier to include a database file I made in SQLite Expert). sqlite-net should work with an existing database just fine.

Using MySql wit linq

I have 2 questions for which I need help.
1)
I have developed an application where in I store the files(doc,xls,etc) in database. I have used LINQ to perform insert,update and delete. I have used MS SQL. Now, the requirement is that of using MySql. Can I use LINQ wit MySql. I searchd and found that LINQ only supports MS SQL and access. If it is decided that MySql should be usued, I dont want to go back to the traditional 3tier architecture. Can NHibernate can be used with MySql?
2)
How do the blade servers perform when it has to manage a data of 500gb+ data(documents). The RAM is about 12GB. Please nedd sugggestions that if such a huge amount of data is there, is it better not to store the data(documents) in database and store it in drives on the server instead.Because I have seen that if the data is stored in database(binary format) the size does increase.
Ok, here we go
1) It is not possible to communicate with an MySQL-Database via Linq To Sql, like you mentioned it is only build for MSSQL and Access. Prefer using the EntityFramework to communicate with variable databases. It is nearly the same to work with like Linq To Sql. You can easily develop your application using an MSSQL-Database and switch to a MySQL-Database after deployment by just changing your ConnectionString and installing the MySQL-EntityFramework-Connector.
These links may be helpfull to you:
Codeproject.com - An Introduction to Entity Framework for Absolute Beginners
Stackoverflow.com - Using MySQL with Entity Framework
2) I would advise you to store your data on physical drives and set references to the stored file in your database. This is because the heavy amount of data transferred while requesting one of your documents will slow down your database for other querys that normally just would take milliseconds to be executed.

How to save Application data

Generally, how to save application data?
In a binary file, or a database? In other words, which structure can I use?
If there is a database table, how can I select data from it?
For simple applications settings, use QSettings - it provides persistent platform-independent application settings.
For more complex data, you might want to have a look at QSqlDatabase, several databases are supported, including SQLite. To select data or, more generally, to make an SQL query, have a look at QSqlQuery.

Sqlite database documentation templates / software?

I need to write documentation for several small sqlite databases. Want to describe how the data is used, including table and row descriptions and sample data.
Is it possible to use MySQL Workbench? If not are there any alternatives, or any templates I could work from?
TIA!
Using MySQL Workbench is not possible since, as far as I know, it only supports exporting to SQLite. For a number of suggestions about free database managers you might want to take a look at What are good open source GUI SQLite database managers? - a number of the GUIs mentioned there support report generation.
Definitely far more feature rich, but with a significant price tag, is Navicat for SQLite, which is an excellent database manager with report generation features.

Creating stored procedure in SQLite

Is it somehow possible to create a stored procedure when using SQLite?
SQLite has had to sacrifice other characteristics that some people find useful, such as high concurrency, fine-grained access control, a rich set of built-in functions, stored procedures, esoteric SQL language features, XML and/or Java extensions, tera- or peta-byte scalability, and so forth
Source : Appropriate Uses For SQLite
Answer: NO
Here's Why ... I think a key reason for having stored procs in a database is that you're executing SP code in the same process as the SQL engine. This makes sense for database engines designed to work as a network connected service but the imperative for SQLite is much less given that it runs as a DLL in your application process rather than in a separate SQL engine process. So it makes more sense to implement all your business logic including what would have been SP code in the host language.
You can however extend SQLite with your own user defined functions in the host language (PHP, Python, Perl, C#, Javascript, Ruby etc). You can then use these custom functions as part of any SQLite select/update/insert/delete. I've done this in C# using DevArt's SQLite to implement password hashing.
Chris Wolf made a prototype implementation of SQLite with stored procedures. You can find the details at his blog post: Adding Stored Procedures to SQLite
Yet, it is possible to fake it using a dedicated table, named for your fake-sp, with an AFTER INSERT trigger. The dedicated table rows contain the parameters for your fake sp, and if it needs to return results you can have a second (poss. temp) table (with name related to the fake-sp) to contain those results. It would require two queries: first to INSERT data into the fake-sp-trigger-table, and the second to SELECT from the fake-sp-results-table, which could be empty, or have a message-field if something went wrong.
No, but you can :
Write long multi-statement scripts
Create temporary one-row tables called e.g. Vars to hold variables
Create a View over a Recursive CTE to program arbitrary functions in pure SQL queries.
So you can do most things you would normally do with stored procs.
For how to program functions in a SQL View see https://www.cafe-encounter.net/p3300/pretending-that-sqlite-has-stored-procedures-and-functions.
Alternatively you can:
Compile short single-page C programs to program arbitrary functions
This is easier and less work than you might think!
A step-by-step guide is at https://www.cafe-encounter.net/p3244/installing-and-using-sqlite-extensions-on-macos-and-maybe-windows-linux-too . This does add some deployment work: you will have to deploy the additional dll/so/dylib files with your application.
I've come across this question myself. I think stored procedures are supported in PHP PDO, but that module is handling it and building normal SQL queries to send to SQLite. So, in PHP, possible to write stored procedures in your code, but no performance gain from using them.
Correct me if I'm wrong, please.

Resources