Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Last active November 29, 2015 19:17
Show Gist options
  • Save stephlocke/c053c6fd383f810cc8ee to your computer and use it in GitHub Desktop.
Save stephlocke/c053c6fd383f810cc8ee to your computer and use it in GitHub Desktop.
Database Conceptual Diagram
library(data.table)
library(ggplot2)
ratio<-2/3
dblayout<-rbind(
data.table(level=4,colour='DB',name='Database', start=0 ,end=1),
data.table(level=3,colour='S', name='Schema' , start=0 ,end=ratio),
data.table(level=3,colour='S', name='...' , start=ratio ,end=1),
data.table(level=2,colour='T', name='Table' , start=0 ,end=ratio^2),
data.table(level=2,colour='T', name='...' , start=ratio^2,end=ratio),
data.table(level=1,colour='C', name='Key' , start=0 ,end=ratio^3),
data.table(level=1,colour='C', name='...' , start=ratio^3,end=ratio^2)
)
ggplot(dblayout
,aes(xmin=level-1,xmax=level,ymin=start,ymax=end, fill=colour))+
geom_rect(colour="white",size=3)+
coord_flip()+
geom_text(aes(x=level-0.5,y=start+.05,label=name)
,hjust=0,colour="white",size=13 )+
theme_void()+theme(legend.position="none") +
scale_fill_brewer(type = "qual",palette = 7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment