|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78530 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . gen
From: afojgo_at_[hidden]
Date: 2012-05-21 13:46:11
Author: jofaber
Date: 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
New Revision: 78530
URL: http://svn.boost.org/trac/boost/changeset/78530
Log:
Started Db Generator
Added:
sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.cpp (contents, props changed)
Binary files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/MakeTyExDagObjects.sql | 465 +++++++--------------------------------
sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql | 423 +++++++++++++++++++++++++++++++++--
sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 16 +
sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.h | 56 ++--
sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 10
5 files changed, 527 insertions(+), 443 deletions(-)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/MakeTyExDagObjects.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/MakeTyExDagObjects.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/MakeTyExDagObjects.sql 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -5,398 +5,103 @@
drop table Vertex;
drop table Edge;
drop table Object;
-drop table Relation;
create table TypeTraits (key integer primary key, name varchar);
create table ObjectType (key integer primary key, traits integer, name varchar);
create table EdgeType (key integer primary key, refSourceType integer, refRelationType integer, refTargetType integer, name varchar);
create table Vertex (key integer primary key, refObjectType integer, refObject integer);
create table Edge (key integer primary key, refEdgeType integer, refSourceVertex integer, refTargetVertex integer, refObject integer);
+
+-- Object is hardly a new entity of its own. It builds the disjoint union of
+-- Vertex and Edge Key.
+-- {Object.keys} == {V.keys} + {E,keys} +:set union
+-- {} == {V.keys} & {E,keys} &:set intersection
create table Object (key integer primary key);
-create table Attribute (key integer primary key, refObjectType integer, name varchar);
+create table Attribute (key integer primary key, refObjectType integer, name varchar);
create table IntObject (refObject integer, refAttribute integer, value integer, primary key (refObject, refAttribute));
create table VarCharObject (refObject integer, refAttribute integer, value varchar, primary key (refObject, refAttribute));
+-- The creation sequence and systematics for generating example entities:
+-- To add an album with titles, recordings and locations
+-- we proceed from elemetal, independent, not refering entities
+-- to those that contain references to other entities
+
+-- Example Album: Abbey Road.
+
+-- add genre ...
+-- add Beat
+-- add Obj, Vtx, Name
+
+-- add artists
+-- add John Lennon T(1) v(15)
+-- add Obj(15), Vtx(15,1,15), VarCharObject(15, 1, J.L)
+-- IntObject(15, 2,1940)
+-- add Paul McCartney
+-- add Obj(16), Vtx(16,1,16), VarCharObject(16, 1, P.McC)
+-- IntObject(16, 2, 1942)
+-- add Geroge Harrison
+-- add Obj(17), Vtx(17,1,17), VarCharObject(17, 1, G.H.)
+-- IntObject(17, 2, 1943)
+-- add Ringo Starr
+-- add Obj(18), Vtx(18,1,18), VarCharObject(18, 1, R.S.)
+-- IntObject(18, 2, 1940)
+
+-- add titles
+-- add Come Together
+-- add Obj(19), Vtx(19,2,19), VarCharObject(19,1,C.T.),
+-- YoC:IntObject(19,2,1969)
+-- add Something
+-- add Obj(20), Vtx(20,2,20), VarCharObject(20,1,Sth.),
+-- YoC:IntObject(20,2,1968)
+
+-- add album
+-- add Obj(21), Vtx(21,10,21), VarCharObject(21,1,Abbey Rd.),
+-- IntObject(21,2,1969)
+
+-- add recordings
+-- add Obj(22), Vtx(22,3,22), VarCharObject(22,1,Aby.Rd: Come Together),
+-- VarCharObject(22,4,#1),
+-- VarCharObject(22,3,"04:20"),
+
+-- add recordings
+-- add Obj(23), Vtx(23,3,23), VarCharObject(23,1,Aby.Rd: Something),
+-- VarCharObject(23,4,#2),
+-- VarCharObject(23,3,"03:03"),
+
+-- === EDGES
+-- add artist composed title relation
+-- add Obj(24)
+-- add Edge(24): composed(ET:1(VT:1,RT:6,VT:2)), J.L.(15), C.T.(19), obj(24)
+-- = Edge(24,1,15,19,24)
+-- add Obj(25)
+-- add Edge(25): composed(ET:1(VT:1,RT:6,VT:2)), P.McC.(16), C.T.(19), obj(25)
+-- = Edge(25,1,16,19,25)
+
+-- add album contains recording
+-- add Obj(26)
+-- add Edge(26): contains(ET:5(VT:10,RT:11,VT:3)), AbyRd(21), AbR:C.T.(22), obj(26)
+-- = Edge(26,5,21,22,26)
+-- add Obj(27)
+-- add Edge(27): contains(ET:5(VT:10,RT:11,VT:3)), AbyRd(21), AbR:S.th.(23), obj(27)
+-- = Edge(27,5,21,23,27)
+
+-- add title recorded as recording
+-- add Obj(28)
+-- add Edge(28): recorded_as(ET:3(VT:2,RT:8,VT:3)), AbR:C.T.(22), ComeTgthr(19), obj(28)
+-- = Edge(28,3,22,19,28)
+-- add Obj(29)
+-- add Edge(29): recorded_as(ET:3(VT:2,RT:8,VT:3)), AbR:C.T.(22), Someth.(20), obj(29)
+-- = Edge(29,3,22,20,29)
+
+-- add artist performed on album
+-- add Obj(30)
+-- add Edge(30): performed_on(ET:2(VT:1,RT:7,VT:10)), J.L.(15), AbyRd(21), obj(30)
+-- = Edge(30,2,15,21,30)
+-- add Obj(31)
+-- add Edge(31): performed_on(ET:2(VT:1,RT:7,VT:10)), P.McC(16), AbyRd(21), obj(31)
+-- = Edge(31,2,16,21,31)
--- -----------------------------------------------------------------------------
-insert into TypeTraits values (0, 'atom obj');
-insert into TypeTraits values (1, 'comp obj');
-insert into TypeTraits values (2, 'atom rel');
-
-insert into ObjectType values (0, 0, 'Nil');
-insert into ObjectType values (1, 0, 'a:artist');
-insert into ObjectType values (2, 0, 'a:title');
-insert into ObjectType values (3, 0, 'a:recording');
-insert into ObjectType values (4, 0, 'c:artists');
-insert into ObjectType values (5, 1, 'c:genre');
-insert into ObjectType values (6, 2, 'r:composed');
-insert into ObjectType values (7, 2, 'r:performed');
-insert into ObjectType values (8, 2, 'r:recorded as');
-insert into ObjectType values (9, 2, 'r:located at');
-insert into ObjectType values (10, 0, 'c:album');
-insert into ObjectType values (11, 2, 'r:contains');
-
-insert into EdgeType values (1, 1, 6, 2, 'artist composed title' );
-insert into EdgeType values (2, 1, 7, 3, 'artist performed record' );
-insert into EdgeType values (3, 2, 8, 3, 'title recorded as record');
-insert into EdgeType values (4, 3, 9, 4, 'record located at url' );
-insert into EdgeType values (5, 10, 11, 3, 'album contains record' );
-
-insert into Object values (0);
-
-insert into Object values (1);
-insert into Attribute values (1, "Name");
-insert into VarCharObject values (1, 1, "Charlie Haden");
-
-insert into Object values (2);
-insert into VarCharObject values (2, 1, "Kenny Barron");
-
-insert into Object values (3);
-insert into VarCharObject values (3, 1, "Jonny Green");
-
-insert into Object values (4);
-insert into VarCharObject values (4, 1, "Twighlight Song");
-
-insert into Object values (5);
-insert into VarCharObject values (5, 1, "Body & Soul");
-
-insert into Object values (6);
-insert into VarCharObject values (6, 1, "composed in 1995");
-
-insert into Object values (7);
-insert into VarCharObject values (7, 1, "composed in 1930");
-
-insert into Object values (8);
-insert into VarCharObject values (8, 1, "N&tC: Twighlight Song");
-
-insert into Object values (9);
-insert into VarCharObject values (9, 1, "N&tC: Body & Soul");
-
-insert into Object values (10);
-insert into VarCharObject values (10, 1, "Night & the City");
-
-
-insert into Vertex values (0, 0, 0);
-insert into Vertex values (1, 1, 1);
-insert into Vertex values (2, 1, 2);
-insert into Vertex values (3, 1, 3);
-insert into Vertex values (4, 2, 4);
-insert into Vertex values (5, 2, 5);
-insert into Vertex values (8, 3, 8);
-insert into Vertex values (9, 3, 9);
-insert into Vertex values (10, 3, 10);
-
-insert into Edge values (1, 1, 1, 4, 6);
--- 2:key 1:composed 3:J.Green 5:Body&Soul 7:comp1930
-insert into Edge values (2, 1, 3, 5, 7);
-
--- 3:key 2:performed 2:K.Barron 10:N&tC 11:rec1996
-insert into Edge values (3, 2, 2, 10, 11);
--- 4:key 7:performed 1:C.Haden 10:N&tC
-insert into Edge values (4, 2, 1, 10, 11);
-
-insert into Object values (11);
-insert into VarCharObject values (11, 1, "recoreded 1996");
-
-
--- -------------------------------------
--- Dag Related Architecture Linking All
--- D R A C U L A
--- -------------------------------------------------------
--- Dag Related Architecture Using Links All over the place
--- D R A C U L A
-
--- -----------------------------------------------------------------------------
--- Check for EdgeTypes
-create view EdgeTypeCheck as
-select
- (select ObjectType.name from ObjectType where ObjectType.key = EdgeType.refSourceType) as SrcT,
- (select ObjectType.name from ObjectType where ObjectType.key = EdgeType.refRelationType) as RelT,
- ObjectType.name as TrgT,
- EdgeType.name
-from EdgeType
- inner join ObjectType on EdgeType.refTargetType = ObjectType.key
-
--- -----------------------------------------------------------------------------
--- Named Objects
-create view NamedObjects as
-select Object.key as Obj, VarCharObject.value as Name
-from Object
- inner join VarCharObject on VarCharObject.refObject = Object.key
-
--- -----------------------------------------------------------------------------
--- Named Objects 1:1 Attributes joined horizontally.
-select Object.key as Obj, Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
-from Object
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
- -- and so on ...
-
--- -----------------------------------------------------------------------------
--- Named Objects and Types 1:1 Attributes joined horizontally.
-select Object.key as Obj, Vertex.refObjectType as Type, Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
-from Object
- inner join Vertex on Vertex.refObject = Object.key and Type = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
-
-
--- -----------------------------------------------------------------------------
--- Vertexes
-select Vertex.key as Vtx, Object.key as Obj, ObjectType.Name as Type , Attribute.Name as Attr,
- VarCharObject.Value as Name, IntObject.value as Year
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key
- inner join Attribute on VarCharObject.refAttribute = Attribute.key
- inner join VarCharObject on VarCharObject.refObject = Object.key
- left outer join IntObject on IntObject.refObject = Object.key
-
--- -----------------------------------------------------------------------------
--- Edge-Objects and associated values
-select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type , Attribute.Name as Attr,
- VarCharObject.Value as Name, IntObject.value as Year
-from Object
- inner join Edge on Edge.refObject = Object.key
- inner join EdgeType on Edge.refEdgeType = EdgeType.key
- inner join Attribute on VarCharObject.refAttribute = Attribute.key
- inner join VarCharObject on VarCharObject.refObject = Object.key
- left outer join IntObject on IntObject.refObject = Object.key
-
--- -----------------------------------------------------------------------------
--- Edges
-select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type,
- VarCharObject.value as Name, IntObject.value as Year
-from Object
- inner join Edge on Edge.refObject = Object.key
- inner join EdgeType on Edge.refEdgeType = EdgeType.key
- inner join VarCharObject on VarCharObject.refObject = Object.key
- left outer join IntObject on IntObject.refObject = Object.key
-
--- -----------------------------------------------------------------------------
--- EdgesMinimal
-create view EdgesMinimal as
-select SrcName.Value as Source, EdgeType.Name as Type, TrgName.Value as Target
-from Object
- inner join Edge on Edge.refObject = Object.key
- inner join EdgeType on Edge.refEdgeType = EdgeType.key
- inner join VarCharObject on VarCharObject.refObject = Object.key
- inner join VarCharObject as SrcName on Edge.refSourceVertex = SrcName.refObject
- inner join VarCharObject as TrgName on Edge.refTargetVertex = TrgName.refObject
-
--- -----------------------------------------------------------------------------
--- EdgesComplete
-select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type,
- VarCharObject.value as Name, IntObject.value as Year,
- Edge.refSourceVertex as Src, SrcName.Value,
- Edge.refTargetVertex as Trg, TrgName.Value
-from Object
- inner join Edge on Edge.refObject = Object.key
- inner join EdgeType on Edge.refEdgeType = EdgeType.key
- inner join VarCharObject on VarCharObject.refObject = Object.key
- inner join VarCharObject as SrcName on Edge.refSourceVertex = SrcName.refObject
- inner join VarCharObject as TrgName on Edge.refTargetVertex = TrgName.refObject
- left outer join IntObject on IntObject.refObject = Object.key
-
--- -----------------------------------------------------------------------------
--- Edges 2.
---
-select refSourceVertex as Src, VarCharObject.value as Source,
- (select EdgeType.name from EdgeType where EdgeType.key = Edge.refEdgeType) as Relation,
- (select IntObject.value
- from Edge
- inner join Object on Object.key = Edge.refObject
- inner join IntObject on Object.key = IntObject.refObject
- ) as Year,
- (select VarCharObject.value
- from Edge
- inner join Vertex on Vertex.key = Edge.refTargetVertex
- inner join Object on Object.key = Vertex.refObject
- inner join VarCharObject on Object.key = VarCharObject.refObject
- ) as Target
-from Edge
- inner join Vertex on Vertex.key = Edge.refSourceVertex
- inner join Object on Object.key = Vertex.refObject
- inner join VarCharObject on Object.key = VarCharObject.refObject
-
-
--- -----------------------------------------------------------------------------
--- Fields
-
-
--- -----------------------------------------------------------------------------
--- Artists
-select Vertex.key as Vtx, Object.key as Obj, VarCharObject.value as Name, IntObject.value as YoBirth
-from Vertex
- inner join Object on Object.key = Vertex.refObject
- inner join VarCharObject on Object.key = VarCharObject.refObject and VarCharObject.refAttribute = 1
- inner join IntObject on Object.key = IntObject.refObject and IntObject.refAttribute = 2
-where
- Vertex.refObjectType = 1
-
-
-
--- -----------------------------------------------------------------------------
--- Recordings alias Tracks
-select Object.key as Obj, Vertex.refObjectType as TKey, ObjectType.Name as Type,
- Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
-
-
--- -----------------------------------------------------------------------------
--- Tracks, incluing album attributes via sub-selects
-select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type,
- Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur,
- (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb,
- (select VarCharObject.value from VarCharObject where VarCharObject.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) and VarCharObject.refAttribute = 1) as Album,
- (select IntObject.value from IntObject where IntObject.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) and IntObject.refAttribute = 2) as YoC
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
-
--- -----------------------------------------------------------------------------
--- Tracks, incluing album attributes via joins
-select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type,
- Name.value as Name, Position.value as Pos, Duration.value as Dur,
- (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb,
- Album_Name.value as Album, Album_Year.value as YoC
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
- left outer join VarCharObject as Album_Name
- on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Name.refAttribute = 1
- left outer join IntObject as Album_Year
- on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Year.refAttribute = 2
-
-
--- -----------------------------------------------------------------------------
--- Tracks, including album attributes via joins
-select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
- , Name.value as Name, Position.value as Pos, Duration.value as Dur
- , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
- , Album_Name.value as Album, Album_Year.value as YoC
- , Performer_Name.value as Performer
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
- left outer join VarCharObject as Album_Name
- on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Name.refAttribute = 1
- left outer join IntObject as Album_Year
- on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Year.refAttribute = 2
- left outer join VarCharObject as Performer_Name
- on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
-
-
--- -----------------------------------------------------------------------------
--- Recordings alias Tracks, incluing album attributes via joins
-(select Edge.refTargetVertex, group_concat(VarCharObject.value) as Performers
- from Edge
- inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
- where refTargetVertex = 12 and refEdgeType = 2)
-
--- -----------------------------------------------------------------------------
--- Tracks, including album attributes via joins
-select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
- , Name.value as Name, Position.value as Pos, Duration.value as Dur
- , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
- , Album_Name.value as Album, Album_Year.value as YoC
- , Performer_Name.value as Performer
- , (select Edge.refTargetVertex, group_concat(VarCharObject.value) as Performers
- from Edge
- inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
- where refTargetVertex = 12 and refEdgeType = 2)
-
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
- left outer join VarCharObject as Album_Name
- on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Name.refAttribute = 1
- left outer join IntObject as Album_Year
- on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Year.refAttribute = 2
- left outer join VarCharObject as Performer_Name
- on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
-
-
--- -----------------------------------------------------------------------------
--- Tracks, including album attributes via joins
-select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
- , Name.value as Name, Position.value as Pos, Duration.value as Dur
- , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
- , Album_Name.value as Album, Album_Year.value as YoC
- , Performer_Name.value as Performer
- , (select group_concat(VarCharObject.value)
- from Edge
- inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
- where refTargetVertex = (select Edge.refSourceVertex from Edge
- where refTargetVertex = Object.key and refEdgeType = 5)
- and refEdgeType = 2
- ) as AlbumArtists
-from Object
- inner join Vertex on Vertex.refObject = Object.key
- inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
- inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
- left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
- left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
- left outer join VarCharObject as Album_Name
- on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Name.refAttribute = 1
- left outer join IntObject as Album_Year
- on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
- and Album_Year.refAttribute = 2
- left outer join VarCharObject as Performer_Name
- on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
-
-
--- -----------------------------------------------------------------------------
--- View Album
-create view Album as
-select Edge.refTargetVertex as Key, group_concat(Performer_name.value) as Artists, YearOfCreation.value as YoC
- from Vertex
- inner join VarCharObject as Performer_name on Performer_name.refObject = Vertex.key and Vertex.refObjectType = 1
- inner join Edge on Edge.refSourceVertex = Vertex.key and Edge.refEdgeType = 2
- left outer join IntObject as YearOfCreation on YearOfCreation.refObject = Vertex.key
-group by Edge.refTargetVertex
-
-select Edge.refSourceVertex, Edge.refTargetVertex, Album.Album_Artists
-from Edge
-inner join Album on Album.Album_key = Edge.refTargetVertex
-
--- -----------------------------------------------------------------------------
--- Utils
-alter table VarCharObject add seqnum integer
-
-
-
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -5,48 +5,409 @@
drop table Vertex;
drop table Edge;
drop table Object;
+drop table Relation;
create table TypeTraits (key integer primary key, name varchar);
create table ObjectType (key integer primary key, traits integer, name varchar);
create table EdgeType (key integer primary key, refSourceType integer, refRelationType integer, refTargetType integer, name varchar);
create table Vertex (key integer primary key, refObjectType integer, refObject integer);
create table Edge (key integer primary key, refEdgeType integer, refSourceVertex integer, refTargetVertex integer, refObject integer);
-
--- Object is hardly a new entity of its own. It builds the disjoint union of
--- Vertex and Edge Key.
--- {Object.keys} == {V.keys} + {E,keys} +:set union
--- {} == {V.keys} & {E,keys} &:set intersection
create table Object (key integer primary key);
-
create table Attribute (key integer primary key, refObjectType integer, name varchar);
+
create table IntObject (refObject integer, refAttribute integer, value integer, primary key (refObject, refAttribute));
create table VarCharObject (refObject integer, refAttribute integer, value varchar, primary key (refObject, refAttribute));
--- The creation sequence and systematics for generating example entities:
--- To add an album with titles, recordings and locations
--- we proceed from elemetal, independent, not refering entities
--- to those that contain references to other entities
-
--- Example Album: Abbey Road.
-
--- add genre ...
--- add Beat
--- add Obj, Vtx, Name
-
--- add artists
--- add John Lennon
--- add Obj, Vtx, Name, [...]
--- add Paul McCartney
--- add Geroge Harrison
--- add Ringo Starr
-
--- add titles
--- add Come Together
--- add Obj, Vtx, Name, YoC
--- add Something
--- ...
--- add artist composed title relation
---
+
+-- -----------------------------------------------------------------------------
+insert into TypeTraits values (0, 'atom obj');
+insert into TypeTraits values (1, 'comp obj');
+insert into TypeTraits values (2, 'atom rel');
+
+insert into ObjectType values (0, 0, 'Nil');
+insert into ObjectType values (1, 0, 'a:artist');
+insert into ObjectType values (2, 0, 'a:title');
+insert into ObjectType values (3, 0, 'a:recording');
+insert into ObjectType values (4, 0, 'c:artists');
+insert into ObjectType values (5, 1, 'c:genre');
+insert into ObjectType values (6, 2, 'r:composed');
+insert into ObjectType values (7, 2, 'r:performed');
+insert into ObjectType values (8, 2, 'r:recorded as');
+insert into ObjectType values (9, 2, 'r:located at');
+insert into ObjectType values (10, 0, 'c:album');
+insert into ObjectType values (11, 2, 'r:contains');
+
+insert into EdgeType values (1, 1, 6, 2, 'artist composed title' );
+insert into EdgeType values (2, 1, 7, 3, 'artist performed record' );
+insert into EdgeType values (3, 2, 8, 3, 'title recorded as record');
+insert into EdgeType values (4, 3, 9, 4, 'record located at url' );
+insert into EdgeType values (5, 10, 11, 3, 'album contains record' );
+
+insert into Object values (0);
+
+insert into Object values (1);
+insert into Attribute values (1, "Name");
+insert into VarCharObject values (1, 1, "Charlie Haden");
+
+insert into Object values (2);
+insert into VarCharObject values (2, 1, "Kenny Barron");
+
+insert into Object values (3);
+insert into VarCharObject values (3, 1, "Jonny Green");
+
+insert into Object values (4);
+insert into VarCharObject values (4, 1, "Twighlight Song");
+
+insert into Object values (5);
+insert into VarCharObject values (5, 1, "Body & Soul");
+
+insert into Object values (6);
+insert into VarCharObject values (6, 1, "composed in 1995");
+
+insert into Object values (7);
+insert into VarCharObject values (7, 1, "composed in 1930");
+
+insert into Object values (8);
+insert into VarCharObject values (8, 1, "N&tC: Twighlight Song");
+
+insert into Object values (9);
+insert into VarCharObject values (9, 1, "N&tC: Body & Soul");
+
+insert into Object values (10);
+insert into VarCharObject values (10, 1, "Night & the City");
+
+
+insert into Vertex values (0, 0, 0);
+insert into Vertex values (1, 1, 1);
+insert into Vertex values (2, 1, 2);
+insert into Vertex values (3, 1, 3);
+insert into Vertex values (4, 2, 4);
+insert into Vertex values (5, 2, 5);
+insert into Vertex values (8, 3, 8);
+insert into Vertex values (9, 3, 9);
+insert into Vertex values (10, 3, 10);
+
+insert into Edge values (1, 1, 1, 4, 6);
+-- 2:key 1:composed 3:J.Green 5:Body&Soul 7:comp1930
+insert into Edge values (2, 1, 3, 5, 7);
+
+-- 3:key 2:performed 2:K.Barron 10:N&tC 11:rec1996
+insert into Edge values (3, 2, 2, 10, 11);
+-- 4:key 7:performed 1:C.Haden 10:N&tC
+insert into Edge values (4, 2, 1, 10, 11);
+
+insert into Object values (11);
+insert into VarCharObject values (11, 1, "recoreded 1996");
+
+
+-- -------------------------------------
+-- Dag Related Architecture Linking All
+-- D R A C U L A
+-- -------------------------------------------------------
+-- Dag Related Architecture Using Links All over the place
+-- D R A C U L A
+
+-- -----------------------------------------------------------------------------
+-- Check for EdgeTypes
+create view EdgeTypeCheck as
+select
+ (select ObjectType.name from ObjectType where ObjectType.key = EdgeType.refSourceType) as SrcT,
+ (select ObjectType.name from ObjectType where ObjectType.key = EdgeType.refRelationType) as RelT,
+ ObjectType.name as TrgT,
+ EdgeType.name
+from EdgeType
+ inner join ObjectType on EdgeType.refTargetType = ObjectType.key
+
+-- -----------------------------------------------------------------------------
+-- Named Objects
+create view NamedObjects as
+select Object.key as Obj, VarCharObject.value as Name
+from Object
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+
+-- -----------------------------------------------------------------------------
+-- Named Objects 1:1 Attributes joined horizontally.
+select Object.key as Obj, Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
+from Object
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+ -- and so on ...
+
+-- -----------------------------------------------------------------------------
+-- Named Objects and Types 1:1 Attributes joined horizontally.
+select Object.key as Obj, Vertex.refObjectType as Type, Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
+from Object
+ inner join Vertex on Vertex.refObject = Object.key and Type = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+
+
+-- -----------------------------------------------------------------------------
+-- Vertexes
+select Vertex.key as Vtx, Object.key as Obj, ObjectType.Name as Type , Attribute.Name as Attr,
+ VarCharObject.Value as Name, IntObject.value as Year
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key
+ inner join Attribute on VarCharObject.refAttribute = Attribute.key
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+ left outer join IntObject on IntObject.refObject = Object.key
+
+-- -----------------------------------------------------------------------------
+-- Edge-Objects and associated values
+select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type , Attribute.Name as Attr,
+ VarCharObject.Value as Name, IntObject.value as Year
+from Object
+ inner join Edge on Edge.refObject = Object.key
+ inner join EdgeType on Edge.refEdgeType = EdgeType.key
+ inner join Attribute on VarCharObject.refAttribute = Attribute.key
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+ left outer join IntObject on IntObject.refObject = Object.key
+
+-- -----------------------------------------------------------------------------
+-- Edges
+select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type,
+ VarCharObject.value as Name, IntObject.value as Year
+from Object
+ inner join Edge on Edge.refObject = Object.key
+ inner join EdgeType on Edge.refEdgeType = EdgeType.key
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+ left outer join IntObject on IntObject.refObject = Object.key
+
+-- -----------------------------------------------------------------------------
+-- EdgesMinimal
+create view EdgesMinimal as
+select SrcName.Value as Source, EdgeType.Name as Type, TrgName.Value as Target
+from Object
+ inner join Edge on Edge.refObject = Object.key
+ inner join EdgeType on Edge.refEdgeType = EdgeType.key
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+ inner join VarCharObject as SrcName on Edge.refSourceVertex = SrcName.refObject
+ inner join VarCharObject as TrgName on Edge.refTargetVertex = TrgName.refObject
+
+-- -----------------------------------------------------------------------------
+-- EdgesComplete
+select Edge.key as Edg, Object.key as Obj, EdgeType.Name as Type,
+ VarCharObject.value as Name, IntObject.value as Year,
+ Edge.refSourceVertex as Src, SrcName.Value,
+ Edge.refTargetVertex as Trg, TrgName.Value
+from Object
+ inner join Edge on Edge.refObject = Object.key
+ inner join EdgeType on Edge.refEdgeType = EdgeType.key
+ inner join VarCharObject on VarCharObject.refObject = Object.key
+ inner join VarCharObject as SrcName on Edge.refSourceVertex = SrcName.refObject
+ inner join VarCharObject as TrgName on Edge.refTargetVertex = TrgName.refObject
+ left outer join IntObject on IntObject.refObject = Object.key
+
+-- -----------------------------------------------------------------------------
+-- Edges 2.
+--
+select refSourceVertex as Src, VarCharObject.value as Source,
+ (select EdgeType.name from EdgeType where EdgeType.key = Edge.refEdgeType) as Relation,
+ (select IntObject.value
+ from Edge
+ inner join Object on Object.key = Edge.refObject
+ inner join IntObject on Object.key = IntObject.refObject
+ ) as Year,
+ (select VarCharObject.value
+ from Edge
+ inner join Vertex on Vertex.key = Edge.refTargetVertex
+ inner join Object on Object.key = Vertex.refObject
+ inner join VarCharObject on Object.key = VarCharObject.refObject
+ ) as Target
+from Edge
+ inner join Vertex on Vertex.key = Edge.refSourceVertex
+ inner join Object on Object.key = Vertex.refObject
+ inner join VarCharObject on Object.key = VarCharObject.refObject
+
+
+-- -----------------------------------------------------------------------------
+-- Fields
+
+
+-- -----------------------------------------------------------------------------
+-- Artists
+select Vertex.key as Vtx, Object.key as Obj, VarCharObject.value as Name, IntObject.value as YoBirth
+from Vertex
+ inner join Object on Object.key = Vertex.refObject
+ inner join VarCharObject on Object.key = VarCharObject.refObject and VarCharObject.refAttribute = 1
+ inner join IntObject on Object.key = IntObject.refObject and IntObject.refAttribute = 2
+where
+ Vertex.refObjectType = 1
+
+
+
+-- -----------------------------------------------------------------------------
+-- Recordings alias Tracks
+select Object.key as Obj, Vertex.refObjectType as TKey, ObjectType.Name as Type,
+ Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+
+
+-- -----------------------------------------------------------------------------
+-- Tracks, incluing album attributes via sub-selects
+select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type,
+ Name.value as Name, YearOfCrea.value as YoC, Position.value as Pos, Duration.value as Dur,
+ (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb,
+ (select VarCharObject.value from VarCharObject where VarCharObject.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) and VarCharObject.refAttribute = 1) as Album,
+ (select IntObject.value from IntObject where IntObject.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) and IntObject.refAttribute = 2) as YoC
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join IntObject as YearOfCrea on YearOfCrea.refObject = Object.key and YearOfCrea.refAttribute = 2
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+
+-- -----------------------------------------------------------------------------
+-- Tracks, incluing album attributes via joins
+select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type,
+ Name.value as Name, Position.value as Pos, Duration.value as Dur,
+ (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb,
+ Album_Name.value as Album, Album_Year.value as YoC
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+ left outer join VarCharObject as Album_Name
+ on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Name.refAttribute = 1
+ left outer join IntObject as Album_Year
+ on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Year.refAttribute = 2
+
+
+-- -----------------------------------------------------------------------------
+-- Tracks, including album attributes via joins
+select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
+ , Name.value as Name, Position.value as Pos, Duration.value as Dur
+ , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
+ , Album_Name.value as Album, Album_Year.value as YoC
+ , Performer_Name.value as Performer
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+ left outer join VarCharObject as Album_Name
+ on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Name.refAttribute = 1
+ left outer join IntObject as Album_Year
+ on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Year.refAttribute = 2
+ left outer join VarCharObject as Performer_Name
+ on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
+
+
+-- -----------------------------------------------------------------------------
+-- Recordings alias Tracks, incluing album attributes via joins
+(select Edge.refTargetVertex, group_concat(VarCharObject.value) as Performers
+ from Edge
+ inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
+ where refTargetVertex = 12 and refEdgeType = 2)
+
+-- -----------------------------------------------------------------------------
+-- Tracks, including album attributes via joins
+select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
+ , Name.value as Name, Position.value as Pos, Duration.value as Dur
+ , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
+ , Album_Name.value as Album, Album_Year.value as YoC
+ , Performer_Name.value as Performer
+ , (select Edge.refTargetVertex, group_concat(VarCharObject.value) as Performers
+ from Edge
+ inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
+ where refTargetVertex = 12 and refEdgeType = 2)
+
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+ left outer join VarCharObject as Album_Name
+ on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Name.refAttribute = 1
+ left outer join IntObject as Album_Year
+ on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Year.refAttribute = 2
+ left outer join VarCharObject as Performer_Name
+ on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
+
+
+-- -----------------------------------------------------------------------------
+-- Tracks, including album attributes via joins (*)
+select Object.key as Obj, Vertex.refObjectType as Tp, ObjectType.Name as Type
+ , Name.value as Name, Position.value as Pos, Duration.value as Dur
+ , (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5) as Alb
+ , Album_Name.value as Album, Album_Year.value as YoC
+ , Performer_Name.value as Performer
+ , (select group_concat(VarCharObject.value)
+ from Edge
+ inner join VarCharObject on Edge.refSourceVertex = VarCharObject.refObject
+ where refTargetVertex = (select Edge.refSourceVertex from Edge
+ where refTargetVertex = Object.key and refEdgeType = 5)
+ and refEdgeType = 2
+ ) as AlbumArtists
+from Object
+ inner join Vertex on Vertex.refObject = Object.key
+ inner join ObjectType on Vertex.refObjectType = ObjectType.key and ObjectType.key = 3
+ inner join VarCharObject as Name on Name.refObject = Object.key and Name.refAttribute = 1
+ left outer join VarCharObject as Duration on Duration.refObject = Object.key and Duration.refAttribute = 3
+ left outer join VarCharObject as Position on Position.refObject = Object.key and Position.refAttribute = 4
+ left outer join VarCharObject as Album_Name
+ on Album_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Name.refAttribute = 1
+ left outer join IntObject as Album_Year
+ on Album_Year.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = Object.key and refEdgeType = 5)
+ and Album_Year.refAttribute = 2
+ left outer join VarCharObject as Performer_Name
+ on Performer_Name.refObject = (select Edge.refSourceVertex from Edge where refTargetVertex = 12 and refEdgeType = 2)
+
+
+-- -----------------------------------------------------------------------------
+-- Experimental views: Checking how we can structure selects based on Edges
+-- using Sql-Views to make them more managable.
+-- -----------------------------------------------------------------------------
+-- View Album
+create view Album as
+select -- Edge.refSourceVertex as ArtistKey,
+ Vertex.key as Key, AlbumTitle.value as Name, group_concat(Performer.value) as Artists, YearOfCreation.value as YoC
+from Vertex
+ inner join Edge on Edge.refTargetVertex = Vertex.key
+ and Edge.refEdgeType = 2 -- 2: Artist (performs on) Album
+ left outer join VarCharObject as AlbumTitle on AlbumTitle.refObject = vertex.key and AlbumTitle.refAttribute = 1
+ left outer join VarCharObject as Performer on Performer.refObject = Edge.refSourceVertex
+ left outer join IntObject as YearOfCreation on YearOfCreation.refObject = Vertex.key
+group by Vertex.key
+
+-- -----------------------------------------------------------------------------
+-- View Track
+-- create view Track as
+select -- Edge.refSourceVertex as ArtistKey,
+ Vertex.key as TrkKey, TrackName.value
+ , MotherAlbum.refSourceVertex as MAlbKey, Album.Key as AlbKey
+ , Album.Name as AlbumName, Album.Artists as AlbumArtists
+from Vertex
+ inner join VarCharObject as TrackName on TrackName.refObject = Vertex.key
+ and TrackName.refAttribute = 1
+ and Vertex.refObjectType = 3
+ left outer join Edge as MotherAlbum on MotherAlbum.refTargetVertex = Vertex.key
+ and MotherAlbum.refEdgeType = 5 -- 5: Album contains Recording
+ left outer join Album on MotherAlbum.refSourceVertex = Album.Key
+
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -51,6 +51,8 @@
#include "data/qsql/QSqlSelector.h"
#include "data/concept/Selector.h"
+#include "gen/NameGenerator.h"
+
Browser::Browser(QWidget *parent)
: QWidget(parent)
{
@@ -186,6 +188,20 @@
QSqlQuery curQuery = QSqlQuery(connectionWidget->currentDatabase());
//JODO Testcode
+ gen::tString some;
+ gen::NameGenerator makeSome(2,5);
+
+ for(int i=0; i<10; i++)
+ {
+ some += makeSome();
+ some += "\n";
+ }
+
+ QMessageBox msgBox;
+ QString msg = some;
+ msgBox.setText(msg);
+ msgBox.exec();
+
bool success = false;
data::QSqlSelector selector;
dag::db::TypeGraph tygra;
Added: sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.cpp
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.cpp 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#include "NameGenerator.h"
+
+using namespace gen;
+
+boost::random::mt19937 NameGenerator::s_aGen;
+
+const char* NameGenerator::s_SyllablesBegin[] =
+{
+ "Ana"
+ , "Pa"
+ , "Re"
+};
+
+const char* NameGenerator::s_SyllablesMid[] =
+{
+ "be"
+ , "dre"
+ , "dri"
+ , "ja"
+ , "na"
+ , "ma"
+ , "no"
+ , "ra"
+};
+
+const char* NameGenerator::s_SyllablesEnd[] =
+{
+ "ja"
+ , "ka"
+ , "le"
+ , "ma"
+ , "na"
+};
+
+
+int NameGenerator::syllablesBeginCount()
+{
+ return sizeof(s_SyllablesBegin)/sizeof(s_SyllablesBegin[0]);
+}
+
+int NameGenerator::syllablesMidCount()
+{
+ return sizeof(s_SyllablesMid)/sizeof(s_SyllablesMid[0]);
+}
+
+int NameGenerator::syllablesEndCount()
+{
+ return sizeof(s_SyllablesEnd)/sizeof(s_SyllablesEnd[0]);
+}
+
+tUniform NameGenerator::s_BeginDist(0, NameGenerator::syllablesBeginCount()-1);
+tUniform NameGenerator::s_MidDist (0, NameGenerator::syllablesMidCount()-1);
+tUniform NameGenerator::s_EndDist (0, NameGenerator::syllablesEndCount()-1);
+
+tString NameGenerator::operator()()const
+{
+ tString someName = m_aPrefix;
+ someName += s_SyllablesBegin[s_BeginDist(s_aGen)];
+
+ int count = m_aDist(s_aGen) - 2;
+ count = count < 0 ? 0 : count;
+
+ for(int idx = 0; idx < count; idx++)
+ someName += s_SyllablesMid[s_MidDist(s_aGen)];
+
+
+ someName += s_SyllablesEnd[s_EndDist(s_aGen)];
+
+ return someName;
+}
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/gen/NameGenerator.h 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -9,43 +9,43 @@
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
+#include <QString.h>
+
namespace gen
{
+typedef QString tString;
+typedef boost::random::uniform_int_distribution<> tUniform;
-static const char* sylable_begin[] =
+class NameGenerator
{
- , "An"
-};
+public:
+ NameGenerator(int min, int max)
+ : m_aPrefix(), m_aDist(min, max){}
-static const char* sylable_mid[] =
-{
- , "bel"
- , "dre"
- , "dri"
- , "ja"
- , "na"
- , "nusch"
-};
+ tString operator()()const;
-static const char* sylable_female_end[] =
-{
- , "ka"
- , "le"
- , "na"
-};
+ static int syllablesBeginCount();
+ static int syllablesMidCount();
+ static int syllablesEndCount();
+private:
+ int m_iMinSyllables;
+ int m_iMaxSyllables;
+ tString m_aPrefix;
-template<class Accessor>
-struct SelectorTraits
-{
- typedef typename Accessor::size_type size_type;
- typedef typename Accessor::tQuery tQuery;
- typedef typename Accessor::iterator const_iterator;
-
- static const_iterator begin(const Accessor& accessor);
- static const_iterator end(const Accessor& accessor);
- static size_type select(const tQuery&);
+ static boost::random::mt19937 s_aGen;
+
+ tUniform m_aDist;
+
+ static const char* s_SyllablesBegin[];
+ static const char* s_SyllablesMid[];
+ static const char* s_SyllablesEnd[];
+
+ static tUniform s_BeginDist;
+ static tUniform s_MidDist;
+ static tUniform s_EndDist;
};
+
} // namespace data
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
==============================================================================
Binary files. No diff available.
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro 2012-05-21 13:46:09 EDT (Mon, 21 May 2012)
@@ -3,8 +3,8 @@
QT += sql
-INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
-#INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
+#INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
+INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
exttableview.h \
@@ -25,13 +25,15 @@
data/concept/CreatorTraits.h \
data/qsql/QSqlSelector.h \
data/qsql/QSqlCreator.h \
- data/concept/GetCreator.h
+ data/concept/GetCreator.h \
+ gen/NameGenerator.h
SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp \
exttableview.cpp \
dagitem.cpp \
dagmodel.cpp \
Dag/TypeGraph.cpp \
- Dag/TypeGraph.cpp
+ Dag/TypeGraph.cpp \
+ gen/NameGenerator.cpp
FORMS = browserwidget.ui qsqlconnectiondialog.ui
build_all:!build_pass {
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk