This is part two of e-Sword and Databases, and in this part I want to discuss how e-Sword reads the data, the information placed in the database.
If you remember, in the outset of Part 1, I said:
Primarily and basically e-Sword is a Database Reader, in that it reads only database files.
This is very important to remember because a Database has only one primary function, and that is to gather data, and that data can be any sort, shape or size. It is an all or nothing tool, and it will display only what is put into it. Leave anything out in the database, it won't display it. So in the way that e-Sword reads the data, all that information has to be placed in the database before e-Sword can read it.
Where e-Sword puts the data
When a database file is opened in e-Sword these Fields and Records placed in a certain order and in a certain place.
In part one we looked at a Bible Database file, and in that file we have seen that it was made up of Tables, Fields, and Records. We learned that the Bible Table had the following Fields:
- Book
- Chapter
- Verse
- Scripture
How e-Sword reads and outputs the data
1. Getting it all sorted.
We also learned that in regards to the Book, Chapter, and Verse Fields, they have been given an Integer (whole number) value. With regard to the Book Field, When e-Sword reads them, those numbers are converted to a String Output in where they are given a name. So when e-Sword reads the number 1, it outputs a String called, Genesis. A String is a length of text.
In the Bible View (Window) The following database information is displayed:
- The selected book of the Bible from the Bible Field
- The selected Chapter from the Chapter Field
- All the verses related to the chapter in the Verse Field
- All the text in the Scripture Field related to the above Fields.
2. Making it all look readable and pretty
One thing you will notice in e-Sword is that the data is displayed in a certain way that makes it readable and presentable. This is Formatting. But the problem with a Database is that it can't and it doesn't cause the Data to be presented in such a way that makes it look readable and pretty. All a Database can do is give information and nothing more. A Database program such as SQLite, MS Access, Oracle, Paradox and etc., do not have text formatting capabilities. and for what they are used for neither should they have them. But we like text to have a pleasant appearance to our eyes that makes it good to read. So in order for that to happen extra data/information has to be put in the database in order for that to happen.
But that's not all. In real life there are people who speak different languages read in different languages, have different kinds of text and not all languages use Roman/English kinds of Text. Some countries read Right to Left (Horizontal), in other countries read Up and Down (Vertical), and in all English and most European countries we read Left to Right. And its here that Databases are not good at all, in fact they pretty much useless in trying to detect what kind of text and language the user has to have.
So all of these things have to be put into the a Database so that the user can read the information/data, and so we come to a crucial part of what has to be done to the data for it to be understandable.
A. Language Settings and UTF
SQLite Database uses UTF for reading language settings and fonts, and for Hebrew, Arabic, Chinese, Japanese, and other non-Roman text languages for SQLite Database file created for e-Sword, the UTF encoding is set at UTF-16le.
What does all this mean? UTF stands for Unicode Transformation Format, and it comes in Three main flavors
- UTF-8 which is Unicode Transformation Format - 8 bit, and is the primary setting for e-Sword/SQLite files.
- UTF-16 which is Unicode Transformation Format - 16 bit, and is a large extension of UTF-8, and does more than UTF-8. There are two subcategories of UTF-16 which are UTF-16le (Unicode Transformation Format -16 bit Little Endian) and UTF-16be (Unicode Transformation Format Big Endian).
- UTF-32 which is Unicode Transformation Format - 32 bit, and is also known as UTF 4 or Unicode version 4. This is basically the mother of all Unicode, and its huge. It also has the Little and Big Endian capability that UTF-16 has.
For example if the Language has been set by the reserved word HEBREW, and the direction of the text has been set as "1" (for Right to Left {see Details Table for these settings} ) then the UTF encoding will pick up this information, and it will read the code for the glyphs, and display the text in e-Sword.
B. RTF Code and Settings
Rich Text Formatting (a Microsoft invention) also has to be entered into the database in order for the text to be displayed with a particular formatting. Interesting to note, that e-Sword editors are Database file generators, and it inserts the RTF code for the format into the database file, and it reads that format. No RTF Code is stored inside e-Sword. All RTF code is placed in the Record of a particular Table of that database file.
Fonts, Font sizes, margins and etc, in the Editors are placed in their Database files. As where Bible Database files, I think are in Unicode, and are read by e-Sword.
OK, this actually ends this bit on e-Sword and Databases, of how they work. Although much of the information is quite technical, and may be somewhat difficult to understand, I trust this has been an interesting learning curve for you.
If you have SQLite Manager or SQLite Browser, open an e-Sword resource file in it, and explore it. Look at the different Tables, Fields and Records, look at the settings, note the code used in a Record Entry, and you'll see just how all that works in e-Sword. But before you play around with a file in SQLite, be sure to make a copy of it, so if you stuff it up, at least you'll have a copy to replace it.
Blessings,