summaryrefslogtreecommitdiffstats
blob: 2dfea346b2443581eedcebc4b925f320f684e902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
-- @name		SQLDDL
-- @version		1.0
-- @domains		Databases
-- @authors		Marcos Didonet Del Fabro (marcos.didonet-del-fabro@univ-nantes.fr)
-- @date		2006/08/28
-- @description	This metamodel is a subset of SQL Data Definition Language 


package SQLDDL {

	abstract class LocatedElement {
		attribute location : String;
		attribute commentsBefore[*] : String;
		attribute commentsAfter[*] : String;
	}

	abstract class NamedElement extends LocatedElement {
		attribute name : String;
	}

	class Database extends NamedElement {
		reference tables[*] ordered container : Table oppositeOf database;
	}

	class Table extends NamedElement {
		reference database : Database oppositeOf tables;
		reference referencedBy[*] : ForeignKey oppositeOf referencedTable;

		reference elements[*] ordered container : TableElement oppositeOf table;
		reference parameters[*] ordered container : Parameter oppositeOf table;
	}

-- @begin Table Elements
	abstract class TableElement extends LocatedElement {
		reference table : Table oppositeOf elements;
	}

	class Column extends TableElement {
		reference referencedBy[*] : ForeignKey oppositeOf referencedColumns;

		attribute name : String;

		reference type container : Type;
		attribute canBeNull : Boolean;
		reference default[0-1] container : Value;

		reference keys[*] : Key oppositeOf columns;
	}

	abstract class Key extends TableElement {
		attribute isUnique : Boolean;
		attribute name[0-1] : String;
		reference columns[1-*] ordered : Column oppositeOf keys;
	}

	class SimpleKey extends Key {
	}

	class PrimaryKey extends Key {
	}

	class ForeignKey extends Key {
		reference referencedTable : Table oppositeOf referencedBy;
		reference referencedColumns[1-*] : Column oppositeOf referencedBy;
	}
-- @end Table Elements

	class Type extends NamedElement {
		attribute length[0-2] : Integer;
		attribute isUnsigned : Boolean;
	}

	class Parameter extends NamedElement {
		reference table : Table oppositeOf parameters;

		reference value[0-1] container : Value;
	}

-- @begin Values
	abstract class Value extends LocatedElement {
	}

	class IntegerVal extends Value {
		attribute value : Integer;
	}

	class NullVal extends Value {
	}

	class StringVal extends Value {
		attribute value : String;
	}
-- @end Values
}

package PrimitiveTypes {
	datatype Boolean;
	datatype Integer;
	datatype String;
}