composite_primary_keys 9.0.4 → 9.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.rdoc +20 -0
- data/Rakefile +37 -34
- data/lib/composite_primary_keys.rb +5 -10
- data/lib/composite_primary_keys/arel/in.rb +6 -6
- data/lib/composite_primary_keys/arel/sqlserver.rb +36 -0
- data/lib/composite_primary_keys/associations/association_scope.rb +51 -29
- data/lib/composite_primary_keys/attribute_methods/read.rb +3 -1
- data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +22 -0
- data/lib/composite_primary_keys/relation.rb +30 -0
- data/lib/composite_primary_keys/relation/query_methods.rb +25 -36
- data/lib/composite_primary_keys/sanitization.rb +31 -47
- data/lib/composite_primary_keys/version.rb +1 -1
- data/tasks/databases/mysql.rake +40 -42
- data/tasks/databases/oracle.rake +29 -15
- data/tasks/databases/postgresql.rake +38 -47
- data/tasks/databases/sqlite.rake +25 -0
- data/tasks/databases/sqlserver.rake +32 -16
- data/test/abstract_unit.rb +12 -11
- data/test/connections/connection_spec.rb +27 -18
- data/test/connections/databases.ci.yml +5 -4
- data/test/connections/databases.example.yml +19 -4
- data/test/connections/databases.yml +25 -4
- data/test/fixtures/article.rb +6 -5
- data/test/fixtures/db_definitions/mysql.sql +16 -7
- data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
- data/test/fixtures/db_definitions/oracle.sql +25 -15
- data/test/fixtures/db_definitions/postgresql.sql +11 -2
- data/test/fixtures/db_definitions/sqlite.sql +8 -0
- data/test/fixtures/db_definitions/sqlserver.sql +19 -33
- data/test/fixtures/pk_called_id.rb +5 -0
- data/test/fixtures/pk_called_ids.yml +11 -0
- data/test/test_associations.rb +334 -332
- data/test/test_create.rb +9 -1
- data/test/test_delete.rb +17 -39
- data/test/test_ids.rb +113 -109
- data/test/test_preload.rb +94 -0
- data/test/test_suite.rb +1 -1
- data/test/test_update.rb +12 -7
- metadata +14 -24
- data/lib/composite_primary_keys/associations/singular_association.rb +0 -14
- data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +0 -71
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +0 -50
- data/lib/composite_primary_keys/dirty.rb +0 -19
- data/lib/composite_primary_keys/validations/uniqueness.rb +0 -41
- data/tasks/databases/oracle_enhanced.rake +0 -27
- data/tasks/databases/sqlite3.rake +0 -27
- data/test/connections/native_ibm_db/connection.rb +0 -19
- data/test/connections/native_mysql/connection.rb +0 -17
- data/test/connections/native_oracle/connection.rb +0 -11
- data/test/connections/native_oracle_enhanced/connection.rb +0 -16
- data/test/connections/native_postgresql/connection.rb +0 -13
- data/test/connections/native_sqlite3/connection.rb +0 -9
- data/test/connections/native_sqlserver/connection.rb +0 -11
- data/test/fixtures/db_definitions/sqlserver.drop.sql +0 -92
- data/test/test_delete_all.rb +0 -29
@@ -1,18 +1,27 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module CompositePrimaryKeys
|
5
|
+
class ConnectionSpec
|
6
|
+
def self.[](adapter)
|
7
|
+
config[adapter.to_s].dup
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def self.config
|
13
|
+
@config ||= begin
|
14
|
+
# Find the file location
|
15
|
+
path = File.join(PROJECT_ROOT, 'test', 'connections', 'databases.yml')
|
16
|
+
|
17
|
+
# Run any erb code
|
18
|
+
template = ERB.new(File.read(path))
|
19
|
+
project_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
20
|
+
data = template.result(binding)
|
21
|
+
|
22
|
+
# And now to YAML
|
23
|
+
YAML.load(data)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,12 +4,13 @@ mysql:
|
|
4
4
|
password: ""
|
5
5
|
database: composite_primary_keys_unittest
|
6
6
|
|
7
|
-
sqlite3:
|
8
|
-
adapter: sqlite3
|
9
|
-
database: db/composite_primary_keys_unittest.sqlite
|
10
|
-
|
11
7
|
postgresql:
|
12
8
|
adapter: postgresql
|
13
9
|
database: composite_primary_keys_unittest
|
14
10
|
username: postgres
|
15
11
|
host: localhost
|
12
|
+
|
13
|
+
sqlite:
|
14
|
+
adapter: sqlite3
|
15
|
+
database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
|
16
|
+
|
@@ -2,14 +2,24 @@
|
|
2
2
|
# 1. Copy this file to test/connections/databases.yml.
|
3
3
|
# 2. Update to match the databases you want to test against.
|
4
4
|
|
5
|
+
ibm_db:
|
6
|
+
database: ocdpdev
|
7
|
+
username: db2inst1
|
8
|
+
password: password
|
9
|
+
host: localhost
|
10
|
+
|
5
11
|
mysql:
|
6
12
|
adapter: mysql2
|
7
13
|
username: root
|
14
|
+
password: mysql
|
8
15
|
database: composite_primary_keys_unittest
|
9
16
|
|
10
|
-
|
11
|
-
adapter:
|
12
|
-
database:
|
17
|
+
oracle:
|
18
|
+
adapter: oracle_enhanced
|
19
|
+
database: xe
|
20
|
+
username: SYSTEM
|
21
|
+
password: oracle
|
22
|
+
host: localhost
|
13
23
|
|
14
24
|
postgresql:
|
15
25
|
adapter: postgresql
|
@@ -17,9 +27,14 @@ postgresql:
|
|
17
27
|
username: postgres
|
18
28
|
host: localhost
|
19
29
|
|
30
|
+
sqlite:
|
31
|
+
adapter: sqlite3
|
32
|
+
database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
|
33
|
+
|
20
34
|
sqlserver:
|
21
35
|
adapter: sqlserver
|
36
|
+
username: cpk
|
37
|
+
password: cpk
|
22
38
|
database: composite_primary_keys_unittest
|
23
|
-
username: rails
|
24
39
|
host: localhost
|
25
40
|
port: 1433
|
@@ -1,9 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
mysql:
|
2
|
+
adapter: mysql2
|
3
|
+
username: root
|
4
|
+
password: mysql
|
5
|
+
database: composite_primary_keys_unittest
|
6
|
+
|
7
|
+
oracle:
|
8
|
+
adapter: oracle_enhanced
|
9
|
+
database: xe
|
10
|
+
username: SYSTEM
|
11
|
+
password: oracle
|
12
|
+
host: localhost
|
13
|
+
|
5
14
|
postgresql:
|
6
15
|
adapter: postgresql
|
7
16
|
database: composite_primary_keys_unittest
|
8
17
|
username: postgres
|
9
18
|
host: localhost
|
19
|
+
|
20
|
+
sqlite:
|
21
|
+
adapter: sqlite3
|
22
|
+
database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
|
23
|
+
|
24
|
+
sqlserver:
|
25
|
+
adapter: sqlserver
|
26
|
+
username: cpk
|
27
|
+
password: cpk
|
28
|
+
database: composite_primary_keys_unittest
|
29
|
+
host: localhost
|
30
|
+
port: 1433
|
data/test/fixtures/article.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
class Article < ActiveRecord::Base
|
2
|
-
|
3
|
-
has_many :
|
4
|
-
|
5
|
-
|
1
|
+
class Article < ActiveRecord::Base
|
2
|
+
validates :id, uniqueness: true, numericality: true, allow_nil: true, allow_blank: true, on: :create
|
3
|
+
has_many :readings, :dependent => :delete_all
|
4
|
+
has_many :users, :through => :readings
|
5
|
+
end
|
6
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
create table topics (
|
2
|
-
id int not null auto_increment,
|
2
|
+
id int not null auto_increment,
|
3
3
|
name varchar(50) default null,
|
4
4
|
feed_size int default null,
|
5
5
|
primary key (id)
|
@@ -155,8 +155,8 @@ create table restaurants (
|
|
155
155
|
create table restaurants_suburbs (
|
156
156
|
franchise_id int not null,
|
157
157
|
store_id int not null,
|
158
|
-
city_id int
|
159
|
-
suburb_id int
|
158
|
+
city_id int default null,
|
159
|
+
suburb_id int default null
|
160
160
|
);
|
161
161
|
|
162
162
|
create table dorms (
|
@@ -201,18 +201,27 @@ create table seats (
|
|
201
201
|
);
|
202
202
|
|
203
203
|
create table capitols (
|
204
|
-
country varchar(100)
|
205
|
-
city varchar(100)
|
204
|
+
country varchar(100) not null,
|
205
|
+
city varchar(100) not null,
|
206
206
|
primary key (country, city)
|
207
207
|
);
|
208
208
|
|
209
209
|
create table products_restaurants (
|
210
210
|
product_id int not null,
|
211
|
-
franchise_id int
|
212
|
-
store_id int
|
211
|
+
franchise_id int default null,
|
212
|
+
store_id int default null
|
213
213
|
);
|
214
214
|
|
215
215
|
create table employees_groups (
|
216
216
|
employee_id int not null,
|
217
217
|
group_id int not null
|
218
218
|
);
|
219
|
+
|
220
|
+
create table pk_called_ids (
|
221
|
+
id integer not null,
|
222
|
+
reference_code int not null,
|
223
|
+
code_label varchar(50) default null,
|
224
|
+
abbreviation varchar(50) default null,
|
225
|
+
description varchar(50) default null,
|
226
|
+
primary key (id, reference_code)
|
227
|
+
);
|
@@ -16,24 +16,24 @@ create sequence reference_types_seq start with 1000;
|
|
16
16
|
|
17
17
|
create table reference_types (
|
18
18
|
reference_type_id number(11) primary key,
|
19
|
-
type_label
|
20
|
-
abbreviation
|
21
|
-
description
|
19
|
+
type_label varchar(50) default null,
|
20
|
+
abbreviation varchar(50) default null,
|
21
|
+
description varchar(50) default null
|
22
22
|
);
|
23
23
|
|
24
24
|
create table reference_codes (
|
25
25
|
reference_type_id number(11),
|
26
26
|
reference_code number(11),
|
27
|
-
code_label
|
28
|
-
abbreviation
|
29
|
-
description
|
27
|
+
code_label varchar(50) default null,
|
28
|
+
abbreviation varchar(50) default null,
|
29
|
+
description varchar(50) default null
|
30
30
|
);
|
31
31
|
|
32
32
|
create sequence products_seq start with 1000;
|
33
33
|
|
34
34
|
create table products (
|
35
35
|
id number(11) primary key,
|
36
|
-
name
|
36
|
+
name varchar(50) default null
|
37
37
|
);
|
38
38
|
|
39
39
|
create table tariffs (
|
@@ -55,7 +55,7 @@ create table product_tariffs (
|
|
55
55
|
create table suburbs (
|
56
56
|
city_id number(11),
|
57
57
|
suburb_id number(11),
|
58
|
-
name
|
58
|
+
name varchar(50) not null,
|
59
59
|
constraint suburbs_pk primary key (city_id, suburb_id)
|
60
60
|
);
|
61
61
|
|
@@ -65,21 +65,21 @@ create table streets (
|
|
65
65
|
id number(11) primary key,
|
66
66
|
city_id number(11) not null,
|
67
67
|
suburb_id number(11) not null,
|
68
|
-
name
|
68
|
+
name varchar(50) not null
|
69
69
|
);
|
70
70
|
|
71
71
|
create sequence users_seq start with 1000;
|
72
72
|
|
73
73
|
create table users (
|
74
74
|
id number(11) primary key,
|
75
|
-
name
|
75
|
+
name varchar(50) not null
|
76
76
|
);
|
77
77
|
|
78
78
|
create sequence articles_seq start with 1000;
|
79
79
|
|
80
80
|
create table articles (
|
81
81
|
id number(11) primary key,
|
82
|
-
name
|
82
|
+
name varchar(50) not null
|
83
83
|
);
|
84
84
|
|
85
85
|
create sequence readings_seq start with 1000;
|
@@ -95,7 +95,7 @@ create sequence groups_seq start with 1000;
|
|
95
95
|
|
96
96
|
create table groups (
|
97
97
|
id number(11) primary key,
|
98
|
-
name
|
98
|
+
name varchar(50) not null
|
99
99
|
);
|
100
100
|
|
101
101
|
create table memberships (
|
@@ -110,7 +110,7 @@ create table membership_statuses (
|
|
110
110
|
id number(11) primary key,
|
111
111
|
user_id number(11) not null,
|
112
112
|
group_id number(11) not null,
|
113
|
-
status
|
113
|
+
status varchar(50) not null
|
114
114
|
);
|
115
115
|
|
116
116
|
create table departments (
|
@@ -218,8 +218,8 @@ create table seats (
|
|
218
218
|
);
|
219
219
|
|
220
220
|
create table capitols (
|
221
|
-
country
|
222
|
-
city
|
221
|
+
country varchar(100) not null,
|
222
|
+
city varchar(100) not null,
|
223
223
|
primary key (country, city)
|
224
224
|
);
|
225
225
|
|
@@ -234,3 +234,13 @@ create table employees_groups (
|
|
234
234
|
group_id int not null
|
235
235
|
);
|
236
236
|
|
237
|
+
create sequence pk_called_ids_seq start with 1000;
|
238
|
+
|
239
|
+
create table pk_called_ids (
|
240
|
+
id int not null,
|
241
|
+
reference_code int not null,
|
242
|
+
code_label varchar(50) default null,
|
243
|
+
abbreviation varchar(50) default null,
|
244
|
+
description varchar(50) default null,
|
245
|
+
constraint pk_called_ids_pk primary key (id, reference_code)
|
246
|
+
);
|
@@ -41,9 +41,9 @@ create table tariffs (
|
|
41
41
|
tariff_id int not null,
|
42
42
|
start_date date not null,
|
43
43
|
amount int default null,
|
44
|
-
primary key (tariff_id, start_date),
|
45
44
|
created_at timestamp without time zone NOT NULL,
|
46
|
-
updated_at timestamp without time zone NOT NULL
|
45
|
+
updated_at timestamp without time zone NOT NULL,
|
46
|
+
primary key (tariff_id, start_date)
|
47
47
|
);
|
48
48
|
|
49
49
|
create table product_tariffs (
|
@@ -218,3 +218,12 @@ create table employees_groups (
|
|
218
218
|
employee_id int not null,
|
219
219
|
group_id int not null
|
220
220
|
);
|
221
|
+
|
222
|
+
create table pk_called_ids (
|
223
|
+
id serial not null,
|
224
|
+
reference_code int not null,
|
225
|
+
code_label varchar(50) default null,
|
226
|
+
abbreviation varchar(50) default null,
|
227
|
+
description varchar(50) default null,
|
228
|
+
primary key (id, reference_code)
|
229
|
+
);
|
@@ -204,3 +204,11 @@ create table employees_groups (
|
|
204
204
|
group_id integer not null
|
205
205
|
);
|
206
206
|
|
207
|
+
create table pk_called_ids (
|
208
|
+
id integer not null,
|
209
|
+
reference_code int not null,
|
210
|
+
code_label varchar(50) default null,
|
211
|
+
abbreviation varchar(50) default null,
|
212
|
+
description varchar(50) default null,
|
213
|
+
primary key (id, reference_code)
|
214
|
+
);
|
@@ -1,19 +1,16 @@
|
|
1
1
|
USE [composite_primary_keys_unittest];
|
2
|
-
go
|
3
2
|
|
4
3
|
CREATE TABLE topics (
|
5
4
|
id [int] IDENTITY(1000,1) NOT NULL,
|
6
5
|
name [varchar](50) default NULL,
|
7
6
|
feed_size [int] default NULL
|
8
7
|
);
|
9
|
-
go
|
10
8
|
|
11
9
|
CREATE TABLE topic_sources (
|
12
10
|
topic_id [int] NOT NULL,
|
13
11
|
platform [varchar](50) NOT NULL,
|
14
12
|
keywords [varchar](50) default NULL,
|
15
13
|
);
|
16
|
-
go
|
17
14
|
|
18
15
|
CREATE TABLE reference_types (
|
19
16
|
reference_type_id [int] IDENTITY(1000,1) NOT NULL,
|
@@ -21,7 +18,6 @@ CREATE TABLE reference_types (
|
|
21
18
|
abbreviation [varchar](50) NULL,
|
22
19
|
description [varchar](50) NULL
|
23
20
|
);
|
24
|
-
go
|
25
21
|
|
26
22
|
CREATE TABLE reference_codes (
|
27
23
|
reference_type_id [int],
|
@@ -30,22 +26,21 @@ CREATE TABLE reference_codes (
|
|
30
26
|
abbreviation [varchar](50) NULL,
|
31
27
|
description [varchar](50) NULL
|
32
28
|
);
|
33
|
-
go
|
34
29
|
|
35
30
|
CREATE TABLE products (
|
36
31
|
id [int] IDENTITY(1000,1) NOT NULL,
|
37
32
|
name [varchar](50) NULL
|
38
33
|
);
|
39
|
-
go
|
40
34
|
|
41
35
|
CREATE TABLE tariffs (
|
42
36
|
[tariff_id] [int],
|
43
37
|
[start_date] [date],
|
44
|
-
[amount] [int] NULL
|
45
|
-
|
38
|
+
[amount] [int] NULL,
|
39
|
+
[created_at] [datetimeoffset](7) NOT NULL,
|
40
|
+
[updated_at] [datetimeoffset](7) NOT NULL
|
41
|
+
CONSTRAINT [tariffs_pk] PRIMARY KEY
|
46
42
|
( [tariff_id], [start_date] )
|
47
43
|
);
|
48
|
-
go
|
49
44
|
|
50
45
|
CREATE TABLE product_tariffs (
|
51
46
|
[product_id] [int],
|
@@ -54,7 +49,6 @@ CREATE TABLE product_tariffs (
|
|
54
49
|
CONSTRAINT [product_tariffs_pk] PRIMARY KEY
|
55
50
|
( [product_id], [tariff_id], [tariff_start_date] )
|
56
51
|
);
|
57
|
-
go
|
58
52
|
|
59
53
|
CREATE TABLE suburbs (
|
60
54
|
city_id [int],
|
@@ -63,7 +57,6 @@ CREATE TABLE suburbs (
|
|
63
57
|
CONSTRAINT [suburbs_pk] PRIMARY KEY
|
64
58
|
( [city_id], [suburb_id] )
|
65
59
|
);
|
66
|
-
go
|
67
60
|
|
68
61
|
CREATE TABLE streets (
|
69
62
|
id [int] IDENTITY(1000,1) NOT NULL,
|
@@ -71,19 +64,16 @@ CREATE TABLE streets (
|
|
71
64
|
suburb_id [int] NOT NULL,
|
72
65
|
name [varchar](50) NOT NULL
|
73
66
|
);
|
74
|
-
go
|
75
67
|
|
76
68
|
CREATE TABLE users (
|
77
69
|
id [int] IDENTITY(1000,1) NOT NULL,
|
78
70
|
name varchar(50) NOT NULL
|
79
71
|
);
|
80
|
-
go
|
81
72
|
|
82
73
|
CREATE TABLE articles (
|
83
74
|
id [int] IDENTITY(1000,1) NOT NULL,
|
84
75
|
name varchar(50) NOT NULL
|
85
76
|
);
|
86
|
-
go
|
87
77
|
|
88
78
|
CREATE TABLE readings (
|
89
79
|
id [int] PRIMARY KEY,
|
@@ -91,13 +81,11 @@ CREATE TABLE readings (
|
|
91
81
|
article_id [int] NOT NULL,
|
92
82
|
rating [int] NOT NULL
|
93
83
|
);
|
94
|
-
go
|
95
84
|
|
96
85
|
CREATE TABLE groups (
|
97
86
|
id [int] IDENTITY(1000,1) NOT NULL,
|
98
87
|
name [varchar](50) NOT NULL
|
99
88
|
);
|
100
|
-
go
|
101
89
|
|
102
90
|
CREATE TABLE memberships (
|
103
91
|
user_id [int] NOT NULL,
|
@@ -105,7 +93,6 @@ CREATE TABLE memberships (
|
|
105
93
|
CONSTRAINT [memberships_pk] PRIMARY KEY
|
106
94
|
( [user_id], [group_id] )
|
107
95
|
);
|
108
|
-
go
|
109
96
|
|
110
97
|
CREATE TABLE membership_statuses (
|
111
98
|
id [int] IDENTITY(1,1) NOT NULL,
|
@@ -113,7 +100,6 @@ CREATE TABLE membership_statuses (
|
|
113
100
|
group_id [int] not null,
|
114
101
|
status varchar(50) not null
|
115
102
|
);
|
116
|
-
go
|
117
103
|
|
118
104
|
CREATE TABLE departments (
|
119
105
|
department_id [int] NOT NULL,
|
@@ -121,14 +107,12 @@ CREATE TABLE departments (
|
|
121
107
|
CONSTRAINT [departments_pk] PRIMARY KEY
|
122
108
|
( [department_id], [location_id] )
|
123
109
|
);
|
124
|
-
go
|
125
110
|
|
126
111
|
CREATE TABLE employees (
|
127
112
|
id [int] IDENTITY(1000,1) NOT NULL,
|
128
113
|
department_id [int] NULL,
|
129
114
|
location_id [int] NULL
|
130
115
|
);
|
131
|
-
go
|
132
116
|
|
133
117
|
CREATE TABLE comments (
|
134
118
|
id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
|
@@ -137,13 +121,11 @@ CREATE TABLE comments (
|
|
137
121
|
person_type varchar(100) NULL,
|
138
122
|
hack_id [int] NULL
|
139
123
|
);
|
140
|
-
go
|
141
124
|
|
142
125
|
CREATE TABLE hacks (
|
143
126
|
id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
|
144
127
|
name [varchar](50) NOT NULL
|
145
128
|
);
|
146
|
-
go
|
147
129
|
|
148
130
|
CREATE TABLE restaurants (
|
149
131
|
franchise_id [int] NOT NULL,
|
@@ -153,7 +135,6 @@ CREATE TABLE restaurants (
|
|
153
135
|
CONSTRAINT [restaurants_pk] PRIMARY KEY CLUSTERED
|
154
136
|
( [franchise_id], [store_id] )
|
155
137
|
);
|
156
|
-
go
|
157
138
|
|
158
139
|
CREATE TABLE restaurants_suburbs (
|
159
140
|
franchise_id [int] NOT NULL,
|
@@ -161,12 +142,10 @@ CREATE TABLE restaurants_suburbs (
|
|
161
142
|
city_id [int] NOT NULL,
|
162
143
|
suburb_id [int] NOT NULL
|
163
144
|
);
|
164
|
-
go
|
165
145
|
|
166
146
|
CREATE TABLE dorms (
|
167
147
|
id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
|
168
148
|
);
|
169
|
-
go
|
170
149
|
|
171
150
|
CREATE TABLE rooms (
|
172
151
|
dorm_id [int] NOT NULL,
|
@@ -174,32 +153,27 @@ CREATE TABLE rooms (
|
|
174
153
|
CONSTRAINT [rooms_pk] PRIMARY KEY CLUSTERED
|
175
154
|
( [dorm_id], [room_id] )
|
176
155
|
);
|
177
|
-
go
|
178
156
|
|
179
157
|
CREATE TABLE room_attributes (
|
180
158
|
id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
|
181
159
|
name [varchar](50)
|
182
160
|
);
|
183
|
-
go
|
184
161
|
|
185
162
|
CREATE TABLE room_attribute_assignments (
|
186
163
|
dorm_id [int] NOT NULL,
|
187
164
|
room_id [int] NOT NULL,
|
188
165
|
room_attribute_id [int] NOT NULL
|
189
166
|
);
|
190
|
-
go
|
191
167
|
|
192
168
|
CREATE TABLE students (
|
193
169
|
id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
|
194
170
|
);
|
195
|
-
go
|
196
171
|
|
197
172
|
CREATE TABLE room_assignments (
|
198
173
|
student_id [int] NOT NULL,
|
199
174
|
dorm_id [int] NOT NULL,
|
200
175
|
room_id [int] NOT NULL
|
201
176
|
);
|
202
|
-
go
|
203
177
|
|
204
178
|
CREATE TABLE seats (
|
205
179
|
flight_number [int] NOT NULL,
|
@@ -208,7 +182,6 @@ CREATE TABLE seats (
|
|
208
182
|
CONSTRAINT [seats_pk] PRIMARY KEY
|
209
183
|
( [flight_number], [seat] )
|
210
184
|
);
|
211
|
-
go
|
212
185
|
|
213
186
|
CREATE TABLE capitols (
|
214
187
|
country varchar(450) NOT NULL,
|
@@ -216,11 +189,24 @@ CREATE TABLE capitols (
|
|
216
189
|
CONSTRAINT [capitols_pk] PRIMARY KEY
|
217
190
|
( [country], [city] )
|
218
191
|
);
|
219
|
-
go
|
220
192
|
|
221
193
|
CREATE TABLE products_restaurants (
|
222
194
|
product_id [int] NOT NULL,
|
223
195
|
franchise_id [int] NOT NULL,
|
224
196
|
store_id [int] NOT NULL
|
225
197
|
);
|
226
|
-
|
198
|
+
|
199
|
+
CREATE TABLE employees_groups (
|
200
|
+
employee_id [int] not null,
|
201
|
+
group_id [int] not null
|
202
|
+
);
|
203
|
+
|
204
|
+
CREATE TABLE pk_called_ids (
|
205
|
+
id [int] IDENTITY(1000,1) NOT NULL,
|
206
|
+
reference_code [int] not null,
|
207
|
+
code_label [varchar](50) default null,
|
208
|
+
abbreviation [varchar](50) default null,
|
209
|
+
description [varchar](50) default null
|
210
|
+
CONSTRAINT [pk_called_ids_pk] PRIMARY KEY
|
211
|
+
( [id], [reference_code] )
|
212
|
+
);
|