Code Monkey home page Code Monkey logo

thailand-administrative-division-province-district-subdistrict-sql's Introduction

ฐานข้อมูล จังหวัด อำเภอ ตำบล ละติจูด ลองจิจูด

ข้อมูลจาก Open Government Data data.go.th

ข้อมูลพิกัด LAT/LONG ที่ตั้งตำบล

โดย

  • ปรับปรุงความถูกต้องของข้อมูลที่ซ้ำกัน
  • ปรับข้อมูลให้อยู่ในรูปแบบ relational database
  • เพิ่ม Foreign key
  • Indexing
  • Unique constraint
  • Rename column
  • Surrogate Id

How to use it/การใช้งาน

  • connect to your database
  • execute thai-administrative-division-full-my-sql.sql for MySQL database
  • execute thai-administrative-division-full-sql-server.sql for SQL Server database

database diagram

thai-administrative-division-province-district-subdistrict-sqld-iagram

database dictionary

ความถูกต้องของข้อมูล

ฐานข้อมูลมีจำนวนข้อมูลดังนี้

  • จำนวนจังหวัด 77 จังหวัด
  • จำนวนอำเภอ 928 อำเภอ
  • จำนวนตำบล 7,364 ตำบล
  • จำนวนเลขรหัสไปรษณีย์ของแต่ละตำบล 7,348 จำนวน (มีบางตำบลไม่มีรหัสไปรษณีย์ ฐานข้อมูลขาดข้อมูลส่วนนี้ไป)

SQL statement to verify number of row

SELECT COUNT(Id) FROM Provinces;
SELECT COUNT(Id) FROM Districts;
SELECT COUNT(Id) FROM Subdistricts;
SELECT COUNT(Id) FROM Subdistricts WHERE ZipCode IS NOT NULL;

หากข้อมูลส่วนใดไม่ถูกต้อง ต้องการให้แก้ไข สามารถสร้าง PR หรือติดต่อมาที่ facebook page codesanook.com ได้เลยครับ

ความถูกต้องของข้อมูล

  • ข้อมูลบางส่วนไม่ได้ update เป็นล่าสุด เช่น ตำบล รหัสไปรษณีย์
  • ข้อมูลละติจูด ลองจิจูดไม่แม่นยำสำหรับพื้นที่ตำบลที่เป็นเกาะ เพราะต้องใช้ข้อมูลหลายจุด ไม่สามารถใช้ข้อมูลจุดเดียวได้ จะปรับปรุงในอนาคต
  • ความถูกต้องของข้อมูลจะได้รับการปรับปรุงเมื่อพัฒนาเป็นระบบเป็น web application ที่ทุกคนสามารถเข้าไปร่วมแก้ไข และช่วยกันตรวจสอบความถูกต้อง

Credit & Thank you

useful information

index and key naming convention

  • If Index is Primary Clustered Index, use PK_TableName

  • If Index is Non-clustered Index, use IX_TableName_ColumnName1_ColumnName2…

  • If Index is Unique Non-clustered Index, use UX_TableName_ColumnName1_ColumnName2… (unique key should be index)

  • If Foreign key : FK_TableName_ColumnName1_ColumnName2… (Use IX.. if you want to create index for this foreign key)

  • credit https://blog.sqlauthority.com/2012/05/21/sql-server-renaming-index-index-naming-conventions/

TO DO

  • SQL script for SQL server
  • SQL script for MySQL
  • zip code
  • CodeSanook Module
  • allow to edit correctness/approve
  • Export to multiple types of RDMS with NHibernate e.g.
  • SQL Server
  • MySQL
  • Oracle
  • SQLite
  • SQL Server Compact
  • PostgreSQL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.