README: update

This commit is contained in:
0x1eef 2023-01-04 00:55:54 -03:00
parent 0d90e8c7a8
commit 5f267feeb0

View file

@ -1,8 +1,8 @@
## About ## About
This repository contains the holy book, The Quran, in its original Arabic and as translations This repository contains the holy book, The Quran, in its original Arabic
in English, Farsi, and Portuguese. The contents are made available as JSON, and SQL. The SQL and as translations in English, Farsi, and Portuguese. The contents are made
can be imported to create a database that contains The Quran. available in the JSON, and SQL formats.
**Contents** **Contents**
@ -12,8 +12,6 @@ can be imported to create a database that contains The Quran.
## <a id='srcjson-directory'>`src/json/` directory</a> ## <a id='srcjson-directory'>`src/json/` directory</a>
This section covers the JSON files.
* The [src/json/ar/](src/json/ar/) directory contains The Quran in its original Arabic. * The [src/json/ar/](src/json/ar/) directory contains The Quran in its original Arabic.
* The [src/json/en/](src/json/en/) directory contains an English translation of The Quran. * The [src/json/en/](src/json/en/) directory contains an English translation of The Quran.
@ -89,30 +87,25 @@ The codepoints can be mapped to Arabic using JavaScript's
## <a id='srcsql-directory'>`src/sql/` directory</a> ## <a id='srcsql-directory'>`src/sql/` directory</a>
This section covers the SQL files.
* The [src/sql/schema.sql](src/sql/schema.sql) defines the schema of the database. <br> * The [src/sql/schema.sql](src/sql/schema.sql) defines the schema of the database. <br>
The schema is composed of three tables: `qurans`, `chapters`, and `verses`. The schema is composed of three tables: `qurans`, `chapters`, and `verses`.
* The [src/sql/seed.sql](src/sql/seed.sql) populates the contents of the database. <br> * The [src/sql/seed.sql](src/sql/seed.sql) populates the contents of the database. <br>
The languages included are Arabic, English, Farsi, and Portuguese. The languages included are Arabic, English, Farsi, and Portuguese.
* The [src/sql/queries/](src/sql/queries) directory contains `.sql` files that contain SQL queries. <br> * The [src/sql/queries/](src/sql/queries) directory contains `.sql` files that
They serve as examples, and as inspiration for writing new queries. contain example SQL queries.
### SQLite3 ### SQLite3
This section of the README demonstrates how the SQL files mentioned above can be used The SQL files mentioned above can be used to create a fully populated database
to create a fully populated database in memory, how to query the database, and how to in-memory and on disk using SQLite3. Other SQL databases might work as well but
save the database to disk for future use. have not been tested.
It is assumed that the repository has been cloned or downloaded (see below), and that
"sqlite3" is started from the root of the repository. Other SQL databases, such as MySQL,
and PostgreSQL should be able to import the SQL files as well, but have not been tested.
**1. $HOME/.sqliterc** **1. $HOME/.sqliterc**
For identical results - it is recommended that `$HOME/.sqliterc` has the following contents: For identical results - it is recommended that `$HOME/.sqliterc` has the
following contents:
``` ```
PRAGMA case_sensitive_like=ON; PRAGMA case_sensitive_like=ON;
@ -122,10 +115,9 @@ pragma FOREIGN_KEYS = on;
``` ```
**2. Import / save the database to disk** **2. Save the database to disk**
The `.save` command can be used to save the database to disk permanently, and The `.save` command can be used to save the database to disk:
avoid repeatedly importing the database into memory:
``` ```
sqlite> .read src/sql/schema.sql sqlite> .read src/sql/schema.sql
@ -134,7 +126,8 @@ sqlite> .save src/sql/quran.db
sqlite> .exit sqlite> .exit
``` ```
SQLite3 can now be started with the path to the database saved to disk: SQLite3 can then be started with the path to the database that's been saved
to disk:
``` ```
$ sqlite3 src/sql/quran.db $ sqlite3 src/sql/quran.db
@ -149,10 +142,8 @@ sqlite>
3.1 3.1
After the previous steps, the database is fully populated and exists The SQL query we will execute fetches the contents of chapter 112 in
on disk. We can now query the database and its contents. The SQL the English locale (i.e: `en`):
query we will execute fetches the contents of chapter 112 in the English
locale (i.e: `en`):
```sql ```sql
SELECT qurans.locale, SELECT qurans.locale,
@ -169,7 +160,7 @@ WHERE qurans.locale = "en"
AND chapters.number = 112; AND chapters.number = 112;
``` ```
The output should look like this: The output should look similar to this:
``` ```
locale chapter (name) chapter verse content locale chapter (name) chapter verse content
@ -182,8 +173,8 @@ en Al-Ikhlas 112 4 And there is none comparable to Him.”
3.2 3.2
The next query we will execute demonstrates how to find a particular word or The next query we will find a particular phrase in the English translation of The Quran
phrase in the English translation of The Quran - using the LIKE operator: by using the LIKE operator:
```sql ```sql
SELECT qurans.locale, SELECT qurans.locale,
@ -201,7 +192,7 @@ WHERE qurans.locale = "en"
``` ```
The output should look like this: The output should look similar to this:
``` ```
locale chapter (name) chapter verse content locale chapter (name) chapter verse content
@ -263,8 +254,9 @@ bundle install
## Download ## Download
For those who don't have access to, or know how to use "git", The contents of the repository is provided as a zip file.
a zip file of the repository is provided for download: [download zip file](https://github.com/ReflectedLight/The-Qur-an/archive/refs/tags/v0.11.1.zip). <br>
[Download zip file](https://github.com/ReflectedLight/The-Qur-an/archive/refs/tags/v0.11.1.zip).
## Credit, and thanks ## Credit, and thanks