SlideShare a Scribd company logo
1 of 39
How to Design a Good Database
PHPID Online Meetup for COVID-19
8 April 2020 - https://zoom.us/j/510834649
8 April 2020 How to Design a Good Database Code Factory
About Me
• Editor PojokProgrammer.net
• Writers welcome!
• CEO Cronos Studio
• Developers welcome!
• Pegiat Komunitas
• PHP Indonesia
• MySQL Indonesia
• Drupal Indonesia
• VB.Net Indonesia
How to Design a Good Database8 April 2020 Code Factory
E-Commerce
8 April 2020 How to Design a Good Database Code Factory
Social Media
ERP Software
8 April 2020 How to Design a Good Database Code Factory
Apa Persamaannya?
8 April 2020 How to Design a Good Database Code Factory
GoodDesign Matters
• Data are foundation of your application.
• A well-designed database is easy to understand.
• A well-designed database performs fast and efficient.
8 April 2020 How to Design a Good Database Code Factory
Poorly
Designed
Database
Poorly
Designed
Application
Low
Performance &
Chaotic Data
Difficult to
Maintain &
Enhance
Agenda
• Characteristics of Good Database Design
• How to Design a Good Database
• Case Study: Inventory System
8 April 2020 How to Design a Good Database Code Factory
Are You Ready?
8 April 2020 How to Design a Good Database Code Factory
Characteristics of GoodDatabase Design
8 April 2020 How to Design a Good Database Code Factory
ThingsTo Consider
• What Functionality is Needed from the Database?
• Break Your Data Into Logical Pieces
• Avoid Data Separated by Separators
• Centralize Name Value Table Design
• Self-reference PK And FK For Unlimited Hierarchical Data
• Database Design Tips
• Relational vs. NoSQL Databases
8 April 2020 How to Design a Good Database Code Factory
Database Functionality
• Transactional (OLTP): Write intensive application. Your end
user is more interested in CRUD, i.e., creating, reading,
updating, and deleting records.
• Analytical (OLAP): Read intensive applications. Your end user
is more interested in analysis, reporting, forecasting, etc.
These kinds of databases have a less number of inserts and
updates. The main intention here is to fetch and analyze data
as fast as possible.
8 April 2020 How to Design a Good Database Code Factory
Database Functionality
8 April 2020 How to Design a Good Database Code Factory
Break Your Data Into Logical Pieces
• This rule is from the first rule of 1st normal form.
• If your queries are using too many string parsing functions
like substring, charindex, etc., then probably this rule needs
to be applied.
• Common Example, Name and Address Field
• Break this field into further logical pieces so that we can
write clean and optimal queries.
8 April 2020 How to Design a Good Database Code Factory
• This rule is from the second
rule of 1st normal form.
• Data stuffed with separators
need special attention and
should be to moved to a
different table
• Link them with keys for better
management.
Avoid Data with Separators
8 April 2020 How to Design a Good Database Code Factory
• Name and value tables
contains key and some data
associated with the key.
• Lookup Tables
• Differentiating the data
using a type field.
• Adding new type of does not
require to create new table.
Centralize Name Value Table Design
8 April 2020 How to Design a Good Database Code Factory
• Data with unlimited parent child
hierarchy.
• Consider a multi-level marketing
scenario where a sales person can
have multiple sales people below
them.
• Using a self-referencing primary key
and foreign key will simplify
database design.
Self-reference for Hierarchical Data
8 April 2020 How to Design a Good Database Code Factory
Database Design Tips
• Use English for table and field naming, all plural or all singular
• Use well defined and consistent names for tables and columns (e.g.
School, StudentCourse, CourseID ...)
• Don’t use unnecessary prefixes or suffixes for table names (i.e. use
School instead of TblSchool, SchoolTable etc.).
• Keep passwords as encrypted or hashed for security. Decrypt them in
application when required.
• Use integer id fields for all tables. If id is not required for the time
being, it may be required in the future (for association
tables, indexing ...).
8 April 2020 How to Design a Good Database Code Factory
Database Design Tips
• Choose columns with the integer data type (or its variants) for
indexing. varchar column indexing will cause performance problems.
• Use constraints (foreign key, check, not null ...) for data integrity.
Don’t give whole control to application code.
• Lack of database documentation is evil. Document your database
design with ER schemas and instructions. Also write comment lines
for your triggers, stored procedures and other scripts.
• Use indexes for frequently used queries on big tables.
• Place Image and blob data in separate tables.
8 April 2020 How to Design a Good Database Code Factory
Relational vs. NoSQL Databases
• Not every database fits every business need.
• Many companies rely on both relational and non-relational
databases for different tasks.
• NoSQL databases gained popularity for their speed and
scalability.
• There are still situations in which a highly structured SQL
database more preferable
8 April 2020 How to Design a Good Database Code Factory
• You need ACID compliancy
(Atomicity, Consistency,
Isolation, Durability).
• Your data is structured and
unchanging
• Standards-based proven
technology with good
developer experience and
support
• Storing large volumes of
data without structure.
• Using cloud computing and
storage. Easily spread data
across servers
• Simpler or looser project
objectives
• Rapid development, able to
start coding immediately
RDBMS
8 April 2020 How to Design a Good Database Code Factory
NoSQL
8 April 2020 How to Design a Good Database Code Factory
How to Design a GoodDatabase
8 April 2020 How to Design a Good Database Code Factory
Concepts to Master
• Conceptual Model
• Logical Model
• Physical Model
• Natural Key vs Surrogate Key
• Normalisasi vs. Denormalisasi
8 April 2020 How to Design a Good Database Code Factory
Requirements
• Perusahaan ada di beberapa lokasi.
• Setiap lokasi ada beberapa warehouse.
• Sistem harus mengetahui stok barang per warehouse.
• Ada beberapa jenis barang tersedia, misalkan raw material
dan finished goods.
• Sistem harus mencatat semua transaksi barang masuk.
• Sistem harus mencatat semua transaksi barang keluar.
• Sistem harus dapat mengeluarkan Laporan Kartu Stok.
8 April 2020 How to Design a Good Database Code Factory
We Will Need
• Locations entity (data lokasi)
• Warehouse entity (data gudang)
• Items entity (data barang)
• Item_Types entity (data jenis barang)
• Transactions entity (data transaksi)
• Transaction_Types entity (data jenis transaksi)
8 April 2020 How to Design a Good Database Code Factory
Conceptual Model
• Identifikasikan semua entitas (entity) yang terlibat dalam
sistem yang ingin dikembangkan.
• Buat Conceptual Model berupa relasi antar entitas tersebut.
• Gambarkan hanya relasi antar entitas tersebut, tidak
termasuk atribut dari entitas tersebut.
8 April 2020 How to Design a Good Database Code Factory
Conceptual Model
8 April 2020 How to Design a Good Database Code Factory
Logical Model
• Tambahkan attributes yang diperlukan oleh setiap entitas.
• Definisikan atribut yang bertindak sebagai PK, namun kita
tidak perlu mendefinisikan FK.
8 April 2020 How to Design a Good Database Code Factory
Logical Model
8 April 2020 How to Design a Good Database Code Factory
Physical Model
• Tentukan tipe data dari masing-masing kolom sesuai dengan
RDBMS yang kita pilih.
• Pemetakan relasi FK serta buat associative table untuk relasi
many-to-many.
8 April 2020 How to Design a Good Database Code Factory
Physical Model (IDEF1X)
8 April 2020 How to Design a Good Database Code Factory
Natural Key vs. Surrogate Key
• Ada kalanya sebuah tabel sudah memiliki kolom yang
nilainya unik untuk setiap baris (row)
• Kolom seperti ini disebut Natural Key, dan bisa kita jadikan
sebagai Primary Key.
• Best-practice tetap menambahkan Surrogate Key dan
menjadikannya sebagai Primary Key.
• Surrogate Key di-generate oleh database, biasanya berupa
field integer yang nilainya auto increment.
• Natural Key yang ada cukup sebagai unique index.
8 April 2020 How to Design a Good Database Code Factory
Normalisasi vs. Denormalisasi
• Normalization must be used as required, to optimize the
performance.
• Under-normalization will cause excessive repetition of data.
• Over-normalization will cause excessive joins across too
many tables.
• Both of them will get worse performance.
8 April 2020 How to Design a Good Database Code Factory
Thank You
8 April 2020 How to Design a Good Database Code Factory
BANTUTENAGA
MEDISLAWAN
CORONA !!!
Code Factory How to Design a Good Database
Rumah Komunitas mengajak teman-
teman ikut berpartisipasi dalam
program penggalangan dana untuk
pembuatan APD (Alat Pelindung Diri)
dan diproduksi di tempat konveksi
Rumah Komunitas.
Informasi Selengkapnya :
bit.ly/donasi-bersama-lawan-corona
#BersamaLawanCorona
#DiRumahAja
#StayAtHome
#WorkFromHome
8 April 2020 How to Design a Good Database Code Factory
About Me
• Telegram: @hidayat365
• PHP Indonesia for Student
https://t.me/PHPIDforStudent
• MySQL Indonesia
https://t.me/mysqlid
• Github
https://github.com/hidayat365
• This Slide
https://slideshare.net/hidayat365
Feedback
•Feedback https://bit.ly/phpom01-f
•Donasi https://bit.ly/donasi-bersama-lawan-
corona
8 April 2020 How to Design a Good Database Code Factory
Thank You
8 April 2020 How to Design a Good Database Code Factory

More Related Content

What's hot

MySQL conference 2010 ignite talk on InfiniDB
MySQL conference 2010 ignite talk on InfiniDBMySQL conference 2010 ignite talk on InfiniDB
MySQL conference 2010 ignite talk on InfiniDB
Calpont
 
The thinking persons guide to data warehouse design
The thinking persons guide to data warehouse designThe thinking persons guide to data warehouse design
The thinking persons guide to data warehouse design
Calpont
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2
Fabio Fumarola
 

What's hot (20)

MySQL conference 2010 ignite talk on InfiniDB
MySQL conference 2010 ignite talk on InfiniDBMySQL conference 2010 ignite talk on InfiniDB
MySQL conference 2010 ignite talk on InfiniDB
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Data dictionary pl17
Data dictionary pl17Data dictionary pl17
Data dictionary pl17
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Management
 
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databases
 
U-SQL Federated Distributed Queries (SQLBits 2016)
U-SQL Federated Distributed Queries (SQLBits 2016)U-SQL Federated Distributed Queries (SQLBits 2016)
U-SQL Federated Distributed Queries (SQLBits 2016)
 
SQL Server 2012 - Semantic Search
SQL Server 2012 - Semantic SearchSQL Server 2012 - Semantic Search
SQL Server 2012 - Semantic Search
 
Making MySQL Great For Business Intelligence
Making MySQL Great For Business IntelligenceMaking MySQL Great For Business Intelligence
Making MySQL Great For Business Intelligence
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented Databases
 
Microsoft's Hadoop Story
Microsoft's Hadoop StoryMicrosoft's Hadoop Story
Microsoft's Hadoop Story
 
Spark SQL Beyond Official Documentation
Spark SQL Beyond Official DocumentationSpark SQL Beyond Official Documentation
Spark SQL Beyond Official Documentation
 
Oracle
OracleOracle
Oracle
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
 
No sql
No sqlNo sql
No sql
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
 
The thinking persons guide to data warehouse design
The thinking persons guide to data warehouse designThe thinking persons guide to data warehouse design
The thinking persons guide to data warehouse design
 
Appache Cassandra
Appache Cassandra  Appache Cassandra
Appache Cassandra
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2
 

Similar to How to Design a Good Database

Data Con LA 2022 - Open Source Large Knowledge Graph Factory
Data Con LA 2022 - Open Source Large Knowledge Graph FactoryData Con LA 2022 - Open Source Large Knowledge Graph Factory
Data Con LA 2022 - Open Source Large Knowledge Graph Factory
Data Con LA
 
Data Science Machine Lerning Bigdat.pptx
Data Science Machine Lerning Bigdat.pptxData Science Machine Lerning Bigdat.pptx
Data Science Machine Lerning Bigdat.pptx
Priyadarshini648418
 
Not Your Father’s Data Warehouse: Breaking Tradition with Innovation
Not Your Father’s Data Warehouse: Breaking Tradition with InnovationNot Your Father’s Data Warehouse: Breaking Tradition with Innovation
Not Your Father’s Data Warehouse: Breaking Tradition with Innovation
Inside Analysis
 

Similar to How to Design a Good Database (20)

Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Build a modern data platform.pptx
Build a modern data platform.pptxBuild a modern data platform.pptx
Build a modern data platform.pptx
 
How to Survive as a Data Architect in a Polyglot Database World
How to Survive as a Data Architect in a Polyglot Database WorldHow to Survive as a Data Architect in a Polyglot Database World
How to Survive as a Data Architect in a Polyglot Database World
 
NoSQL
NoSQLNoSQL
NoSQL
 
Data Con LA 2022 - Open Source Large Knowledge Graph Factory
Data Con LA 2022 - Open Source Large Knowledge Graph FactoryData Con LA 2022 - Open Source Large Knowledge Graph Factory
Data Con LA 2022 - Open Source Large Knowledge Graph Factory
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
 
Data Lakehouse, Data Mesh, and Data Fabric (r1)
Data Lakehouse, Data Mesh, and Data Fabric (r1)Data Lakehouse, Data Mesh, and Data Fabric (r1)
Data Lakehouse, Data Mesh, and Data Fabric (r1)
 
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
 
Relational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsRelational data modeling trends for transactional applications
Relational data modeling trends for transactional applications
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
Big data by Mithlesh sadh
Big data by Mithlesh sadhBig data by Mithlesh sadh
Big data by Mithlesh sadh
 
php databse handling
php databse handlingphp databse handling
php databse handling
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
 
How to use Big Data and Data Lake concept in business using Hadoop and Spark...
 How to use Big Data and Data Lake concept in business using Hadoop and Spark... How to use Big Data and Data Lake concept in business using Hadoop and Spark...
How to use Big Data and Data Lake concept in business using Hadoop and Spark...
 
Data Science Machine Lerning Bigdat.pptx
Data Science Machine Lerning Bigdat.pptxData Science Machine Lerning Bigdat.pptx
Data Science Machine Lerning Bigdat.pptx
 
Democratizing Data Science in the Enterprise
Democratizing Data Science in the EnterpriseDemocratizing Data Science in the Enterprise
Democratizing Data Science in the Enterprise
 
Data Ingestion Engine
Data Ingestion EngineData Ingestion Engine
Data Ingestion Engine
 
Not Your Father’s Data Warehouse: Breaking Tradition with Innovation
Not Your Father’s Data Warehouse: Breaking Tradition with InnovationNot Your Father’s Data Warehouse: Breaking Tradition with Innovation
Not Your Father’s Data Warehouse: Breaking Tradition with Innovation
 
Chapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortalsChapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortals
 
Building a modern data platform with scala, akka, apache beam
Building a modern data platform with scala, akka, apache beamBuilding a modern data platform with scala, akka, apache beam
Building a modern data platform with scala, akka, apache beam
 

More from Nur Hidayat (7)

Develop a Software, Where to Start?
Develop a Software, Where to Start?Develop a Software, Where to Start?
Develop a Software, Where to Start?
 
PostgreSQL Advanced Queries
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced Queries
 
Seminar Android - Pengenalan PhoneGap
Seminar Android - Pengenalan PhoneGapSeminar Android - Pengenalan PhoneGap
Seminar Android - Pengenalan PhoneGap
 
Do IT with SQL
Do IT with SQLDo IT with SQL
Do IT with SQL
 
How to Become Great Programmer
How to Become Great ProgrammerHow to Become Great Programmer
How to Become Great Programmer
 
PHP Oracle
PHP OraclePHP Oracle
PHP Oracle
 
MRI Presentation
MRI PresentationMRI Presentation
MRI Presentation
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 

How to Design a Good Database

  • 1. How to Design a Good Database PHPID Online Meetup for COVID-19 8 April 2020 - https://zoom.us/j/510834649 8 April 2020 How to Design a Good Database Code Factory
  • 2. About Me • Editor PojokProgrammer.net • Writers welcome! • CEO Cronos Studio • Developers welcome! • Pegiat Komunitas • PHP Indonesia • MySQL Indonesia • Drupal Indonesia • VB.Net Indonesia How to Design a Good Database8 April 2020 Code Factory
  • 3. E-Commerce 8 April 2020 How to Design a Good Database Code Factory Social Media
  • 4. ERP Software 8 April 2020 How to Design a Good Database Code Factory
  • 5. Apa Persamaannya? 8 April 2020 How to Design a Good Database Code Factory
  • 6. GoodDesign Matters • Data are foundation of your application. • A well-designed database is easy to understand. • A well-designed database performs fast and efficient. 8 April 2020 How to Design a Good Database Code Factory Poorly Designed Database Poorly Designed Application Low Performance & Chaotic Data Difficult to Maintain & Enhance
  • 7. Agenda • Characteristics of Good Database Design • How to Design a Good Database • Case Study: Inventory System 8 April 2020 How to Design a Good Database Code Factory
  • 8. Are You Ready? 8 April 2020 How to Design a Good Database Code Factory
  • 9. Characteristics of GoodDatabase Design 8 April 2020 How to Design a Good Database Code Factory
  • 10. ThingsTo Consider • What Functionality is Needed from the Database? • Break Your Data Into Logical Pieces • Avoid Data Separated by Separators • Centralize Name Value Table Design • Self-reference PK And FK For Unlimited Hierarchical Data • Database Design Tips • Relational vs. NoSQL Databases 8 April 2020 How to Design a Good Database Code Factory
  • 11. Database Functionality • Transactional (OLTP): Write intensive application. Your end user is more interested in CRUD, i.e., creating, reading, updating, and deleting records. • Analytical (OLAP): Read intensive applications. Your end user is more interested in analysis, reporting, forecasting, etc. These kinds of databases have a less number of inserts and updates. The main intention here is to fetch and analyze data as fast as possible. 8 April 2020 How to Design a Good Database Code Factory
  • 12. Database Functionality 8 April 2020 How to Design a Good Database Code Factory
  • 13. Break Your Data Into Logical Pieces • This rule is from the first rule of 1st normal form. • If your queries are using too many string parsing functions like substring, charindex, etc., then probably this rule needs to be applied. • Common Example, Name and Address Field • Break this field into further logical pieces so that we can write clean and optimal queries. 8 April 2020 How to Design a Good Database Code Factory
  • 14. • This rule is from the second rule of 1st normal form. • Data stuffed with separators need special attention and should be to moved to a different table • Link them with keys for better management. Avoid Data with Separators 8 April 2020 How to Design a Good Database Code Factory
  • 15. • Name and value tables contains key and some data associated with the key. • Lookup Tables • Differentiating the data using a type field. • Adding new type of does not require to create new table. Centralize Name Value Table Design 8 April 2020 How to Design a Good Database Code Factory
  • 16. • Data with unlimited parent child hierarchy. • Consider a multi-level marketing scenario where a sales person can have multiple sales people below them. • Using a self-referencing primary key and foreign key will simplify database design. Self-reference for Hierarchical Data 8 April 2020 How to Design a Good Database Code Factory
  • 17. Database Design Tips • Use English for table and field naming, all plural or all singular • Use well defined and consistent names for tables and columns (e.g. School, StudentCourse, CourseID ...) • Don’t use unnecessary prefixes or suffixes for table names (i.e. use School instead of TblSchool, SchoolTable etc.). • Keep passwords as encrypted or hashed for security. Decrypt them in application when required. • Use integer id fields for all tables. If id is not required for the time being, it may be required in the future (for association tables, indexing ...). 8 April 2020 How to Design a Good Database Code Factory
  • 18. Database Design Tips • Choose columns with the integer data type (or its variants) for indexing. varchar column indexing will cause performance problems. • Use constraints (foreign key, check, not null ...) for data integrity. Don’t give whole control to application code. • Lack of database documentation is evil. Document your database design with ER schemas and instructions. Also write comment lines for your triggers, stored procedures and other scripts. • Use indexes for frequently used queries on big tables. • Place Image and blob data in separate tables. 8 April 2020 How to Design a Good Database Code Factory
  • 19. Relational vs. NoSQL Databases • Not every database fits every business need. • Many companies rely on both relational and non-relational databases for different tasks. • NoSQL databases gained popularity for their speed and scalability. • There are still situations in which a highly structured SQL database more preferable 8 April 2020 How to Design a Good Database Code Factory
  • 20. • You need ACID compliancy (Atomicity, Consistency, Isolation, Durability). • Your data is structured and unchanging • Standards-based proven technology with good developer experience and support • Storing large volumes of data without structure. • Using cloud computing and storage. Easily spread data across servers • Simpler or looser project objectives • Rapid development, able to start coding immediately RDBMS 8 April 2020 How to Design a Good Database Code Factory NoSQL
  • 21. 8 April 2020 How to Design a Good Database Code Factory
  • 22. How to Design a GoodDatabase 8 April 2020 How to Design a Good Database Code Factory
  • 23. Concepts to Master • Conceptual Model • Logical Model • Physical Model • Natural Key vs Surrogate Key • Normalisasi vs. Denormalisasi 8 April 2020 How to Design a Good Database Code Factory
  • 24. Requirements • Perusahaan ada di beberapa lokasi. • Setiap lokasi ada beberapa warehouse. • Sistem harus mengetahui stok barang per warehouse. • Ada beberapa jenis barang tersedia, misalkan raw material dan finished goods. • Sistem harus mencatat semua transaksi barang masuk. • Sistem harus mencatat semua transaksi barang keluar. • Sistem harus dapat mengeluarkan Laporan Kartu Stok. 8 April 2020 How to Design a Good Database Code Factory
  • 25. We Will Need • Locations entity (data lokasi) • Warehouse entity (data gudang) • Items entity (data barang) • Item_Types entity (data jenis barang) • Transactions entity (data transaksi) • Transaction_Types entity (data jenis transaksi) 8 April 2020 How to Design a Good Database Code Factory
  • 26. Conceptual Model • Identifikasikan semua entitas (entity) yang terlibat dalam sistem yang ingin dikembangkan. • Buat Conceptual Model berupa relasi antar entitas tersebut. • Gambarkan hanya relasi antar entitas tersebut, tidak termasuk atribut dari entitas tersebut. 8 April 2020 How to Design a Good Database Code Factory
  • 27. Conceptual Model 8 April 2020 How to Design a Good Database Code Factory
  • 28. Logical Model • Tambahkan attributes yang diperlukan oleh setiap entitas. • Definisikan atribut yang bertindak sebagai PK, namun kita tidak perlu mendefinisikan FK. 8 April 2020 How to Design a Good Database Code Factory
  • 29. Logical Model 8 April 2020 How to Design a Good Database Code Factory
  • 30. Physical Model • Tentukan tipe data dari masing-masing kolom sesuai dengan RDBMS yang kita pilih. • Pemetakan relasi FK serta buat associative table untuk relasi many-to-many. 8 April 2020 How to Design a Good Database Code Factory
  • 31. Physical Model (IDEF1X) 8 April 2020 How to Design a Good Database Code Factory
  • 32. Natural Key vs. Surrogate Key • Ada kalanya sebuah tabel sudah memiliki kolom yang nilainya unik untuk setiap baris (row) • Kolom seperti ini disebut Natural Key, dan bisa kita jadikan sebagai Primary Key. • Best-practice tetap menambahkan Surrogate Key dan menjadikannya sebagai Primary Key. • Surrogate Key di-generate oleh database, biasanya berupa field integer yang nilainya auto increment. • Natural Key yang ada cukup sebagai unique index. 8 April 2020 How to Design a Good Database Code Factory
  • 33. Normalisasi vs. Denormalisasi • Normalization must be used as required, to optimize the performance. • Under-normalization will cause excessive repetition of data. • Over-normalization will cause excessive joins across too many tables. • Both of them will get worse performance. 8 April 2020 How to Design a Good Database Code Factory
  • 34. Thank You 8 April 2020 How to Design a Good Database Code Factory
  • 35. BANTUTENAGA MEDISLAWAN CORONA !!! Code Factory How to Design a Good Database Rumah Komunitas mengajak teman- teman ikut berpartisipasi dalam program penggalangan dana untuk pembuatan APD (Alat Pelindung Diri) dan diproduksi di tempat konveksi Rumah Komunitas. Informasi Selengkapnya : bit.ly/donasi-bersama-lawan-corona #BersamaLawanCorona #DiRumahAja #StayAtHome #WorkFromHome
  • 36. 8 April 2020 How to Design a Good Database Code Factory
  • 37. About Me • Telegram: @hidayat365 • PHP Indonesia for Student https://t.me/PHPIDforStudent • MySQL Indonesia https://t.me/mysqlid • Github https://github.com/hidayat365 • This Slide https://slideshare.net/hidayat365
  • 39. Thank You 8 April 2020 How to Design a Good Database Code Factory

Editor's Notes

  1. Think outside the database. Try to think about what the website will need to do. For example, if a membership website is needed, the first instinct may be to begin thinking of all the data each user will need to store. Forget it, that’s for later. Rather, write down that users and their information will need to be stored in the database, and what else? What will those members need to do on the site? Will they make posts, upload files or photos, or send messages? Then the database will need a place for files/photos, posts, and messages.