# mogila **Repository Path**: xk_git_admin/mogila ## Basic Information - **Project Name**: mogila - **Description**: Mogila is a sample MogDB database based on PostgreSQL's Pagila. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-04-05 - **Last Updated**: 2024-06-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: MogDB ## README Mogila ====== Mogila is a port of the Sakila example database available for MySQL, which was originally developed by Mike Hillyer of the MySQL AB documentation team. It is intended to provide a standard schema that can be used for examples in books, tutorials, articles, samples, etc. Mogila works against MogDB 2.1.0 and above. All the tables, data, views, and functions have been ported; some of the changes made were: * Changed char(1) true/false fields to true boolean fields * The last_update columns were set with triggers to update them * Added foreign keys * Removed 'DEFAULT 0' on foreign keys since it's pointless with real FK's * Used PostgreSQL built-in fulltext searching for fulltext index. Removed the need for the film_text table. * The rewards_report function was ported to a simple SRF The schema and data for the Sakila database were made available under the BSD license which can be found at http://www.opensource.org/licenses/bsd-license.php. The mogila database is made available under this license as well. FULLTEXT SEARCH --------------- Fulltext functionality is built in PostgreSQL, so parts of the schema exist in the main schema file. Example usage: SELECT * FROM film WHERE fulltext @@ to_tsquery('fate&india'); PARTITIONED TABLES ------------------ The payment table is designed as a partitioned table with a 6 month timespan for the date ranges. If you want to take full advantage of table partitioning, you need to make sure constraint_exclusion is turned on in your database. You can do this by setting "constraint_exclusion = on" in your postgresql.conf, or by issuing the command "ALTER DATABASE mogila SET constraint_exclusion = on" (substitute mogila for your database name if installing into a database with a different name) INSTALL NOTE ------------ The mogila-data.sql file and the mogila-insert-data.sql both contain the same data, the former using COPY commands, the latter using INSERT commands, so you only need to install one of them. Both formats are provided for those who have trouble using one version or another. VERSION HISTORY --------------- Version 1.0 * First release of mogila USE Mogila ON [MogDB Container Edition](https://docs.mogdb.io/zh/mogdb/v2.1/container-based-installation) --------------------------- 1. On terminal pull the latest mogdb image: - amd ``` docker pull swr.cn-north-4.myhuaweicloud.com/mogdb/mogdb:2.1.0_amd ``` - arm ``` docker pull swr.cn-north-4.myhuaweicloud.com/mogdb/mogdb:2.1.0_arm ``` 2. Run image: ``` docker run --name mogdb --privileged=true -d -e GS_PASSWORD=Enmo@123 swr.cn-north-4.myhuaweicloud.com/mogdb/mogdb:2.1.0_amd ``` 3. Done! Just use: ``` docker exec -it mogdb bash ``` ``` omm@3b54e9113145:~$ gsql -d mogila -p5432 gsql ((MogDB 2.1.0 build 56189e20) compiled at 2022-01-07 18:46:52 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. MogDB=#\dt List of relations Schema | Name | Type | Owner | Storage --------+---------------+-------+-------+---------------------------------- public | actor | table | mogdb | {orientation=row,compression=no} public | address | table | mogdb | {orientation=row,compression=no} public | category | table | mogdb | {orientation=row,compression=no} public | city | table | mogdb | {orientation=row,compression=no} public | country | table | mogdb | {orientation=row,compression=no} public | customer | table | mogdb | {orientation=row,compression=no} public | film | table | mogdb | {orientation=row,compression=no} public | film_actor | table | mogdb | {orientation=row,compression=no} public | film_category | table | mogdb | {orientation=row,compression=no} public | inventory | table | mogdb | {orientation=row,compression=no} public | language | table | mogdb | {orientation=row,compression=no} public | payment | table | mogdb | {orientation=row,compression=no} public | rental | table | mogdb | {orientation=row,compression=no} public | staff | table | mogdb | {orientation=row,compression=no} public | store | table | mogdb | {orientation=row,compression=no} (15 rows) MogDB=# ``` USE Mogila ON [MogDB Enterprise Edition](https://www.mogdb.io/mogdb) --------------------------- 1. [Install MogDB](https://docs.mogdb.io/zh/mogdb/v2.1/1-installation-overview) 2. Create the sample database: ``` [root@test ~]# su - omm [omm@test ~]$ gsql -d postgres -p5432 -r gsql ((MogDB 2.1.0 build 56189e20) compiled at 2022-01-07 18:47:53 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. MogDB=#create database mogila DBCOMPATIBILITY='PG'; CREATE DATABASE MogDB=#create user mogdb password 'Enmo@123'; CREATE ROLE ``` 3. Create schema objects then insert data manually: - 3.1. Create all schema objetcs (tables, etc): ``` gsql -d mogila -p5432 -f mogila-schema.sql ``` - 3.2. Insert all data: ``` gsql -d mogila -p5432 -f mogila-data.sql ``` **OR create schema objects and insert data by 1 script, if you have done 3.1 and 3.2, you don't need 4!!** 4. Create all schema objetcs (tables, etc) and Insert all data: ``` gsql -d mogila -p5432 -f mogila-insert-data.sql ``` 5. Done! Use: ``` [omm@test ~]$ gsql -d mogila -p5432 -r gsql ((MogDB 2.0.1 build f892ccb7) compiled at 2021-07-09 16:12:59 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. mogila=# \dt List of relations Schema | Name | Type | Owner | Storage --------+---------------+-------+-------+---------------------------------- public | actor | table | mogdb | {orientation=row,compression=no} public | address | table | mogdb | {orientation=row,compression=no} public | category | table | mogdb | {orientation=row,compression=no} public | city | table | mogdb | {orientation=row,compression=no} public | country | table | mogdb | {orientation=row,compression=no} public | customer | table | mogdb | {orientation=row,compression=no} public | film | table | mogdb | {orientation=row,compression=no} public | film_actor | table | mogdb | {orientation=row,compression=no} public | film_category | table | mogdb | {orientation=row,compression=no} public | inventory | table | mogdb | {orientation=row,compression=no} public | language | table | mogdb | {orientation=row,compression=no} public | payment | table | mogdb | {orientation=row,compression=no} public | rental | table | mogdb | {orientation=row,compression=no} public | staff | table | mogdb | {orientation=row,compression=no} public | store | table | mogdb | {orientation=row,compression=no} (15 rows) mogila=# ```