/*
 *  Copyright 2006 - 2012 Hannes Holtzhausen
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.

 */

/*
 * $Id: product.sql,v 1.5 2007/11/01 22:53:15 hannes Exp $
 *
 * Description: 
 *   Sample database tables for beans demo.
 */

/*
 * product types
 */

create table product_type (
    pt_id       int           not null  auto_increment,
    pt_type     varchar(20)   not null,
    pt_descr    varchar(20)   null,

  primary key (pt_id),
  unique key pt_type (pt_type)
) type = innodb;


/*
 * product vendors.
 */

create table vendor (
    vndr_id     int           not null  auto_increment,
    vndr_name   varchar(20)   not null,
    vndr_descr  varchar(20)   null,

  primary key (vndr_id),
  unique key vndr_name (vndr_name)
) type = innodb;


/*
 * product table
 */

create table product (
    prod_id       int           not null  auto_increment,
    prod_pt_id    int           not null,
    prod_vndr_id  int           not null,
    prod_name     varchar(20)   not null,
    prod_value    double(10,2)  not null,
    prod_descr    varchar(20)   null,

  primary key (prod_id),
  unique key prod_name (prod_name),
  foreign key fk_prod_pt_id (prod_pt_id) references product_type (pt_id),
  foreign key fk_prod_vndr_id (prod_vndr_id) references vendor (vndr_id)
) type = innodb;
