readme: update.

This commit is contained in:
0x1eef 2022-05-28 03:54:34 -03:00
parent 5f13718806
commit 6eaf75ec16

148
README.md
View file

@ -251,80 +251,7 @@ sqlite> .read src/sql/seed.sql
sqlite>
```
**4. Query the database**
4.1
After steps two and three, the database is fully populated and exists
in memory / RAM. We can now query the database and its contents. The SQL
query we will execute fetches the contents of chapter 112 in the English
locale (i.e: `en`):
```sql
SELECT qurans.locale,
chapters.number as chapter,
verses.number as verse,
verses.content from verses
INNER JOIN qurans ON qurans.id = verses.quran_id
INNER JOIN chapters ON chapters.id = verses.chapter_id
WHERE qurans.locale = "en" AND chapters.number = 112;
```
The output should look like this:
```
sqlite> SELECT qurans.locale,
...> chapters.number as chapter,
...> verses.number as verse,
...> verses.content from verses
...> INNER JOIN qurans ON qurans.id = verses.quran_id
...> INNER JOIN chapters ON chapters.id = verses.chapter_id
...> WHERE qurans.locale = "en" AND chapters.number = 112;
locale chapter verse content
------ ------- ----- -----------------------------------------------------
en 112 1 Say, ˹O Prophet,˺ “He is Allah—One ˹and Indivisible˺;
en 112 2 Allah—the Sustainer ˹needed by all˺.
en 112 3 He has never had offspring, nor was He born.
en 112 4 And there is none comparable to Him.”
```
4.2
The next query we will execute demonstrates how to find a particular word or
phrase in the English translation of The Qur'an, using the LIKE operator:
```sql
SELECT qurans.locale,
chapters.number AS chapter,
verses.number AS verse,
verses.content from verses
INNER JOIN qurans ON qurans.id = verses.quran_id
INNER JOIN chapters ON chapters.id = verses.chapter_id
WHERE qurans.locale = "en" AND
verses.content LIKE "%reflected light%";
```
The output should look like this:
```
sqlite> SELECT qurans.locale,
...> chapters.number AS chapter,
...> verses.number AS verse,
...> verses.content FROM verses
...> INNER JOIN qurans ON qurans.id = verses.quran_id
...> INNER JOIN chapters ON chapters.id = verses.chapter_id
...> WHERE qurans.locale = "en" AND
...> verses.content LIKE "%reflected light%";
locale chapter verse content
------ ------- ----- ------------------------------------------------------------
en 10 5 He is the One Who made the sun a radiant source and the moon
a reflected light, with precisely ordained phases, so that
you may know the number of years and calculation ˹of time˺.
Allah did not create all this except for a purpose. He makes
the signs clear for people of knowledge.
```
**5. Save the database to disk**
**4. Save the database to disk**
The `.save` command can be used to save the database to disk permanently -
after steps 2 and 3 have been completed. This will help avoid having to repeat
@ -337,8 +264,8 @@ sqlite> .save src/sql/quran.db
sqlite> .exit
```
From that moment on, sqlite3 can be started with the path to the database
saved to disk instead:
From now on, sqlite3 can be started with the path to the database
saved to disk instead loading into memory each time:
```
$ sqlite3 src/sql/quran.db
@ -349,6 +276,75 @@ id
sqlite>
```
**5. Query the database**
5.1
After the previous steps, the database is fully populated and exists
on disk. We can now query the database and its contents. The SQL
query we will execute fetches the contents of chapter 112 in the English
locale (i.e: `en`):
```sql
SELECT qurans.locale,
chapters.tr_name AS "chapter (name)",
chapters.number AS chapter,
verses.number AS verse,
verses.content
FROM verses
INNER JOIN qurans
ON qurans.id = verses.quran_id
INNER JOIN chapters
ON chapters.id = verses.chapter_id
WHERE qurans.locale = "en"
AND chapters.number = 112;
```
The output should look like this:
```
locale chapter (name) chapter verse content
------ -------------- ------- ----- -----------------------------------------------------
en Al-Ikhlas 112 1 Say, ˹O Prophet,˺ “He is Allah—One ˹and Indivisible˺;
en Al-Ikhlas 112 2 Allah—the Sustainer ˹needed by all˺.
en Al-Ikhlas 112 3 He has never had offspring, nor was He born.
en Al-Ikhlas 112 4 And there is none comparable to Him.”
```
5.2
The next query we will execute demonstrates how to find a particular word or
phrase in the English translation of The Qur'an - using the LIKE operator:
```sql
SELECT qurans.locale,
chapters.name AS "chapter (name)",
chapters.number AS chapter,
verses.number AS verse,
verses.content
FROM verses
INNER JOIN qurans
ON qurans.id = verses.quran_id
INNER JOIN chapters
ON chapters.id = verses.chapter_id
WHERE qurans.locale = "en"
AND verses.content LIKE "%reflected light%";
```
The output should look like this:
```
locale chapter (name) chapter verse content
------ -------------- ------- ----- ------------------------------------------------------------
en Jonah 10 5 He is the One Who made the sun a radiant source and the moon
a reflected light, with precisely ordained phases, so that
you may know the number of years and calculation ˹of time˺.
Allah did not create all this except for a purpose. He makes
the signs clear for people of knowledge.
```
### <a id='bin-directory'>`bin/` directory</a>
The [bin/](bin/) directory contains scripts that generate the