globe-composite_primary_keys 3.0.1

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.
Files changed (150) hide show
  1. data/History.txt +203 -0
  2. data/Manifest.txt +121 -0
  3. data/README.txt +41 -0
  4. data/README_DB2.txt +33 -0
  5. data/Rakefile +30 -0
  6. data/composite_primary_keys.gemspec +17 -0
  7. data/lib/adapter_helper/base.rb +63 -0
  8. data/lib/adapter_helper/mysql.rb +13 -0
  9. data/lib/adapter_helper/oracle.rb +12 -0
  10. data/lib/adapter_helper/oracle_enhanced.rb +12 -0
  11. data/lib/adapter_helper/postgresql.rb +13 -0
  12. data/lib/adapter_helper/sqlite3.rb +13 -0
  13. data/lib/composite_primary_keys.rb +63 -0
  14. data/lib/composite_primary_keys/association_preload.rb +162 -0
  15. data/lib/composite_primary_keys/associations.rb +159 -0
  16. data/lib/composite_primary_keys/attribute_methods.rb +84 -0
  17. data/lib/composite_primary_keys/base.rb +200 -0
  18. data/lib/composite_primary_keys/composite_arrays.rb +29 -0
  19. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +9 -0
  20. data/lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb +21 -0
  21. data/lib/composite_primary_keys/connection_adapters/oracle_adapter.rb +15 -0
  22. data/lib/composite_primary_keys/connection_adapters/oracle_enhanced_adapter.rb +17 -0
  23. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +53 -0
  24. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +15 -0
  25. data/lib/composite_primary_keys/finder_methods.rb +68 -0
  26. data/lib/composite_primary_keys/fixtures.rb +8 -0
  27. data/lib/composite_primary_keys/read.rb +25 -0
  28. data/lib/composite_primary_keys/reflection.rb +39 -0
  29. data/lib/composite_primary_keys/relation.rb +31 -0
  30. data/lib/composite_primary_keys/through_association_scope.rb +212 -0
  31. data/lib/composite_primary_keys/validations/uniqueness.rb +118 -0
  32. data/lib/composite_primary_keys/version.rb +9 -0
  33. data/loader.rb +24 -0
  34. data/local/database_connections.rb.sample +12 -0
  35. data/local/paths.rb.sample +2 -0
  36. data/local/tasks.rb.sample +2 -0
  37. data/scripts/console.rb +48 -0
  38. data/scripts/txt2html +67 -0
  39. data/scripts/txt2js +59 -0
  40. data/tasks/activerecord_selection.rake +43 -0
  41. data/tasks/databases.rake +12 -0
  42. data/tasks/databases/mysql.rake +30 -0
  43. data/tasks/databases/oracle.rake +25 -0
  44. data/tasks/databases/postgresql.rake +25 -0
  45. data/tasks/databases/sqlite3.rake +28 -0
  46. data/tasks/deployment.rake +22 -0
  47. data/tasks/local_setup.rake +13 -0
  48. data/tasks/website.rake +18 -0
  49. data/test/README_tests.txt +67 -0
  50. data/test/abstract_unit.rb +103 -0
  51. data/test/connections/native_ibm_db/connection.rb +23 -0
  52. data/test/connections/native_mysql/connection.rb +13 -0
  53. data/test/connections/native_oracle/connection.rb +14 -0
  54. data/test/connections/native_oracle_enhanced/connection.rb +20 -0
  55. data/test/connections/native_postgresql/connection.rb +8 -0
  56. data/test/connections/native_sqlite/connection.rb +9 -0
  57. data/test/fixtures/article.rb +5 -0
  58. data/test/fixtures/article_group.rb +4 -0
  59. data/test/fixtures/article_groups.yml +7 -0
  60. data/test/fixtures/articles.yml +6 -0
  61. data/test/fixtures/comment.rb +6 -0
  62. data/test/fixtures/comments.yml +16 -0
  63. data/test/fixtures/db_definitions/db2-create-tables.sql +113 -0
  64. data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -0
  65. data/test/fixtures/db_definitions/mysql.sql +181 -0
  66. data/test/fixtures/db_definitions/oracle.drop.sql +39 -0
  67. data/test/fixtures/db_definitions/oracle.sql +188 -0
  68. data/test/fixtures/db_definitions/postgresql.sql +206 -0
  69. data/test/fixtures/db_definitions/sqlite.sql +166 -0
  70. data/test/fixtures/department.rb +5 -0
  71. data/test/fixtures/departments.yml +3 -0
  72. data/test/fixtures/dorm.rb +3 -0
  73. data/test/fixtures/dorms.yml +2 -0
  74. data/test/fixtures/employee.rb +4 -0
  75. data/test/fixtures/employees.yml +9 -0
  76. data/test/fixtures/group.rb +3 -0
  77. data/test/fixtures/groups.yml +3 -0
  78. data/test/fixtures/hack.rb +6 -0
  79. data/test/fixtures/hacks.yml +2 -0
  80. data/test/fixtures/kitchen_sink.rb +3 -0
  81. data/test/fixtures/kitchen_sinks.yml +5 -0
  82. data/test/fixtures/membership.rb +10 -0
  83. data/test/fixtures/membership_status.rb +3 -0
  84. data/test/fixtures/membership_statuses.yml +10 -0
  85. data/test/fixtures/memberships.yml +6 -0
  86. data/test/fixtures/product.rb +7 -0
  87. data/test/fixtures/product_tariff.rb +5 -0
  88. data/test/fixtures/product_tariffs.yml +12 -0
  89. data/test/fixtures/products.yml +6 -0
  90. data/test/fixtures/reading.rb +4 -0
  91. data/test/fixtures/readings.yml +10 -0
  92. data/test/fixtures/reference_code.rb +7 -0
  93. data/test/fixtures/reference_codes.yml +28 -0
  94. data/test/fixtures/reference_type.rb +7 -0
  95. data/test/fixtures/reference_types.yml +9 -0
  96. data/test/fixtures/restaurant.rb +6 -0
  97. data/test/fixtures/restaurants.yml +5 -0
  98. data/test/fixtures/restaurants_suburbs.yml +11 -0
  99. data/test/fixtures/room.rb +10 -0
  100. data/test/fixtures/room_assignment.rb +4 -0
  101. data/test/fixtures/room_assignments.yml +4 -0
  102. data/test/fixtures/room_attribute.rb +3 -0
  103. data/test/fixtures/room_attribute_assignment.rb +5 -0
  104. data/test/fixtures/room_attribute_assignments.yml +4 -0
  105. data/test/fixtures/room_attributes.yml +3 -0
  106. data/test/fixtures/rooms.yml +3 -0
  107. data/test/fixtures/seat.rb +5 -0
  108. data/test/fixtures/seats.yml +4 -0
  109. data/test/fixtures/street.rb +3 -0
  110. data/test/fixtures/streets.yml +15 -0
  111. data/test/fixtures/student.rb +4 -0
  112. data/test/fixtures/students.yml +2 -0
  113. data/test/fixtures/suburb.rb +6 -0
  114. data/test/fixtures/suburbs.yml +9 -0
  115. data/test/fixtures/tariff.rb +6 -0
  116. data/test/fixtures/tariffs.yml +13 -0
  117. data/test/fixtures/user.rb +10 -0
  118. data/test/fixtures/users.yml +6 -0
  119. data/test/hash_tricks.rb +34 -0
  120. data/test/plugins/pagination.rb +405 -0
  121. data/test/plugins/pagination_helper.rb +135 -0
  122. data/test/test_associations.rb +178 -0
  123. data/test/test_attribute_methods.rb +22 -0
  124. data/test/test_attributes.rb +80 -0
  125. data/test/test_clone.rb +34 -0
  126. data/test/test_composite_arrays.rb +32 -0
  127. data/test/test_create.rb +68 -0
  128. data/test/test_delete.rb +83 -0
  129. data/test/test_exists.rb +25 -0
  130. data/test/test_find.rb +73 -0
  131. data/test/test_ids.rb +90 -0
  132. data/test/test_miscellaneous.rb +39 -0
  133. data/test/test_pagination.rb +38 -0
  134. data/test/test_polymorphic.rb +32 -0
  135. data/test/test_santiago.rb +27 -0
  136. data/test/test_suite.rb +19 -0
  137. data/test/test_tutorial_example.rb +26 -0
  138. data/test/test_update.rb +40 -0
  139. data/test/test_validations.rb +11 -0
  140. data/website/index.html +195 -0
  141. data/website/index.txt +159 -0
  142. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  143. data/website/stylesheets/screen.css +126 -0
  144. data/website/template.js +3 -0
  145. data/website/template.rhtml +53 -0
  146. data/website/version-raw.js +3 -0
  147. data/website/version-raw.txt +2 -0
  148. data/website/version.js +4 -0
  149. data/website/version.txt +3 -0
  150. metadata +339 -0
@@ -0,0 +1,18 @@
1
+ desc 'Generate website files'
2
+ task :website_generate do
3
+ sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
4
+ sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
5
+ sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
11
+ host = "#{config["username"]}@rubyforge.org"
12
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
13
+ local_dir = 'website'
14
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
15
+ end
16
+
17
+ desc 'Generate and upload website files'
18
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,67 @@
1
+ = Composite Primary Keys - Testing Readme
2
+
3
+ == Testing an adapter
4
+
5
+ There are tests available for the following adapters:
6
+
7
+ * ibmdb
8
+ * mysql
9
+ * oracle
10
+ * postgresql
11
+ * sqlite
12
+
13
+ To run the tests for on of the adapters, follow these steps (using mysql in the example):
14
+
15
+ * rake -T | grep mysql
16
+
17
+ rake mysql:build_databases # Build the MySQL test databases
18
+ rake mysql:drop_databases # Drop the MySQL test databases
19
+ rake mysql:rebuild_databases # Rebuild the MySQL test databases
20
+ rake test_mysql # Run tests for test_mysql
21
+
22
+ * rake mysql:build_databases
23
+ * rake test_mysql
24
+
25
+ == Testing against different ActiveRecord versions (or Edge Rails)
26
+
27
+ ActiveRecord is a RubyGem within Rails, and is constantly being improved/changed on
28
+ its repository (http://dev.rubyonrails.org). These changes may create errors for the CPK
29
+ gem. So, we need a way to test CPK against Edge Rails, as well as officially released RubyGems.
30
+
31
+ The default test (as above) uses the latest RubyGem in your cache.
32
+
33
+ You can select an older RubyGem version by running the following:
34
+
35
+ * rake ar:set VERSION=1.14.4 test_mysql
36
+
37
+ == Edge Rails
38
+
39
+ Before you can test CPK against Edge Rails, you must checkout a copy of edge rails somewhere (see http://dev.rubyonrails.org for for examples)
40
+
41
+ * cd /path/to/gems
42
+ * svn co http://svn.rubyonrails.org/rails/trunk rails
43
+
44
+ Say the rails folder is /path/to/gems/rails
45
+
46
+ Three ways to run CPK tests for Edge Rails:
47
+
48
+ i) Run:
49
+
50
+ EDGE_RAILS_DIR=/path/to/gems/rails rake ar:edge test_mysql
51
+
52
+ ii) In your .profile, set the environment variable EDGE_RAILS_DIR=/path/to/gems/rails,
53
+ and once you reload your profile, run:
54
+
55
+ rake ar:edge test_mysql
56
+
57
+ iii) Store the path in local/paths.rb. Run:
58
+
59
+ cp local/paths.rb.sample local/paths.rb
60
+ # Now set ENV['EDGE_RAILS_DIR']=/path/to/gems/rails
61
+ rake ar:edge test_mysql
62
+
63
+ These are all variations of the same theme:
64
+
65
+ * Set the environment variable EDGE_RAILS_DIR to the path to Rails (which contains the activerecord/lib folder)
66
+ * Run: rake ar:edge test_<adapter>
67
+
@@ -0,0 +1,103 @@
1
+ $:.unshift(ENV['AR_LOAD_PATH']) if ENV['AR_LOAD_PATH']
2
+
3
+ dir = File.dirname(__FILE__)
4
+ cpk_top = File.expand_path(File.join(dir, '..'))
5
+ cpk_root = File.join(cpk_top, 'lib')
6
+ $:.unshift(cpk_root)
7
+
8
+ require 'test/unit'
9
+ require 'hash_tricks'
10
+ require 'rubygems'
11
+ require 'active_record'
12
+ require 'active_record/fixtures'
13
+ require File.join(cpk_top, 'local', 'database_connections')
14
+ begin
15
+ require 'connection'
16
+ rescue MissingSourceFile => e
17
+ adapter = 'postgresql' #'sqlite'
18
+ require File.join(cpk_top, "test", "connections", "native_#{adapter}", "connection")
19
+ end
20
+ require 'composite_primary_keys'
21
+
22
+ QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
23
+
24
+ class ActiveSupport::TestCase #:nodoc:
25
+ include ActiveRecord::TestFixtures
26
+
27
+ self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
28
+ self.use_instantiated_fixtures = false
29
+ self.use_transactional_fixtures = true
30
+
31
+ def assert_date_from_db(expected, actual, message = nil)
32
+ # SQL Server doesn't have a separate column type just for dates,
33
+ # so the time is in the string and incorrectly formatted
34
+ if current_adapter?(:SQLServerAdapter)
35
+ assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00")
36
+ elsif current_adapter?(:SybaseAdapter)
37
+ assert_equal expected.to_s, actual.to_date.to_s, message
38
+ else
39
+ assert_equal expected.to_s, actual.to_s, message
40
+ end
41
+ end
42
+
43
+ def assert_queries(num = 1)
44
+ ActiveRecord::Base.connection.class.class_eval do
45
+ self.query_count = 0
46
+ alias_method :execute, :execute_with_query_counting
47
+ end
48
+ yield
49
+ ensure
50
+ ActiveRecord::Base.connection.class.class_eval do
51
+ alias_method :execute, :execute_without_query_counting
52
+ end
53
+ assert_equal num, ActiveRecord::Base.connection.query_count, "#{ActiveRecord::Base.connection.query_count} instead of #{num} queries were executed."
54
+ end
55
+
56
+ def assert_no_queries(&block)
57
+ assert_queries(0, &block)
58
+ end
59
+
60
+ cattr_accessor :classes
61
+ protected
62
+
63
+ def testing_with(&block)
64
+ classes.keys.each do |key_test|
65
+ @key_test = key_test
66
+ @klass_info = classes[@key_test]
67
+ @klass, @primary_keys = @klass_info[:class], @klass_info[:primary_keys]
68
+ order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
69
+ @first = @klass.find(:first, :order => order)
70
+ yield
71
+ end
72
+ end
73
+
74
+ def first_id
75
+ ids = (1..@primary_keys.length).map {|num| 1}
76
+ composite? ? ids.to_composite_ids : ids.first
77
+ end
78
+
79
+ def first_id_str
80
+ first_id.to_s
81
+ end
82
+
83
+ def composite?
84
+ @key_test != :single
85
+ end
86
+ end
87
+
88
+ def current_adapter?(type)
89
+ ActiveRecord::ConnectionAdapters.const_defined?(type) &&
90
+ ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
91
+ end
92
+
93
+ ActiveRecord::Base.connection.class.class_eval do
94
+ cattr_accessor :query_count
95
+ alias_method :execute_without_query_counting, :execute
96
+ def execute_with_query_counting(sql, name = nil)
97
+ self.query_count += 1
98
+ execute_without_query_counting(sql, name)
99
+ end
100
+ end
101
+
102
+ #ActiveRecord::Base.logger = Logger.new(STDOUT)
103
+ #ActiveRecord::Base.colorize_logging = false
@@ -0,0 +1,23 @@
1
+ print "Using IBM2 \n"
2
+ require 'logger'
3
+
4
+ gem 'ibm_db'
5
+ require 'IBM_DB'
6
+
7
+ RAILS_CONNECTION_ADAPTERS = %w( mysql postgresql sqlite firebird sqlserver db2 oracle sybase openbase frontbase ibm_db )
8
+
9
+
10
+ ActiveRecord::Base.logger = Logger.new("debug.log")
11
+
12
+ db1 = 'composite_primary_keys_unittest'
13
+
14
+ connection_options = {
15
+ :adapter => "ibm_db",
16
+ :database => "ocdpdev",
17
+ :username => "db2inst1",
18
+ :password => "password",
19
+ :host => '192.168.2.21'
20
+ }
21
+
22
+ ActiveRecord::Base.configurations = { db1 => connection_options }
23
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,13 @@
1
+ print "Using native MySQL\n"
2
+ require 'fileutils'
3
+ require 'logger'
4
+ require 'adapter_helper/mysql'
5
+
6
+ log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
7
+ FileUtils.mkdir_p log_path
8
+ puts "Logging to #{log_path}/debug.log"
9
+ ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
10
+
11
+ # Adapter config setup in locals/database_connections.rb
12
+ connection_options = AdapterHelper::MySQL.load_connection_from_env
13
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,14 @@
1
+ print "Using native Oracle\n"
2
+ require 'fileutils'
3
+ require 'logger'
4
+ require 'adapter_helper/oracle'
5
+
6
+ log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
7
+ FileUtils.mkdir_p log_path
8
+ puts "Logging to #{log_path}/debug.log"
9
+ ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
10
+
11
+ # Adapter config setup in locals/database_connections.rb
12
+ connection_options = AdapterHelper::Oracle.load_connection_from_env
13
+ puts connection_options.inspect
14
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,20 @@
1
+ print "Using native Oracle Enhanced\n"
2
+ require 'fileutils'
3
+ require 'logger'
4
+ require 'adapter_helper/oracle_enhanced'
5
+
6
+ log_path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. log]))
7
+ FileUtils.mkdir_p log_path
8
+ puts "Logging to #{log_path}/debug.log"
9
+ ActiveRecord::Base.logger = Logger.new("#{log_path}/debug.log")
10
+ ActiveRecord::Base.logger.level = Logger::DEBUG
11
+
12
+ # Adapter config setup in locals/database_connections.rb
13
+ connection_options = AdapterHelper::OracleEnhanced.load_connection_from_env
14
+ puts connection_options.inspect
15
+ ActiveRecord::Base.establish_connection(connection_options)
16
+
17
+ # Change default options for Oracle Enhanced adapter
18
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
19
+ # Change NLS_DATE_FORMAT to non-default format to verify that all tests should pass
20
+ ActiveRecord::Base.connection.execute %q{alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'}
@@ -0,0 +1,8 @@
1
+ print "Using native Postgresql\n"
2
+ require 'logger'
3
+ require 'adapter_helper/postgresql'
4
+
5
+ ActiveRecord::Base.logger = Logger.new("debug.log")
6
+ # Adapter config setup in locals/database_connections.rb
7
+ connection_options = AdapterHelper::Postgresql.load_connection_from_env
8
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,9 @@
1
+ print "Using native Sqlite3\n"
2
+ require 'logger'
3
+ require 'adapter_helper/sqlite3'
4
+
5
+ ActiveRecord::Base.logger = Logger.new("debug.log")
6
+
7
+ # Adapter config setup in locals/database_connections.rb
8
+ connection_options = AdapterHelper::Sqlite3.load_connection_from_env
9
+ ActiveRecord::Base.establish_connection(connection_options)
@@ -0,0 +1,5 @@
1
+ class Article < ActiveRecord::Base
2
+ has_many :readings
3
+ has_many :users, :through => :readings
4
+ end
5
+
@@ -0,0 +1,4 @@
1
+ class ArticleGroup < ActiveRecord::Base
2
+ belongs_to :article
3
+ belongs_to :group
4
+ end
@@ -0,0 +1,7 @@
1
+ cpk:
2
+ article_id: 1
3
+ group_id: 1
4
+
5
+ transformers:
6
+ article_id: 1
7
+ group_id: 2
@@ -0,0 +1,6 @@
1
+ first:
2
+ id: 1
3
+ name: Article One
4
+ second:
5
+ id: 2
6
+ name: Article Two
@@ -0,0 +1,6 @@
1
+ class Comment < ActiveRecord::Base
2
+ set_primary_keys :id
3
+ belongs_to :person, :polymorphic => true
4
+ belongs_to :hack
5
+ end
6
+
@@ -0,0 +1,16 @@
1
+ comment1:
2
+ id: 1
3
+ person_id: 1
4
+ person_type: Employee
5
+
6
+ comment2:
7
+ id: 2
8
+ person_id: 1
9
+ person_type: User
10
+ hack_id: andrew
11
+
12
+ comment3:
13
+ id: 3
14
+ person_id: andrew
15
+ person_type: Hack
16
+
@@ -0,0 +1,113 @@
1
+ CREATE TABLE reference_types (
2
+ reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
3
+ type_label varchar(50) default NULL,
4
+ abbreviation varchar(50) default NULL,
5
+ description varchar(50) default NULL,
6
+ PRIMARY KEY (reference_type_id)
7
+ );
8
+
9
+ CREATE TABLE reference_codes (
10
+ reference_type_id integer,
11
+ reference_code integer NOT NULL,
12
+ code_label varchar(50) default NULL,
13
+ abbreviation varchar(50) default NULL,
14
+ description varchar(50) default NULL,
15
+ PRIMARY KEY (reference_type_id,reference_code)
16
+ );
17
+
18
+ CREATE TABLE products (
19
+ id integer NOT NULL,
20
+ name varchar(50) default NULL,
21
+ PRIMARY KEY (id)
22
+ );
23
+
24
+ CREATE TABLE tariffs (
25
+ tariff_id integer NOT NULL,
26
+ start_date date NOT NULL,
27
+ amount integer default NULL,
28
+ PRIMARY KEY (tariff_id,start_date)
29
+ );
30
+
31
+ CREATE TABLE product_tariffs (
32
+ product_id integer NOT NULL,
33
+ tariff_id integer NOT NULL,
34
+ tariff_start_date date NOT NULL,
35
+ PRIMARY KEY (product_id,tariff_id,tariff_start_date)
36
+ );
37
+
38
+ CREATE TABLE suburbs (
39
+ city_id integer NOT NULL,
40
+ suburb_id integer NOT NULL,
41
+ name varchar(50) NOT NULL,
42
+ PRIMARY KEY (city_id,suburb_id)
43
+ );
44
+
45
+ CREATE TABLE streets (
46
+ id integer NOT NULL ,
47
+ city_id integer NOT NULL,
48
+ suburb_id integer NOT NULL,
49
+ name varchar(50) NOT NULL,
50
+ PRIMARY KEY (id)
51
+ );
52
+
53
+ CREATE TABLE users (
54
+ id integer NOT NULL ,
55
+ name varchar(50) NOT NULL,
56
+ PRIMARY KEY (id)
57
+ );
58
+
59
+ CREATE TABLE articles (
60
+ id integer NOT NULL ,
61
+ name varchar(50) NOT NULL,
62
+ PRIMARY KEY (id)
63
+ );
64
+
65
+ CREATE TABLE readings (
66
+ id integer NOT NULL ,
67
+ user_id integer NOT NULL,
68
+ article_id integer NOT NULL,
69
+ rating integer NOT NULL,
70
+ PRIMARY KEY (id)
71
+ );
72
+
73
+ CREATE TABLE groups (
74
+ id integer NOT NULL ,
75
+ name varchar(50) NOT NULL,
76
+ PRIMARY KEY (id)
77
+ );
78
+
79
+ CREATE TABLE memberships (
80
+ user_id integer NOT NULL,
81
+ group_id integer NOT NULL,
82
+ PRIMARY KEY (user_id,group_id)
83
+ );
84
+
85
+ CREATE TABLE membership_statuses (
86
+ id integer NOT NULL ,
87
+ user_id integer NOT NULL,
88
+ group_id integer NOT NULL,
89
+ status varchar(50) NOT NULL,
90
+ PRIMARY KEY (id)
91
+ );
92
+
93
+ create table kitchen_sinks (
94
+ id_1 integer not null,
95
+ id_2 integer not null,
96
+ a_date date,
97
+ a_string varchar(100),
98
+ primary key (id_1, id_2)
99
+ );
100
+
101
+ create table restaurants (
102
+ franchise_id integer not null,
103
+ store_id integer not null,
104
+ name varchar(100),
105
+ primary key (franchise_id, store_id)
106
+ );
107
+
108
+ create table restaurants_suburbs (
109
+ franchise_id integer not null,
110
+ store_id integer not null,
111
+ city_id integer not null,
112
+ suburb_id integer not null
113
+ );