
CREATE TABLE "Events" (
	"Event_ID" INTEGER NOT NULL, 
	"Service_ID" INTEGER NOT NULL, 
	"Event_Details" VARCHAR(255), 
	PRIMARY KEY ("Event_ID"), 
	FOREIGN KEY("Service_ID") REFERENCES "Services" ("Service_ID")
)


CREATE TABLE "Participants" (
	"Participant_ID" INTEGER NOT NULL, 
	"Participant_Type_Code" CHAR(15) NOT NULL, 
	"Participant_Details" VARCHAR(255), 
	PRIMARY KEY ("Participant_ID")
)


CREATE TABLE "Participants_in_Events" (
	"Event_ID" INTEGER NOT NULL, 
	"Participant_ID" INTEGER NOT NULL, 
	PRIMARY KEY ("Event_ID", "Participant_ID"), 
	FOREIGN KEY("Participant_ID") REFERENCES "Participants" ("Participant_ID"), 
	FOREIGN KEY("Event_ID") REFERENCES "Events" ("Event_ID")
)


CREATE TABLE "Services" (
	"Service_ID" INTEGER NOT NULL, 
	"Service_Type_Code" CHAR(15) NOT NULL, 
	PRIMARY KEY ("Service_ID")
)

CREATE TABLE "Events" (
	"Event_ID" INTEGER NOT NULL, 
	"Service_ID" INTEGER NOT NULL, 
	"Event_Details" VARCHAR(255), 
	PRIMARY KEY ("Event_ID"), 
	FOREIGN KEY("Service_ID") REFERENCES "Services" ("Service_ID")
)

/*
2 rows from Events table:
Event_ID	Service_ID	Event_Details
3	5	Success
8	8	Success
*/


CREATE TABLE "Participants" (
	"Participant_ID" INTEGER NOT NULL, 
	"Participant_Type_Code" CHAR(15) NOT NULL, 
	"Participant_Details" VARCHAR(255), 
	PRIMARY KEY ("Participant_ID")
)

/*
2 rows from Participants table:
Participant_ID	Participant_Type_Code	Participant_Details
9	Organizer	Karlee Batz
26	Organizer	Vilma Schinner
*/


CREATE TABLE "Participants_in_Events" (
	"Event_ID" INTEGER NOT NULL, 
	"Participant_ID" INTEGER NOT NULL, 
	PRIMARY KEY ("Event_ID", "Participant_ID"), 
	FOREIGN KEY("Participant_ID") REFERENCES "Participants" ("Participant_ID"), 
	FOREIGN KEY("Event_ID") REFERENCES "Events" ("Event_ID")
)

/*
2 rows from Participants_in_Events table:
Event_ID	Participant_ID
3	26
3	66
*/


CREATE TABLE "Services" (
	"Service_ID" INTEGER NOT NULL, 
	"Service_Type_Code" CHAR(15) NOT NULL, 
	PRIMARY KEY ("Service_ID")
)

/*
2 rows from Services table:
Service_ID	Service_Type_Code
2	Marriage
5	Death Proof
*/
How many participants belong to the type 'Organizer'?
SELECT count(*) FROM participants WHERE participant_type_code  =  'Organizer'
[{'count(*)': 7}]