Database Setup

Setting up the database is reasonably straightforward. This section will describe how to load an example schema - the BaseSchema - into a new database, while the next section will describe how that database can be manipulated by using command-line 'curl' commands that manipulate the database using the Web API Bridge.

First, download the BaseSchema sql file and check its MD5 checksum.

cd ~
wget http://www.baseschema.com/client/baseschema/resources/downloads/BaseSchema-1.0.sql
md5sum BaseSchema-1.0.sql
fbeded0d6eee73b445bd0c05dad61718 BaseSchema-1.0.sql

Second, login to MySQL and create a database. This database must be the same name as the most specific subdomain of your intended API service address, excepting 'api', or 'api-'. For example, the database for http://api.webapibridge.org would be 'webapibridge'.

In the following example, because we will be creating a database based on baseschema, we will create a database with the name 'baseschema', and access it using the API endpoint api.baseschema.local

mysql -u root -p
Enter password:
mysql> create database baseschema;
exit

To load the SQL schema:

mysql -u root -p -D baseschema < BaseSchema-1.0.sql
Enter password:

If you login to MySQL and run 'SHOW TABLES' you will see the numerous tables that make up the Base Schema.

mysql -u root -p -D baseschema
Enter password:
mysql> SHOW TABLES
+-------------------------------------+
| Tables_in_baseschema                |
+-------------------------------------+
| articles                            |
| articles_info                       |
| files                               |
| logs                                |
| payments_credit_cards               |
| payments_customers                  |
| payments_details                    |
| payments_invoices                   |
| payments_plans                      |
| payments_purchases                  |
| payments_remove_cards               |
| payments_transactions               |
| preregistrations                    |
| replicantdb_log                     |
| statistics_impressions              |
| statistics_visits                   |
| users                               |
| users_activations                   |
| users_alternate_emails              |
| users_deleted                       |
| users_requested_invites             |
| users_send_resets                   |
| users_sessions                      |
| users_termination_schedule          |
| users_uids                          |
| view_articles                       |
| view_articles_info                  |
| view_files                          |
| view_files_tokens                   |
| view_payments_credit_cards          |
| view_payments_credit_cards_unsynced |
| view_payments_customers_uncreated   |
| view_replicantdb_log                |
| view_statistics_impressions         |
| view_statistics_uniques             |
| view_statistics_visits              |
| view_users                          |
| view_users_sessions                 |
| view_users_summaries                |
+-------------------------------------+
39 rows in set (0.00 sec)

mysql> 

Now read the next section 'CURL Examples', which shows how to manipulate the database via the Web API Bridge using command-line curl commands.