SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rails and Database design

    I've been working through some Rails tutorials and am still a novice at best, but I'm thinking about a project I want to develop and am just trying to wrap my head around the db design. I suppose this would also work in the db forum.
    I'd like to develop an online ordering system for my restaurant. It's a deli counter that offers sandwiches, pizza, soup etc. My main concern is to create a shopping cart type app that allows the user to choose each topping/bread etc on each sandwich.

    I haven't started coding yet, but I'm stuck just thinking about the db design itself. Each sandwich order will have a radio button list for bread, checkbox for cheeses and checkbox for toppings. My first thought was to create one massive table with fields such as, white,brown,rye,chedder,swiss,ham,tomato etc and have each field as an enum y/n. But, this seems really sloppy. So I thought I could separate each section into their own tables, ie. bread, cheese, toppings and maintain a main sandwich table with other info. The separate tables would still be y/n entries and would reference the sandwich table id as foreign key for each sandwich so I would do some joins to get the final order. My only final issue is that I'd actually like the different toppings to be editable through a web interface, so anyone can add or remove available toppings. Now i'm just totally confused as to how I should design this in order to maintain scalability and flexibility.

    I guess this is kind of a convoluted post, but if someone with more db experience might be able to point me in the right direction I'd really appreciate it.

  2. #2
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would have an orders table with a has-and-belongs-to-many relationship with a topping stable.

    That way you can add topping through the web interface.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •