For the Fit Factory e-commerce app, I designed and implemented a comprehensive database schema using Supabase (PostgreSQL) to support all core functionalities, including user management, product catalog, cart operations, and real-time messaging.
Key Features of the Database Design:
User & Auth Management: Leveraging Supabase’s
authschema with tables likeusers,sessions, andrefresh_tokensto handle authentication and secure user sessions.Product Catalog: Tables such as
itemsInfo,itemPrice,itemImgs,categoryInfo, anditemCategorymanage products, categories, images, and pricing efficiently.Shopping Cart & Orders:
cartInfoandcartItemtables store active carts and cart items, supported by views likecart_total_priceandfull_cart_detailsfor easy aggregation and reporting.Real-Time Features:
realtime.messagesandrealtime.subscriptiontables enable live chat and notification functionalities.Storage & Media Management: Supabase
storageschema handles media objects and buckets, supporting product images and other file storage.Security & Encryption:
vault.secretstable and related functions ensure sensitive data is securely stored and managed.Reusable Views & Functions: Created optimized views (
full_item_info,full_cart_details) and functions (prevent_multiple_active_carts) to simplify queries and maintain data integrity.
This database design ensures scalability, performance, and maintainability, allowing the Fit Factory app to handle multiple users, products, and real-time operations efficiently.