 --
 
 CREATE UNIQUE INDEX reading_id_idx ON "Reading" USING btree (reading_id);
+
+
+--
+-- Name: EventData_meter_data_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: sepgroup
+--
+
+ALTER TABLE ONLY "EventData"
+    ADD CONSTRAINT "EventData_meter_data_id_fkey" FOREIGN KEY (meter_data_id) REFERENCES "MeterData"(meter_data_id);
+
+
+--
+-- Name: Event_event_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: sepgroup
+--
+
+ALTER TABLE ONLY "Event"
+    ADD CONSTRAINT "Event_event_id_fkey" FOREIGN KEY (event_data_id) REFERENCES "EventData"(event_data_id) ON UPDATE CASCADE ON DELETE CASCADE;
 
 
 --

ALTER TABLE public."viewReadings" OWNER TO daniel;

--
-- Name: interval_id; Type: DEFAULT; Schema: public; Owner: sepgroup
--


CREATE TABLE "EventData" (
    end_time timestamp without time zone,
    number_events smallint,
    start_time timestamp without time zone,
    meter_data_id bigint,
    event_data_id bigint NOT NULL
);


