Ich habe eine EC-Site mit Ruby on Rails (-v 5.2) erstellt. Dieses Mal werde ich schreiben, dass ich damals so etwas am DB-Design getan habe.
Ich habe auf der obigen Site auf "Überprüfen des Systemszenarios" verwiesen.
Wie folgt.
--Verwenden Sie den Fallnamen: Der Kunde bestellt einen Artikel --Übersicht: Bestellen Sie Produkte auf der EC-Website
Ich habe in den frühen Phasen darüber nachgedacht, aber seit ich damit angefangen habe, habe ich es entsprechend geändert. Die Zahlungsmethode ist auch nur eine Kreditkarte (mit PAY.JP).
Ich war besorgt darüber, was ich mit der Warenkorbtabelle für die Wagenfunktion, die eine wesentliche Funktion auf der EC-Website ist, und der Bestelldetailtabelle tun sollte, aber ich ließ sie als Zwischentabelle mit dem folgenden Gefühl fallen.
Für die Warenkorbtabelle gibt es keine anderen Spalten als PK, da sie nur als Warenkorb dient. Ich habe es im Anwendungsfall nicht erwähnt, aber ich habe keine Benutzer-ID (FK), da ich die Warenkorbfunktion verwenden möchte, auch wenn ich nicht angemeldet bin.
users table
| Column | Type | Options |
|---|---|---|
| nickname | string | null: false |
| string | default: "", null: false | |
| password | string | null: false |
| encrypted_password | string | default: "", null: false |
| reset_password_token | string | |
| reset_password_token | string | |
| admin | boolean | default: false |
Association
orders table
| Column | Type | Options |
|---|---|---|
| user | references | foreign_key: true |
| card | references | foreign_key: true |
| product | references | foreign_key: true |
| quantity | integer | null: false |
| status | integer | default: 0, null: false |
| postage | integer | default: 0, null: false |
| price | integer | null: false |
Association
cards table
| Column | Type | Options |
|---|---|---|
| customer_id | string | null: false |
| card_id | string | null: false |
| user_id | string | null: false |
Association
addresses table
| Column | Type | Options |
|---|---|---|
| destination_family_name | string | null: false |
| destination_first_name | string | null: false |
| destination_family_name_kana | string | null: false |
| destination_family_name_kana | string | null: false |
| postcode | integer | null: false |
| prefecture_code | string | null: false |
| address_city | string | null: false |
| address_street | string | null: false |
| address_building | string | |
| phone_number | bigint | |
| user | references | foreign_key: true, null: false |
Association
brands table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
sexes table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
seasons table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
smell_impressions table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
smell_types table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
user_scenes table
| Column | Type | Options |
|---|---|---|
| name | string |
Association has_many :products, dependent: :destroy
products table
| Column | Type | Options |
|---|---|---|
| name | string | null: false |
| namelap | string | null: false |
| description | text | |
| image | text | |
| price | integer | |
| stock_quantity | ||
| brand | references | foreign_key: true |
| sex | references | foreign_key: true |
| season | references | foreign_key: true |
| smell_type | references | foreign_key: true |
| main_spice | references | foreign_key: true |
| smell_impression | references | foreign_key: true |
| use_scene | references | foreign_key: true |
Association
carts table
| Column | Type | Options |
|---|
Association has_many :line_items, dependent: :destroy
comments table
| Column | Type | Options |
|---|---|---|
| user | references | foreign_key: true |
| product | references | foreign_key: true |
| text | text | null: false |
| rate | float |
Association belongs_to :product belongs_to :user
order_details table
| Column | Type | Options |
|---|---|---|
| product | references | foreign_key: true |
| order | references | foreign_key: true |
| quantity | integer | null: false |
Association
line_items table
| Column | Type | Options |
|---|---|---|
| product | references | foreign_key: true |
| cart | references | foreign_key: true |
| quantity | integer | default: 0, null: false |
Association
Recommended Posts