Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4333688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:25:39+00:00 2026-05-21T10:25:39+00:00

Im currently working on a small project in which I need to model the

  • 0

Im currently working on a small project in which I need to model the following scenario:

Scenario

  1. Customer calls, he want an quote on a new car.
  2. Sales rep. register customer information.
  3. Sales rep. create a quote in the system, and add a item to the quote (the car).
  4. Sales rep. send the quote to the customer on email.
  5. Customer accept the quote, and the quote is now not longer a quote but an order.
  6. Sales rep. check the order, everything is OK and he invoice the order. The order is now not longer an order, but an invoice.

Thoughts

I need a bit of help finding out the ideal way to model this, but I have some thoughts.

  1. I’m thinking that both draft/quote/invoice is basically an order.
  2. Draft/quote/invoice need seperate unique numbers(id’s) so there for i’m thinking separate tables for all of them.

Model

This is my data model v.1.0, please let me know what you think.

Data model v.1.0
Concerns

I however have som concerns regarding this model:

  1. Draft/quote/invoice might have different items and prices on the order lines. In this model all draft/quote/invoice is connected to the same order and also order lines, making it impossible to have separate quote lines/draft lines/invoice lines. Maybe I shall make new tables for this, but then basically the same information would be stored in multiple tables, and that is not good either.
  2. Sometimes two or more quotes become an invoice, how would this model take care of this?

If you have any tips on how to model this better, please let me know!

EDIT: Data model v.1.4
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:25:40+00:00Added an answer on May 21, 2026 at 10:25 am

    It looks like you’ve modeled every one of these things–quote, order, draft, invoice–as structurally identical to all the others. If that’s the case, then you can “push” all the similar attributes up into a single table.

    create table statement (
        stmt_id integer primary key,
        stmt_type char(1) not null check (stmt_type in ('d', 'q', 'o', 'i')),
        stmt_date date not null default current_date,
        customer_id integer not null  -- references customer (customer_id)
    );
    
    create table statement_line_items (
        stmt_id integer not null references statement (stmt_id),
        line_item_number integer not null,
        -- other columns for line items
        primary key (stmt_id, line_item_number)
    );
    

    I think that will work for the model you’ve described, but I think you’ll be better served in the long run by modeling these as a supertype/subtype. Columns common to all subtypes get pushed “up” into the supertype; each subtype has a separate table for the attributes unique to that subtype.

    This SO question and its accepted answer (and comments) illustrate a supertype/subtype design for blog comments. Another question relates to individuals and organizations. Yet another relating to staffing and phone numbers.

    Later . . .

    This isn’t complete, but I’m out of time. I know it doesn’t include line items. Might have missed something else.

    -- "Supertype". Comments appear above the column they apply to.
    create table statement (
      -- Autoincrement or serial is ok here.
      stmt_id integer primary key,    
      stmt_type char(1) unique check (stmt_type in ('d','q','o','i')),
      -- Guarantees that only the order_st table can reference rows having
      -- stmt_type = 'o', only the invoice_st table can reference rows having
      -- stmt_type = 'i', etc.
      unique (stmt_id, stmt_type),
      stmt_date date not null default current_date,
      cust_id integer not null -- references customers (cust_id)
    );
    
    -- order "subtype"
    create table order_st (
      stmt_id integer primary key,
      stmt_type char(1) not null default 'o' check (stmt_type = 'o'),
      -- Guarantees that this row references a row having stmt_type = 'o'
      -- in the table "statement".
      unique (stmt_id, stmt_type),
      -- Don't cascade deletes. Don't even allow deletes. Every order given
      -- an order number must be maintained for accountability, if not for
      -- accounting. 
      foreign key (stmt_id, stmt_type) references statement (stmt_id, stmt_type) 
        on delete restrict,
      -- Autoincrement or serial is *not* ok here, because they can have gaps. 
      -- Database must account for each order number.
      order_num integer not null,  
      is_canceled boolean not null 
        default FALSE
    );
    
    -- Write triggers, rules, whatever to make this view updatable.
    -- You build one view per subtype, joining the supertype and the subtype.
    -- Application code uses the updatable views, not the base tables.    
    create view orders as 
    select t1.stmt_id, t1.stmt_type, t1.stmt_date, t1.cust_id,
           t2.order_num, t2.is_canceled
    from statement t1
    inner join order_st t2 on (t1.stmt_id = t2.stmt_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a small project I'm working on I need to cycle through a list.
I am working on this small project where I'd like to generate the call
I'm working on a memory pool for a small game engine. The main use
I'm currently working on a couple of windows phone projects (Although the question may
I have this project i'm working on and id like to add a really
I currently have a single svn project for all work on a website. But
I am currently working on an app that uses a broadcastreceiver to check for
I have a normal VS2008 project that I've been working on for awhile that
I have a task assigned to me but I am not a project manager.
I am currently looking at building an Open Source People Intelligence Application (Fancy Word

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.