SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Database Design
How to Design a Good Database
for Your Great Application
Seminar Program Studi Manajeman Informatika
18 April 2018 - AMIK BSI Kampus Salemba
About Me
• Editor PojokProgrammer.net
• Writers welcome!
• CEO BiruniLabs
• Trainers welcome!
• CEO Cronos Studio
• Developers welcome!
• Pegiat Komunitas
• PHP Indonesia
• Drupal Indonesia
• VB.Net Indonesia
How to Design a Good Database
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
Prepared for
AMIK BSI Salemba
E-Commerce
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Social Media
Prepared for
AMIK BSI Salemba
ERP Software
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Apa Persamaannya?
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Good Design Matters
• Data are foundation of your application.
• A well designed database is easy to understand.
• A well designed database performs fast and efficient.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Poorly
Designed
Database
Poorly
Designed
Application
Low
Performance &
Chaotic Data
Difficult to
Maintain &
Enhance
AMIK BSI Salemba
Agenda
•Characteristics of Good Database Design
•How to Design a Good Database
•Case Study: Inventory System
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Are You Ready?
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Characteristics of Good
Database Design
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Things To 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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Database Functionality
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
• 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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
• 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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
• 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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
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 ...).
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
• 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
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
NoSQL
Prepared for
AMIK BSI Salemba
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
How to Design
a Good Database
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Concepts to Master
• Conceptual Model
• Logical Model
• Physical Model
• Natural Key vs Surrogate Key
• Normalisasi vs. Denormalisasi
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
• 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.
Conceptual Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
• Tambahkan
attributes yang
diperlukan oleh
setiap entitas.
• Definisikan atribut
yang bertindak
sebagai PK, namun
kita tidak perlu
mendefinisikan FK.
Logical Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
• 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.
Physical Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Case Study:
Inventory System
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Things To Do
• Requirements
• Conceptual Model
• Logical Model
• Physical Model
• Change Your Mindset
• SQL Rule of Thumb
• Data Retrieval using SELECT
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
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)
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Conceptual Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Logical Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Physical Model
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Data Retrieval using SELECT
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
SQL Rule of Thumb
• Use single SQL statement whenever possible
• Use PL/SQL or Stored Procedure
• Use Java (or other programming language)
• Rethink why you want to do it (refine your approach)
From Tom Kyte (Oracle Evangelist)
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Change Your Mindset
• Apa yang akan kalian lakukan jika mendapatkan tugas seperti
di bawah ini
• Tampilkan angka 1 sampai dengan 100, namun…
• setiap kelipatan 3 ubah angkanya menjadi kata Rumah,
• setiap kelipatan 5 ubah angkanya menjadi kata Sakit, dan
• setiap kelipatan 15 ubah angkanya menjadi kata Rumah Sakit.
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Solution
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
SELECT t.id AS trans_id, t.trans_code AS trans_code
, t.trans_date AS trans_date, a.id AS detail_id, a.item_id
, trim(concat(t.remarks,' - ',a.remarks)) AS remarks,
b.code AS item_code, b.name AS item_name
, CASE
WHEN t.type_id=1 THEN a.quantity
WHEN t.type_id=2 THEN -a.quantity
ELSE 0 END
AS quantity
, @sal := @sal + CASE
WHEN t.type_id=1 THEN a.quantity
WHEN t.type_id=2 THEN -a.quantity
ELSE 0 END
AS saldo
FROM transactions t
JOIN transaction_details a ON t.id = a.trans_id
JOIN items b ON a.item_id = b.id
JOIN ( SELECT @sal:=0 ) v
WHERE b.id = :id
ORDER BY t.trans_date, t.id, a.id
Query for Stock Card
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Prepared for
AMIK BSI Salemba
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba
Contact Us
• Telegram: @hidayat365
• PHP Indonesia for Student https://t.me/PHPIDforStudent
• MySQL Indonesia https://t.me/mysqlid
• Github: https://github.com/hidayat365
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database
Link Quesioner (wajib):
http://tiny.cc/bsikuesioner
AMIK BSI Salemba
Thank You
Created by Nur Hidayat
(nur.hidayat@cronosstudio.id)
How to Design a Good Database AMIK BSI Salemba

Más contenido relacionado

La actualidad más candente

Build a modern data platform.pptx
Build a modern data platform.pptxBuild a modern data platform.pptx
Build a modern data platform.pptxIke Ellis
 
Demystifying data engineering
Demystifying data engineeringDemystifying data engineering
Demystifying data engineeringThang Bui (Bob)
 
Chapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsChapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsnehabsairam
 
What is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremWhat is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremRahul Jain
 
Tableau on Hadoop Meet Up: Advancing from Extracts to Live Connect
Tableau on Hadoop Meet Up: Advancing from Extracts to Live ConnectTableau on Hadoop Meet Up: Advancing from Extracts to Live Connect
Tableau on Hadoop Meet Up: Advancing from Extracts to Live ConnectRemy Rosenbaum
 
60 reporting tips in 60 minutes - SQLBits 2018
60 reporting tips in 60 minutes - SQLBits 201860 reporting tips in 60 minutes - SQLBits 2018
60 reporting tips in 60 minutes - SQLBits 2018Ike Ellis
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Managementsameerfaizan
 
How to obtain the Cloudera Data Engineer Certification
How to obtain the Cloudera Data Engineer CertificationHow to obtain the Cloudera Data Engineer Certification
How to obtain the Cloudera Data Engineer Certificationelephantscale
 
Hadoop and IDW - When_to_use_which
Hadoop and IDW - When_to_use_whichHadoop and IDW - When_to_use_which
Hadoop and IDW - When_to_use_whichDan TheMan
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sqldeathsubte
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageBethmi Gunasekara
 
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 mortalsnehabsairam
 
Database awareness
Database awarenessDatabase awareness
Database awarenesskloia
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databasesAshwani Kumar
 
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/2Fabio Fumarola
 
Building next generation data warehouses
Building next generation data warehousesBuilding next generation data warehouses
Building next generation data warehousesAlex Meadows
 
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"DataConf
 

La actualidad más candente (19)

Build a modern data platform.pptx
Build a modern data platform.pptxBuild a modern data platform.pptx
Build a modern data platform.pptx
 
Demystifying data engineering
Demystifying data engineeringDemystifying data engineering
Demystifying data engineering
 
Chapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsChapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortals
 
What is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremWhat is NoSQL and CAP Theorem
What is NoSQL and CAP Theorem
 
Tableau on Hadoop Meet Up: Advancing from Extracts to Live Connect
Tableau on Hadoop Meet Up: Advancing from Extracts to Live ConnectTableau on Hadoop Meet Up: Advancing from Extracts to Live Connect
Tableau on Hadoop Meet Up: Advancing from Extracts to Live Connect
 
60 reporting tips in 60 minutes - SQLBits 2018
60 reporting tips in 60 minutes - SQLBits 201860 reporting tips in 60 minutes - SQLBits 2018
60 reporting tips in 60 minutes - SQLBits 2018
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Management
 
How to obtain the Cloudera Data Engineer Certification
How to obtain the Cloudera Data Engineer CertificationHow to obtain the Cloudera Data Engineer Certification
How to obtain the Cloudera Data Engineer Certification
 
Hadoop and IDW - When_to_use_which
Hadoop and IDW - When_to_use_whichHadoop and IDW - When_to_use_which
Hadoop and IDW - When_to_use_which
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sql
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data Storage
 
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
 
Database awareness
Database awarenessDatabase awareness
Database awareness
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databases
 
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
 
Building next generation data warehouses
Building next generation data warehousesBuilding next generation data warehouses
Building next generation data warehouses
 
Rdbms vs. no sql
Rdbms vs. no sqlRdbms vs. no sql
Rdbms vs. no sql
 
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"
Eugene Polonichko "Azure Data Lake: what is it? why is it? where is it?"
 
Apache Drill at ApacheCon2014
Apache Drill at ApacheCon2014Apache Drill at ApacheCon2014
Apache Drill at ApacheCon2014
 

Similar a How to Design a Good Database for Your Application

Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
Evolution of Distributed Database Technologies in the Digital era
Evolution of Distributed Database Technologies in the Digital eraEvolution of Distributed Database Technologies in the Digital era
Evolution of Distributed Database Technologies in the Digital eraVishal Puri
 
Pr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open sourcePr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open sourceTerry Bunio
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDBMongoDB
 
Conceptual vs. Logical vs. Physical Data Modeling
Conceptual vs. Logical vs. Physical Data ModelingConceptual vs. Logical vs. Physical Data Modeling
Conceptual vs. Logical vs. Physical Data ModelingDATAVERSITY
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...Amazon Web Services
 
SQL, NoSQL, BigData in Data Architecture
SQL, NoSQL, BigData in Data ArchitectureSQL, NoSQL, BigData in Data Architecture
SQL, NoSQL, BigData in Data ArchitectureVenu Anuganti
 
How to Achieve Scale with MongoDB
How to Achieve Scale with MongoDBHow to Achieve Scale with MongoDB
How to Achieve Scale with MongoDBMongoDB
 
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriar
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriarAdf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriar
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriarNilesh Shah
 
Engineering patterns for implementing data science models on big data platforms
Engineering patterns for implementing data science models on big data platformsEngineering patterns for implementing data science models on big data platforms
Engineering patterns for implementing data science models on big data platformsHisham Arafat
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabasesAdi Challa
 
Alex mang patterns for scalability in microsoft azure application
Alex mang   patterns for scalability in microsoft azure applicationAlex mang   patterns for scalability in microsoft azure application
Alex mang patterns for scalability in microsoft azure applicationCodecamp Romania
 
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...Michael Rys
 
Boosting the Performance of your Rails Apps
Boosting the Performance of your Rails AppsBoosting the Performance of your Rails Apps
Boosting the Performance of your Rails AppsMatt Kuklinski
 
Data Lakehouse, Data Mesh, and Data Fabric (r2)
Data Lakehouse, Data Mesh, and Data Fabric (r2)Data Lakehouse, Data Mesh, and Data Fabric (r2)
Data Lakehouse, Data Mesh, and Data Fabric (r2)James Serra
 
When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...MongoDB
 

Similar a How to Design a Good Database for Your Application (20)

Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Evolution of Distributed Database Technologies in the Digital era
Evolution of Distributed Database Technologies in the Digital eraEvolution of Distributed Database Technologies in the Digital era
Evolution of Distributed Database Technologies in the Digital era
 
Pr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open sourcePr dc 2015 sql server is cheaper than open source
Pr dc 2015 sql server is cheaper than open source
 
Scalable web architecture
Scalable web architectureScalable web architecture
Scalable web architecture
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
Conceptual vs. Logical vs. Physical Data Modeling
Conceptual vs. Logical vs. Physical Data ModelingConceptual vs. Logical vs. Physical Data Modeling
Conceptual vs. Logical vs. Physical Data Modeling
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
 
SQL, NoSQL, BigData in Data Architecture
SQL, NoSQL, BigData in Data ArchitectureSQL, NoSQL, BigData in Data Architecture
SQL, NoSQL, BigData in Data Architecture
 
How to Achieve Scale with MongoDB
How to Achieve Scale with MongoDBHow to Achieve Scale with MongoDB
How to Achieve Scale with MongoDB
 
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriar
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriarAdf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriar
Adf and ala design c sharp corner toronto chapter feb 2019 meetup nik shahriar
 
Couchbase 3.0.2 d1
Couchbase 3.0.2  d1Couchbase 3.0.2  d1
Couchbase 3.0.2 d1
 
Engineering patterns for implementing data science models on big data platforms
Engineering patterns for implementing data science models on big data platformsEngineering patterns for implementing data science models on big data platforms
Engineering patterns for implementing data science models on big data platforms
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
 
Alex mang patterns for scalability in microsoft azure application
Alex mang   patterns for scalability in microsoft azure applicationAlex mang   patterns for scalability in microsoft azure application
Alex mang patterns for scalability in microsoft azure application
 
Future career goals in it
Future career goals in itFuture career goals in it
Future career goals in it
 
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
 
Boosting the Performance of your Rails Apps
Boosting the Performance of your Rails AppsBoosting the Performance of your Rails Apps
Boosting the Performance of your Rails Apps
 
Data Lakehouse, Data Mesh, and Data Fabric (r2)
Data Lakehouse, Data Mesh, and Data Fabric (r2)Data Lakehouse, Data Mesh, and Data Fabric (r2)
Data Lakehouse, Data Mesh, and Data Fabric (r2)
 
NoSql Brownbag
NoSql BrownbagNoSql Brownbag
NoSql Brownbag
 
When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...
 

Más de Nur Hidayat

Develop a Software, Where to Start?
Develop a Software, Where to Start?Develop a Software, Where to Start?
Develop a Software, Where to Start?Nur Hidayat
 
PostgreSQL Advanced Queries
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced QueriesNur Hidayat
 
Seminar Android - Pengenalan PhoneGap
Seminar Android - Pengenalan PhoneGapSeminar Android - Pengenalan PhoneGap
Seminar Android - Pengenalan PhoneGapNur Hidayat
 
How to Become Great Programmer
How to Become Great ProgrammerHow to Become Great Programmer
How to Become Great ProgrammerNur Hidayat
 
MRI Presentation
MRI PresentationMRI Presentation
MRI PresentationNur Hidayat
 

Más de 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
 

Último

Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxUnduhUnggah1
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxdolaknnilon
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 

Último (20)

Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docx
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptx
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 

How to Design a Good Database for Your Application

  • 1. Database Design How to Design a Good Database for Your Great Application Seminar Program Studi Manajeman Informatika 18 April 2018 - AMIK BSI Kampus Salemba
  • 2. About Me • Editor PojokProgrammer.net • Writers welcome! • CEO BiruniLabs • Trainers welcome! • CEO Cronos Studio • Developers welcome! • Pegiat Komunitas • PHP Indonesia • Drupal Indonesia • VB.Net Indonesia How to Design a Good Database Created by Nur Hidayat (nur.hidayat@cronosstudio.id) Prepared for AMIK BSI Salemba
  • 3. E-Commerce Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Social Media Prepared for AMIK BSI Salemba
  • 4. ERP Software Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 5. Apa Persamaannya? Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 6. Good Design Matters • Data are foundation of your application. • A well designed database is easy to understand. • A well designed database performs fast and efficient. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Poorly Designed Database Poorly Designed Application Low Performance & Chaotic Data Difficult to Maintain & Enhance AMIK BSI Salemba
  • 7. Agenda •Characteristics of Good Database Design •How to Design a Good Database •Case Study: Inventory System Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 8. Are You Ready? Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 9. Characteristics of Good Database Design Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 10. Things To 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 12. Database Functionality Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 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 ...). Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 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 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database NoSQL Prepared for AMIK BSI Salemba
  • 21. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 22. How to Design a Good Database Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 23. Concepts to Master • Conceptual Model • Logical Model • Physical Model • Natural Key vs Surrogate Key • Normalisasi vs. Denormalisasi Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 24. • 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. Conceptual Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 25. • Tambahkan attributes yang diperlukan oleh setiap entitas. • Definisikan atribut yang bertindak sebagai PK, namun kita tidak perlu mendefinisikan FK. Logical Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 26. • 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. Physical Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 27. 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 28. 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 29. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 30. Case Study: Inventory System Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 31. Things To Do • Requirements • Conceptual Model • Logical Model • Physical Model • Change Your Mindset • SQL Rule of Thumb • Data Retrieval using SELECT Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 32. 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. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 33. 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) Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 34. Conceptual Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 35. Logical Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 36. Physical Model Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 37. Data Retrieval using SELECT Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 38. SQL Rule of Thumb • Use single SQL statement whenever possible • Use PL/SQL or Stored Procedure • Use Java (or other programming language) • Rethink why you want to do it (refine your approach) From Tom Kyte (Oracle Evangelist) Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 39. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 40. Change Your Mindset • Apa yang akan kalian lakukan jika mendapatkan tugas seperti di bawah ini • Tampilkan angka 1 sampai dengan 100, namun… • setiap kelipatan 3 ubah angkanya menjadi kata Rumah, • setiap kelipatan 5 ubah angkanya menjadi kata Sakit, dan • setiap kelipatan 15 ubah angkanya menjadi kata Rumah Sakit. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 41. Solution Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 42. SELECT t.id AS trans_id, t.trans_code AS trans_code , t.trans_date AS trans_date, a.id AS detail_id, a.item_id , trim(concat(t.remarks,' - ',a.remarks)) AS remarks, b.code AS item_code, b.name AS item_name , CASE WHEN t.type_id=1 THEN a.quantity WHEN t.type_id=2 THEN -a.quantity ELSE 0 END AS quantity , @sal := @sal + CASE WHEN t.type_id=1 THEN a.quantity WHEN t.type_id=2 THEN -a.quantity ELSE 0 END AS saldo FROM transactions t JOIN transaction_details a ON t.id = a.trans_id JOIN items b ON a.item_id = b.id JOIN ( SELECT @sal:=0 ) v WHERE b.id = :id ORDER BY t.trans_date, t.id, a.id Query for Stock Card Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Prepared for AMIK BSI Salemba
  • 43. Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba
  • 44. Contact Us • Telegram: @hidayat365 • PHP Indonesia for Student https://t.me/PHPIDforStudent • MySQL Indonesia https://t.me/mysqlid • Github: https://github.com/hidayat365 Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database Link Quesioner (wajib): http://tiny.cc/bsikuesioner AMIK BSI Salemba
  • 45. Thank You Created by Nur Hidayat (nur.hidayat@cronosstudio.id) How to Design a Good Database AMIK BSI Salemba