복습 목적 모델링
URL : https://aquerytool.com:443/aquerymain/index/?rurl=75091db1-dfe1-4ec1-a2e5-c7ea2f525dd4&
from django.db import models
class Order(models.Model):
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
product = models.ManyToManyField('products.Product', through='OrderProduct')
status = models.ForeignKey('Status', on_delete=models.CASCADE)
address = models.ForeignKey('users.Address', on_delete=models.CASCADE)
used_coupon = models.ForeignKey('users.Coupon', on_delete=models.CASCADE, null=True, blank=True)
total_price = models.DecimalField(max_digits=10, decimal_places=2)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'orders'
class OrderProduct(models.Model):
order = models.ForeignKey(Order, on_delete=models.CASCADE)
product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
color_size = models.ForeignKey('products.ColorSizeOption', on_delete=models.CASCADE, null=True, blank=True)
bundle = models.ForeignKey('products.BundleOption', on_delete=models.CASCADE, null=True, blank=True)
quantity = models.IntegerField()
class Meta:
db_table = 'order_products'
class Status(models.Model):
name = models.CharField(max_length=45, unique=True)
class Meta:
db_table = 'status'
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=45, unique=True)
class Meta:
db_table = 'categories'
class Product(models.Model):
name = models.CharField(max_length=45, unique=True)
price = models.DecimalField(max_digits=8, decimal_places=2)
description = models.CharField(max_length=255)
discount_rate = models.DecimalField(max_digits=3, decimal_places=2)
thumbnail_url = models.URLField(max_length=500)
size = models.ManyToManyField('Size', through='ColorSizeOption')
color = models.ManyToManyField('Color', through='ColorSizeOption')
category = models.ForeignKey(Category, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'products'
class SubImage(models.Model):
image_url = models.URLField(max_length=255)
color = models.ForeignKey('Color', on_delete=models.CASCADE, null=True, blank=True)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
class Meta:
db_table = 'sub_images'
class DescriptionImage(models.Model):
image_url = models.URLField(max_length=255)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
sequence = models.SmallIntegerField()
class Color(models.Model):
name = models.CharField(max_length=45)
hex_code = models.CharField(max_length=45)
class Meta:
db_table = 'colors'
class Size(models.Model):
name = models.CharField(max_length=10)
class Meta:
db_table = 'names'
class BundleOption(models.Model):
name = models.CharField(max_length=45, unique=True)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=8, decimal_places=2)
stock = models.IntegerField()
class Meta:
db_table = 'bundle_options'
class ColorSizeOption(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
color = models.ForeignKey(Color, on_delete=models.CASCADE)
size = models.ForeignKey(Size, on_delete=models.CASCADE)
stock = models.IntegerField()
class Meta:
db_table = 'color_size_options'
class BannerImage(models.Model):
image_url = models.URLField(max_length=500)
class Meta:
db_table = 'banner_images'
from django.db import models
class Review(models.Model):
author = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='author')
product = models.ForeignKey('orders.OrderProduct', on_delete=models.CASCADE)
text = models.TextField()
rating = models.SmallIntegerField()
like = models.ManyToManyField('users.User', through='ReviewLike')
class Meta:
db_table = 'reviews'
class ReviewImage(models.Model):
review = models.ForeignKey(Review, on_delete=models.CASCADE)
image_url = models.URLField(max_length=500)
class Meta:
db_table = 'review_images'
class Comment(models.Model):
author = models.ForeignKey('users.User', on_delete=models.CASCADE)
review = models.ForeignKey(Review, on_delete=models.CASCADE)
class Meta:
db_table = 'comments'
class ReviewLike(models.Model):
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
review = models.ForeignKey(Review, on_delete=models.CASCADE)
class Meta:
db_table = 'review_likes'
from django.db import models
class User(models.Model):
email = models.EmailField(max_length=100, unique=True)
password = models.CharField(max_length=200)
name = models.CharField(max_length=45)
phone_number = models.CharField(max_length=45, unique=True)
is_active = models.BooleanField(default=True)
mileage = models.IntegerField()
coupon = models.ManyToManyField('Coupon', through='UserCoupon')
wish = models.ManyToManyField('products.Product', through='WishList')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'users'
class Address(models.Model):
user_id = models.ForeignKey(User, on_delete=models.CASCADE)
postal_code = models.CharField(max_length=45)
main_address = models.CharField(max_length=100)
detail_address = models.CharField(max_length=100)
is_main = models.BooleanField()
phone_number = models.CharField(max_length=45)
class Meta:
db_table = 'addresses'
class WishList(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
is_deleted = models.BooleanField()
class Meta:
db_table = 'wish_lists'
class Coupon(models.Model):
name = models.CharField(max_length=100)
discount_rate = models.IntegerField(null=True, blank=True)
discount_price = models.IntegerField(null=True, blank=True)
valid_days = models.SmallIntegerField()
class Meta:
db_table = 'coupons'
class UserCoupon(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
coupon = models.ForeignKey(Coupon, on_delete=models.CASCADE)
is_used = models.SmallIntegerField()
expire_at = models.DateTimeField()
class Meta:
db_table = 'users_coupons'
Author And Source
이 문제에 관하여(복습 목적 모델링), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@hong_tae/복습-목적-모델링저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)