Using the data made public by the government, a mySQL, csv, and json file has been created which can be used by Developers who are in need of the Philippines Standard Geography Code (example of use case is for the Address).
The data currently contains:
- 81 Province Records
- 145 City Records
- 1,489 Municipality Records
- 42,036 Barangay Records
PSGC is a systemic way of classifying the geographic areas of the Philippines.
The PSGC database as of 31 December 2017 can be accessed at PSGC Publication DEC2017 in excel format. For more information please visit their website here.
The PSGC Classifies the geographical-political subdivisions of the country into 5 levels:
- Region
- Province
- City
- Municipality
- Barangay
The schema contains four tables:
- Region
- Province
- MunCity - a mixture of City and Municipality
- Barangay
The code
column in the table stands for the Philippine Standard Geographic Code. While the district
is the Legislative Districts.
See the EERD File here.
- Open the MySQL Workbench, and create a schema.
Note: Replace the databaseName with your desired schema name
CREATE DATABASE IF NOT EXISTS `databaseName`;
USE `databaseName`;
- Execute the table-region.sql.
- Execute the data-region.sql.
- Execute the table-province.sql.
- Execute the data-province.sql.
- Execute the table-muncity.sql.
- Execute the data-muncity.sql.
- Execute the table-barangay.sql.
- Execute the data-barangay.sql.
To see all the data within the Tables, check the view-psgc.sql.
CREATE OR REPLACE VIEW `psgc_view` AS
SELECT b.`description` AS `barangay`,
m.`description` AS `muncity`,
m.`district` AS `district`,
p.`description` AS `province`,
r.`description` AS `region`
FROM `barangay` b
INNER JOIN `muncity` m
ON m.`muncity_id` = b.`muncity_id`
INNER JOIN `province` p
ON p.`province_id` = m.`province_id`
INNER JOIN `region` r
ON r.`region_id` = p.`region_id`;
{
"region_id": Number,
"code": Number,
"description": String
}
{
"province_id": Number,
"region_id": Number,
"code": Number,
"description": String
}
{
"muncity_id": Number,
"province_id": Number,
"district": String,
"code": Number,
"description": String
}
{
"barangay_id": Number,
"muncity_id": Number,
"code": Number,
"description": String
}
The psgc-data.xlsx is a compilation of the tables separated using sheets.
region.csv
barangay_id, muncity_id, code, description
province.csv
province_id,region_id,code,description
muncity.csv
muncity_id,province_id,district,code,description
barangay.csv
barangay_id,muncity_id,code,description
PSGC-Data is MIT Licensed.
This repository is inspired by clavearnel. The data used is from the PSGC.