Sample Database
This commands below create the SQLite “projectdb2.db” database containing the tables projects, projectmgr, certification and earnedcerts. Inspect the schema creation statements to understand the structure of the database.
library(RSQLite)
# create a new in-memory database
dbcon <- dbConnect(RSQLite::SQLite(), ":memory:")
create table projectmgr (
pmid integer,
name text not null,
primary key (pmid)
)
create table certifications (
cid integer not null,
cert text not null,
body text not null,
primary key (cid)
)
create table earnedcerts (
pmid integer,
cert integer,
primary key (pmid,cert)
foreign key (pmid) references projectmgr(pmid)
foreign key (cert) references certifications(cid)
)
create table projects (
pid integer,
pname text default "No Name",
budget double default 0,
pmgr integer not null,
primary key (pid),
foreign key (pmgr) references projectmgr(pmid)
)
insert into certifications values
(1,"PMP","Project Management Institute"),
(2,"APM","Project Management Institute"),
(4,"CBAP","International Institute of Business Analysis"),
(5,"CIPM","American Academy of Project Management")
insert into projectmgr values
(11,"John Wu"),
(22,"Ann Molloy"),
(18,"Sandeep Ranghani"),
(19,"Alicia Knauss"),
(38,"Roxanna da Silva"),
(23,"Wagner Ormond"),
(47,"Margaret O'Shea"),
(20,"Alden White")
insert into earnedcerts values
(11,1),
(11,4),
(18,1),
(22,1),
(47,1),
(20,1),
(20,4),
(38,5)
insert into projects values
(100,"GOTAM",350000,11),
(200,"Data Twist",875000,20),
(300,"Alpha Launch",12500,18),
(302,"Alpha Arch Design",38000,18),
(303,"Alpha Dev",125000,18),
(305,"Alpha Analytics Dashboard",235000,38),
(811,"Bootstrap Demo",0,47)
LS0tCnRpdGxlOiAiUHJhY3RpY2UgUXVlcmllcyBmb3IgU1FMIEkiCnBhcmFtczoKICBjYXRlZ29yeTogNzAKICBudW1iZXI6IDEwOQogIHRpbWU6IDQ1CiAgbGV2ZWw6IGJlZ2lubmVyCiAgdGFnczogInNxbCxqb2lucyxncm91cCBieSIKICBkZXNjcmlwdGlvbjogIlVzZXMgZXhhbXBsZXMgdG8gZXhwbGFpbiB0aGUgYmFzaWMgcXVlcnkgc3RydWN0dXJlIG9mIFNRTAogICAgICAgICAgICAgIC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