Decoupling in RDBMS

Muhammad Tri Wibowo
2 min readApr 25, 2021

--

Insight :

https://www.sqlservercentral.com/articles/decoupling-in-relational-databases

https://dba.stackexchange.com/questions/71361/how-to-join-3-tables-together-given-2-many-to-many-relationships-tables-in-betwe

Example case :

Given tables as below

Buku (Book), Penerbit (Publisher), Pengarang (Author), Alamat (Address)
Relasitabel (Tablerelation / decouple)

Show all data detail of book (Judul, Harga, Nama Pengarang, NamaPenerbit, Nama Jalan [Penerbit], Kode Pos [Penerbit]) from following tables

Solution :

Select BK.Judul, BK.Harga, PG.NamaPengarang, PN.NamaPenerbit, AL.NamaJalan, AL.Kodepos
From buku BK
left join relasitabel RT_PG on RT_PG.key2=BK.BukuId and RT_PG.LinkName = 'Pengarang-Buku'
left join pengarang PG on RT_PG.key1=PG.PengarangId
left join relasitabel RT_PN on BK.BukuId=RT_PN.key2 and RT_PN.LinkName = 'Penerbit-Buku'
left join penerbit PN on RT_PN.key1 = PN.PenerbitId
left join relasitabel RT_AL on RT_AL.key2=PN.PenerbitId and RT_AL.LinkName = 'Alamat-Penerbit'
left join alamat AL on RT_AL.key1=Al.AlamatId

--

--

No responses yet