milan
milan

Reputation: 2417

Design practice for certain data sets?

I am trying to dig into database design of grofers.com to understand how grofers manages to list store of merchant and make available to the buyers. What i found is

For Merchant to list their store

Basic Details

Name, Email,Phone,Store Category

Financial Detail

Name of legal entity,PAN number,Registered office address,City

Store Detail

Store Name,Location(google map),Store Address,Store Contact Number,Store Timings (  _ to _  and store off Sunday ) **// how to model such store timing**

Product

Name of Product,Item in stock,Price,Description

Category

Name of Category( Grocery, Bakery & Sweets, Food, Meat, Sports & Fitness, etc )

I come up with following design

class Store(models.Model):
    name_of_user = models.CharField()
    email = models.EmailField()
    phone_number_of_user = models.PositiveIntegerField()
    name_of_legal_entity = models.CharField()
    pan_number = models.PositiveIntegerField()
    registered_office_address = models.CharField()
    store_name = models.CharField()
    location = models.CharField()
    store_address = models.CharField()
    store_contact_number = models.CharField()
    # store_timings = models.CharField() 


class Product(models.Model):
    category = models.ForeignKey(Category)  
    name_of_product = models.CharField()
    items_in_stock = models.PositiveIntegerField()
    price = models.DecimalField()
    description = models.TextField()
    image = models.ImageField()

class Category(models.Model):
    store_category = MultiSelectField(choices=MY_CHOICES) # grocery, meats, sports, foods, bags

Process flow

Choose a preferred store from the ones that deliver to you
Checkout the cart with everything you need
This app will then pick up the items from the shop and deliver to you

I tried to design it in django for my practice but i am confuse with how i can show store category and product relation like in gorfers.com and also with the location and store timing.

Upvotes: 0

Views: 77

Answers (1)

jape
jape

Reputation: 2901

Is this what you are trying to achieve?

class Store(models.Model):
    name_of_user = models.CharField()
    email = models.EmailField()
    phone_number_of_user = models.PositiveIntegerField()
    name_of_legal_entity = models.CharField()
    pan_number = models.PositiveIntegerField()
    registered_office_address = models.CharField()
    store_name = models.CharField()
    # For location - using latitude and longitude
    store_long = models.DecimalField(max_digits=12, decimal_places=8, null=True)
    store_lat = models.DecimalField(max_digits=12, decimal_places=8, null=True)
    # End location
    store_address = models.CharField()
    store_contact_number = models.CharField()
    store_start_time = models.DateTimeField()  # start of when a store is closed
    store_end_time = models.DateTimeField()  # ending of when a store is closed


class Category(models.Model):    
    GROCERY = 0
    MEATS = 1
    SPORTS = 2
    FOODS = 3
    BAGS = 4

    STORE_CATEGORIES= (
        (GROCERY, _('Grocery')),
        (MEATS, _('Meats')),
        (SPORTS, _('Sports')),
        (FOODS, _('Foods')),
        (BAGS, _('Bags')),
    )
    store_category = models.IntegerField(
        choices=STORE_CATEGORIES, default=GROCERY)

Upvotes: 1

Related Questions