{"id":18772462,"url":"https://github.com/eftec/milkco-database","last_synced_at":"2026-02-26T02:02:27.027Z","repository":{"id":71041752,"uuid":"274160326","full_name":"EFTEC/MilkCo-Database","owner":"EFTEC","description":"It is an example database for MYSQL and SQL SERVER, similar to Sakila and Adventureworks","archived":false,"fork":false,"pushed_at":"2020-07-04T17:51:20.000Z","size":30365,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T08:13:36.723Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.escuelainformatica.cl","language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EFTEC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-22T14:30:27.000Z","updated_at":"2020-07-04T17:50:28.000Z","dependencies_parsed_at":"2023-06-30T00:45:32.278Z","dependency_job_id":null,"html_url":"https://github.com/EFTEC/MilkCo-Database","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FMilkCo-Database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FMilkCo-Database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FMilkCo-Database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FMilkCo-Database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EFTEC","download_url":"https://codeload.github.com/EFTEC/MilkCo-Database/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680815,"owners_count":19679505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T19:29:10.469Z","updated_at":"2025-12-12T21:30:14.675Z","avatar_url":"https://github.com/EFTEC.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MilkCo-Database\nIt is an example database for MYSQL/Sql Server and it works similar to Sakila, AdventureWorld and other example \ndatabases.\n\n![](banner.jpg)\n\n\u003e Photo from unsplash.com/@jaypix_01\n\nIt is a database model of a Milk Company that we could use to test and evaluate Business Intelligence and Data Science.\n\n## Visual Example using Microsoft Power BI\n\n![Database example for power bi](powerbi2.jpg)\n\n[powerbi/milkco_example_v2.pbix](powerbi/milkco_example_v2.pbix)\n\n\n\n\u003e Note: It points to my database so you will want to change the datasource.    \n\u003e Note: Shocking but it worked OOBE Out Of Box Experience 📦 It is thanks to PowerBI understands foreign keys.   \n\n### Requirements\n\n* Microsoft PowerBI (desktop is for free https://powerbi.microsoft.com/en-us/downloads/ )   \n* MySql Connector Net ( https://dev.mysql.com/downloads/connector/net/ ) If you are using Mysql Database\n* If you are using Sql Server, then you don't need any aditional.\n\n## ER Diagram\n\n![](v2/milkco2.jpg)\n\n## Features\n\n* Products (Skus) divided in types, subtypes, container (cup, bottle, etc.) and brands.\n* 3 Brands: Value Pack, Auntie Annie and Red Label (cheap, normal and expensive)\n* More than 10 years of sales.\n* A worldwide company with offices, employees and customers across the globe.\n* The products has a trends (some products are more sold than others)\n* The sales has seasonal trends in the number of invoice and in the size of the invoices.\n* 50 Branches (offices) across the globe.\n* 1000 Employees\n* 17000 Invoices starting the 2005. The invoices have stationary trends.\n* 64000 Invoice details. The invoices have stationary trends.\n* 3563 Customers. Some of them are companies\n* The database model is vanilla and clean. It does not have views, store procedure, functions or even index (with the exception of primary key and foreign keys)\n* The columns are normalized to use the minimum type of definitions.\n\n| types              | Mysql Definition |\n| ------------------ | ---------------- |\n| Integer numbers    | int              |\n| Strings and texts  | varchar          |\n| Money and decimals | decimal(10,2)    |\n| Booleans           | tinyint          |\n| Date               | DateTime         |\n| Timestamps         | Timestamp        |\n\n## Specifications\n\n* Every Indexes have a prefix called \"id\" with the exception of \"Sku\", where \"sku\" is the index without a prefix.\n* Foreign keys don't have a special name. Usually they have the same name than the primary key.\n* All tables are in plural. Composed names are written in camel case.\n* Columns are written in lowercase, and it starts in lowercase.\n\n## Considerations\n\n* It works with MySQL 8.0 or higher** or Sql Server 2019 or higher.\n* It could work with an older version of MySQL, but you must replace the encoding:\n\n```sql\n-- mysql 8.0\nDEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci\n-- mysql \u003c=5.7\nDEFAULT CHARSET=utf8 \n```\n\n* It could with with an older version of Sql Server (using the script) but it is not tested.\n\n* It misses some features. For example, a table of purchases, the salaries and the costs of each branches are fixed\n* Values are not inflationary. \n* It lacks shipping\n* It does not consider taxes. If the taxes are flat, then it is not a problem.\n\n## Trends\n\nThis database was created with random values. However, it has some trends \n\n\u003e   (I don't want to spoil much the results 😀)\n\n### For example, the invoices per day (January 2020)\n\n![](invoices_per_day.jpg)\n\nSo, apparently, there is not a trend.\n\n### And Invoices per day week (January 2020)\n\n![](invoices-per-day-week.jpg)\n\nDid you see the trend?\n\n\n\n## How to install it? \n\n### Mysql\n\n1. Create a new schema or use one.\n\n```sql\nCREATE SCHEMA `milkco` ; -- or you can use any name.\n```\n\n2. Run the [v2/ddl.sql](v2/ddql.sql)  script\n   \n   1. It includes the structure of the database and the foreign key.s\n3. Run the [v2/dml.sql](v2/dml.sql) script.\n   \n   1. It includes the data of the database.\n4. (optional) You can delete all data executing the next script [v2/truncate_all.sql](v2/truncate_all.sql)   \n5. (optional) You can delete most data (data that usually changes) by executing the next script [v2/truncate_nofixed.sql](v2/truncate_nofixed.sql)\n\n### Sql Server\n\n#### Using the backup\n\n\u003e This is the method recommended, but it is only compatible with Sql Server 2019/2019 or higher (Express, Standard or DataCenter).\n\nLoad next backup file [sqlsrv/milkco2019.bak](sqlsrv/milkco2019.bak)\nLoad next backup file [sqlsrv/milkco2012.bak](sqlsrv/milkco2012.bak)    \n\n#### Using a Script\n\nLoad next script file [sqlsrv/sql.zip](sqlsrv/sql.zip)    \n\n   \n## Related link\n\nhttps://www.southprojects.com/architecture/milko-fake-database-example\n\n## Versions\n\n* 2.2.1\n    * Fixed sql server 2012 (.bak) because it misses some foreign keys.  \n* 2.2 \n    * Added sql server 2012 and 2019.\n* 2.1\n    * Added Sql Server.       \n* 2.0\n    * Rebuild the information. Now it has more records, but it is only for (more or less) 15 years.\n    * Tables related with **cities** are not related with **countries** anymore (it was redundant)\n    * **Customers** buy from **branches** (offices) in the same **country**.\n    * **Employees** works in the same city as **branches**.\n    * **Customers** generate at least 1 invoice.\n    * **Branches** trend to reside in populous cities. Usually, dairy companies reside in rural towns but they sold it \n    in big cities.\n    * **Customers** could generate 1 **invoice** per day or longer.\n* 1.1 \n   * Table **Country** renamed as **Countries**.\n   * New script truncate_all.sql   \n   * New script truncate_nofixed.sql     \n* 1.0 \n   *   First version    \n   \n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fmilkco-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feftec%2Fmilkco-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fmilkco-database/lists"}