CREATE TABLE VxSegment_tab ( Id NUMBER NOT NULL, SegIndex NUMBER NOT NULL, SegmentationId NUMBER NOT NULL, StartPos NUMBER NOT NULL, EndPos NUMBER NOT NULL, CONSTRAINT VxSegment_pk PRIMARY KEY(Id), CONSTRAINT VxSegment_uniq UNIQUE(SegmentationId, SegIndex), CONSTRAINT VxSegment_fk FOREIGN KEY(SegmentationId) REFERENCES VxSegmentation_tab ON DELETE CASCADE ); CREATE SEQUENCE VxSegment_id INCREMENT BY 1 START WITH 1;
A segmentation consists on a list of segments. Segments are stored in the table VxSegment_tab. For each segment we store its index (the position where it appears in the segment list, beggining with 0), the Id of the segmentation it belongs to and its start and end time. An Id is also assigned to each segment. The sequence VxSegment_id is used to assign new Ids.
Query examples:
Select all segments from 'blocks' segmentation of 'friends418';
SQL> SELECT s.SegIndex, s.StartPos, s.EndPos, FROM VxSegmentation_tab seg, VxSegment_tab s WHERE (seg.Id = s.segmentationId) AND (seg.VideoName = 'friends418') AND (seg.Name = 'blocks');
Select segments that end before frame 50:
SQL> SELECT seg.VideoName, seg.Name, s.SegIndex, s.StartPos, s.EndPos FROM VxSegmentation_tab seg, VxSegment_tab s WHERE (seg.Id = s.segmentationId) AND (s.endPos < 50);