chinook_database 0.1.4 → 0.1.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/.gitignore +1 -2
- data/README.md +105 -27
- data/lib/chinook_database/models/album.rb +2 -9
- data/lib/chinook_database/models/artist.rb +1 -7
- data/lib/chinook_database/models/customer.rb +2 -19
- data/lib/chinook_database/models/employee.rb +2 -21
- data/lib/chinook_database/models/genre.rb +1 -7
- data/lib/chinook_database/models/invoice.rb +2 -15
- data/lib/chinook_database/models/invoice_line.rb +2 -10
- data/lib/chinook_database/models/media_type.rb +1 -7
- data/lib/chinook_database/models/playlist.rb +1 -7
- data/lib/chinook_database/models/track.rb +4 -18
- data/lib/chinook_database/version.rb +1 -1
- data/lib/db/Chinook.sqlite +0 -0
- data/lib/db/Chinook_Sqlite_AutoIncrementPKs.sql +15704 -15729
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 420ea1d79fda8bb20be6b0d9694d868617faf815
|
4
|
+
data.tar.gz: f742dcfd7893b41a1d74b0c3f0fb0e4af2cf9b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfaf4f2182a721e4a3ff303efe0ff53a428fd78338817e4eda55e362d2b3f9e6875d5296e758527ab1f69ef0e2a937b0fb0bdaae5fcc30ec5d99bef3ba449d4e
|
7
|
+
data.tar.gz: 904a9a6a15e0080dfe80c7c3531fe7aa4c4bbd3fd214a73f76b6d006478fd5d646ea8a941b681dd6b5749de65325771e92d7cac61bebb8f28b5f64295efd35d5
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# ChinookDatabase
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
The Chinook database is an open source sample database that represents a store selling music tracks to customers.
|
4
|
+
It can be useful as test fixtures for other gems and libraries requiring sample data.
|
5
|
+
|
6
|
+
See official site: https://chinookdatabase.codeplex.com/.
|
7
|
+
|
8
|
+
This gem contains the sample sqlite database that was adapted to conform with ActiveRecord standards,
|
9
|
+
as well as ActiveRecord wrapper classes.
|
5
10
|
|
6
11
|
## Installation
|
7
12
|
|
@@ -30,35 +35,106 @@ require 'chinook_database'
|
|
30
35
|
# ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ChinookDatabase.path
|
31
36
|
ChinookDatabase.connect
|
32
37
|
|
33
|
-
Album.count
|
34
|
-
# => 347
|
35
|
-
|
36
38
|
Artist.count
|
37
39
|
# => 275
|
40
|
+
```
|
38
41
|
|
39
|
-
|
40
|
-
# => 59
|
41
|
-
|
42
|
-
Employee.count
|
43
|
-
# => 8
|
44
|
-
|
45
|
-
Genre.count
|
46
|
-
# => 25
|
47
|
-
|
48
|
-
Invoice.count
|
49
|
-
# => 412
|
50
|
-
|
51
|
-
InvoiceLine.count
|
52
|
-
# => 2240
|
53
|
-
|
54
|
-
MediaType.count
|
55
|
-
# => 5
|
56
|
-
|
57
|
-
Playlist.count
|
58
|
-
# => 18
|
42
|
+
## The Schema
|
59
43
|
|
60
|
-
|
61
|
-
#
|
44
|
+
```
|
45
|
+
# Artists, albums and tracks
|
46
|
+
|
47
|
+
genres
|
48
|
+
id
|
49
|
+
name
|
50
|
+
|
51
|
+
media_types
|
52
|
+
id
|
53
|
+
name
|
54
|
+
|
55
|
+
artists
|
56
|
+
id
|
57
|
+
name
|
58
|
+
|
59
|
+
albums
|
60
|
+
id
|
61
|
+
title
|
62
|
+
artist_id
|
63
|
+
|
64
|
+
tracks
|
65
|
+
id
|
66
|
+
name
|
67
|
+
album_id
|
68
|
+
media_type_id
|
69
|
+
genre_id
|
70
|
+
composer
|
71
|
+
milliseconds
|
72
|
+
bytes
|
73
|
+
unit_price
|
74
|
+
|
75
|
+
# Playlists and tracks they contain
|
76
|
+
|
77
|
+
playlists
|
78
|
+
id
|
79
|
+
name
|
80
|
+
|
81
|
+
playlists_tracks
|
82
|
+
playlist_id
|
83
|
+
track_id
|
84
|
+
|
85
|
+
# Employees and reporting structure
|
86
|
+
|
87
|
+
employees
|
88
|
+
id
|
89
|
+
last_name
|
90
|
+
first_name
|
91
|
+
title
|
92
|
+
reports_to_employee_id (employee)
|
93
|
+
birth_date
|
94
|
+
hire_date
|
95
|
+
address
|
96
|
+
city
|
97
|
+
state
|
98
|
+
country
|
99
|
+
postal_code
|
100
|
+
phone
|
101
|
+
fax
|
102
|
+
email
|
103
|
+
|
104
|
+
# Customers and invoices
|
105
|
+
|
106
|
+
customers
|
107
|
+
id
|
108
|
+
first_name
|
109
|
+
last_name
|
110
|
+
company
|
111
|
+
address
|
112
|
+
city
|
113
|
+
state
|
114
|
+
country
|
115
|
+
postal_code
|
116
|
+
phone
|
117
|
+
fax
|
118
|
+
email
|
119
|
+
support_rep_id (employee)
|
120
|
+
|
121
|
+
invoices
|
122
|
+
id
|
123
|
+
customer_id
|
124
|
+
invoice_date
|
125
|
+
billing_address
|
126
|
+
billing_city
|
127
|
+
billing_state
|
128
|
+
billing_country
|
129
|
+
billing_postal_code
|
130
|
+
total
|
131
|
+
|
132
|
+
invoice_lines
|
133
|
+
id
|
134
|
+
invoice_id
|
135
|
+
track_id
|
136
|
+
unit_price
|
137
|
+
quantity
|
62
138
|
```
|
63
139
|
|
64
140
|
## Development
|
@@ -67,6 +143,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
67
143
|
|
68
144
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
69
145
|
|
146
|
+
To build the sqlite db from the sql file run: `cat lib/db/Chinook_Sqlite_AutoIncrementPKs.sql | sqlite3 lib/db/Chinook.sqlite`
|
147
|
+
|
70
148
|
## Contributing
|
71
149
|
|
72
150
|
1. Fork it ( https://github.com/[my-github-username]/chinook_database/fork )
|
@@ -1,11 +1,4 @@
|
|
1
1
|
class Album < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
alias_attribute :id, 'AlbumId'
|
6
|
-
alias_attribute :title, 'Title'
|
7
|
-
alias_attribute :artist_id, 'ArtistId'
|
8
|
-
|
9
|
-
belongs_to :artist, foreign_key: 'ArtistId'
|
10
|
-
has_many :tracks, foreign_key: 'AlbumId'
|
2
|
+
belongs_to :artist
|
3
|
+
has_many :tracks
|
11
4
|
end
|
@@ -1,21 +1,4 @@
|
|
1
1
|
class Customer < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
alias_attribute :id, 'CustomerId'
|
6
|
-
alias_attribute :first_name, 'FirstName'
|
7
|
-
alias_attribute :last_name, 'LastName'
|
8
|
-
alias_attribute :company, 'Company'
|
9
|
-
alias_attribute :address, 'Address'
|
10
|
-
alias_attribute :city, 'City'
|
11
|
-
alias_attribute :state, 'State'
|
12
|
-
alias_attribute :country, 'Country'
|
13
|
-
alias_attribute :postal_code, 'PostalCode'
|
14
|
-
alias_attribute :phone, 'Phone'
|
15
|
-
alias_attribute :fax, 'Fax'
|
16
|
-
alias_attribute :email, 'Email'
|
17
|
-
alias_attribute :support_rep_id, 'SupportRepId'
|
18
|
-
|
19
|
-
belongs_to :support_rep, class_name: 'Employee', foreign_key: 'SupportRepId'
|
20
|
-
has_many :invoices, foreign_key: 'CustomerId'
|
2
|
+
belongs_to :support_rep, class_name: 'Employee', foreign_key: 'support_rep_id'
|
3
|
+
has_many :invoices
|
21
4
|
end
|
@@ -1,23 +1,4 @@
|
|
1
1
|
class Employee < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
alias_attribute :id, 'EmployeeId'
|
6
|
-
alias_attribute :last_name, 'LastName'
|
7
|
-
alias_attribute :first_name, 'FirstName'
|
8
|
-
alias_attribute :title, 'Title'
|
9
|
-
alias_attribute :reports_to_id, 'ReportsTo'
|
10
|
-
alias_attribute :birth_date, 'BirthDate'
|
11
|
-
alias_attribute :hire_date, 'HireDate'
|
12
|
-
alias_attribute :address, 'Address'
|
13
|
-
alias_attribute :city, 'City'
|
14
|
-
alias_attribute :state, 'State'
|
15
|
-
alias_attribute :country, 'Country'
|
16
|
-
alias_attribute :postal_code, 'PostalCode'
|
17
|
-
alias_attribute :phone, 'Phone'
|
18
|
-
alias_attribute :fax, 'Fax'
|
19
|
-
alias_attribute :email, 'Email'
|
20
|
-
|
21
|
-
belongs_to :reports_to, class_name: 'Employee', foreign_key: 'ReportsTo'
|
22
|
-
has_many :customers, foreign_key: 'SupportRepId'
|
2
|
+
belongs_to :reports_to, class_name: 'Employee', foreign_key: 'reports_to_employee_id'
|
3
|
+
has_many :customers, foreign_key: 'support_rep_id'
|
23
4
|
end
|
@@ -1,17 +1,4 @@
|
|
1
1
|
class Invoice < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
alias_attribute :id, 'InvoiceId'
|
6
|
-
alias_attribute :customer_id, 'CustomerId'
|
7
|
-
alias_attribute :invoice_date, 'InvoiceDate'
|
8
|
-
alias_attribute :billing_address, 'BillingAddress'
|
9
|
-
alias_attribute :billing_city, 'BillingCity'
|
10
|
-
alias_attribute :billing_state, 'BillingState'
|
11
|
-
alias_attribute :billing_country, 'BillingCountry'
|
12
|
-
alias_attribute :billing_postal_code, 'BillingPostalCode'
|
13
|
-
alias_attribute :total, 'Total'
|
14
|
-
|
15
|
-
belongs_to :customer, foreign_key: 'CustomerId'
|
16
|
-
has_many :invoice_lines, foreign_key: 'InvoiceId'
|
2
|
+
belongs_to :customer
|
3
|
+
has_many :invoice_lines
|
17
4
|
end
|
@@ -1,12 +1,4 @@
|
|
1
1
|
class InvoiceLine < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
alias_attribute :id, 'InvoiceLineId'
|
6
|
-
alias_attribute :invoice_id, 'InvoiceId'
|
7
|
-
alias_attribute :track_id, 'TrackId'
|
8
|
-
alias_attribute :unit_price, 'UnitPrice'
|
9
|
-
alias_attribute :quantity, 'Quantity'
|
10
|
-
|
11
|
-
belongs_to :invoice, foreign_key: 'InvoiceId'
|
2
|
+
belongs_to :invoice
|
3
|
+
belongs_to :track
|
12
4
|
end
|
@@ -1,9 +1,3 @@
|
|
1
1
|
class Playlist < ActiveRecord::Base
|
2
|
-
|
3
|
-
self.primary_key = 'PlaylistId'
|
4
|
-
|
5
|
-
alias_attribute :id, 'PlaylistId'
|
6
|
-
alias_attribute :name, 'Name'
|
7
|
-
|
8
|
-
has_and_belongs_to_many :tracks, join_table: 'PlaylistTrack', foreign_key: 'PlaylistId', association_foreign_key: 'TrackId'
|
2
|
+
has_and_belongs_to_many :tracks
|
9
3
|
end
|
@@ -1,20 +1,6 @@
|
|
1
1
|
class Track < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
alias_attribute :name, 'Name'
|
7
|
-
alias_attribute :album_id, 'AlbumId'
|
8
|
-
alias_attribute :media_type_id, 'MediaTypeId'
|
9
|
-
alias_attribute :genre_id, 'GenreId'
|
10
|
-
alias_attribute :composer, 'Composer'
|
11
|
-
alias_attribute :milliseconds, 'Milliseconds'
|
12
|
-
alias_attribute :bytes, 'Bytes'
|
13
|
-
alias_attribute :unit_price, 'UnitPrice'
|
14
|
-
|
15
|
-
belongs_to :album, foreign_key: 'AlbumId'
|
16
|
-
belongs_to :media_type, foreign_key: 'MediaTypeId'
|
17
|
-
belongs_to :genre, foreign_key: 'GenreId'
|
18
|
-
|
19
|
-
has_and_belongs_to_many :playlists, join_table: 'PlaylistTrack', foreign_key: 'TrackId', association_foreign_key: 'PlaylistId'
|
2
|
+
belongs_to :album
|
3
|
+
belongs_to :media_type
|
4
|
+
belongs_to :genre
|
5
|
+
has_and_belongs_to_many :playlists
|
20
6
|
end
|
data/lib/db/Chinook.sqlite
CHANGED
Binary file
|