-- phpMyAdmin SQL Dump
-- version 3.5.3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 07. Feb 2013 um 11:09
-- Server Version: 5.1.49
-- PHP-Version: 5.3.15

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Datenbank: `PBMC`
--

CREATE DATABASE `pbmc` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `pbmc`;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `category`
--

CREATE TABLE IF NOT EXISTS `category` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `category_name` text NOT NULL COMMENT 'category_name',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `motif`
--

CREATE TABLE IF NOT EXISTS `motif` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Motif ID',
  `user_id` int(10) unsigned NOT NULL COMMENT 'user id',
  `category_id` int(10) unsigned NOT NULL COMMENT 'category id',
  `name` text NOT NULL COMMENT 'Motif name',
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Insert time',
  `tempo` double unsigned NOT NULL COMMENT 'Motif tempo',
  `default_instrument` int(10) unsigned NOT NULL COMMENT 'Default instrument',
  `ppqn` int(11) unsigned NOT NULL COMMENT 'ppqn of base-song',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `note`
--

CREATE TABLE IF NOT EXISTS `note` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Note ID',
  `motif_id` int(10) unsigned NOT NULL COMMENT 'Motif ID',
  `note` text NOT NULL COMMENT 'Note value',
  `pitch` int(10) unsigned NOT NULL COMMENT 'Note pitch',
  `dynamic` int(10) unsigned NOT NULL COMMENT 'Note dynamic',
  `rhythm_value` double unsigned NOT NULL COMMENT 'Note rhythm value',
  `duration` double NOT NULL COMMENT 'note duration',
  `real_duration` double NOT NULL COMMENT 'duration in time',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `note_amount`
--

CREATE  TABLE IF NOT EXISTS `note_amount` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(2) NOT NULL COMMENT 'note name e.g.: C',
  `octave` INT NOT NULL COMMENT 'octave of note e.g.: 3',
  `amount` INT UNSIGNED NOT NULL COMMENT 'amount in genre in percent',
  `pitch` INT UNSIGNED NOT NULL COMMENT 'pitch MIDI-Standard',
  `category_id` INT(10) UNSIGNED NULL COMMENT 'category id',
  PRIMARY KEY (`id`) 
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `instrument`
--
  
  CREATE  TABLE IF NOT EXISTS `instrument` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `category_id` INT(10) UNSIGNED NOT NULL COMMENT 'category id',
  `name` VARCHAR(20) NOT NULL COMMENT 'name of instrument group (MIDI)',
  `instr_count` INT UNSIGNED NOT NULL COMMENT 'count',
  PRIMARY KEY (`id`) 
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------
  
--
-- Tabellenstruktur für Tabelle `tonality`
--

  CREATE  TABLE IF NOT EXISTS `tonality` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `music_key` VARCHAR(2) NOT NULL COMMENT 'key of musicfile e.g.: F#',
  `major` TINYINT NOT NULL COMMENT '0 if major, 1 if minor',
  `key_count` INT UNSIGNED NOT NULL COMMENT 'count',
  `category_id` INT(10) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) 
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `noteinbeat`
--

CREATE  TABLE `pbmc`.`noteinbeat` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `polybeat_id` INT UNSIGNED NOT NULL COMMENT 'id des polybeats' ,
  `polynote_id` INT UNSIGNED NOT NULL COMMENT 'id der polynote' ,
  `position` INT UNSIGNED NOT NULL COMMENT 'position/auftreten der note im takt' ,
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `polybeat`
--

CREATE  TABLE `pbmc`.`polybeat` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `notecount` INT NULL COMMENT 'Anzahl der Noten im Takt (aus Performancegruenden gespeichert)' ,
  `tempo` INT NULL COMMENT 'schnell (2), mittel (1), langsam (0)' ,
  `interesting_measure` INT NULL COMMENT 'sehr interessant (2), normal (1), wenig (0)' ,
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------
  
--
-- Tabellenstruktur für Tabelle `polynote`
--

CREATE  TABLE `pbmc`.`polynote` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `pitch` INT NOT NULL COMMENT 'Pitch von 0 - 127, minus infinity = rest' ,
  `duration` DOUBLE UNSIGNED NOT NULL COMMENT 'quantized Duration\n4.0 = Full Note\n2.0 = Half Note\n1.0 = Quarter Note\n0.5 = Eight Note\n0.33 = Tripple Note\n0.25 = Sixteenth Note\n0.125 = Thirtytwo Note' ,
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `polymotif`
--

CREATE  TABLE `pbmc`.`polymotif` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `instrument` INT UNSIGNED NOT NULL COMMENT 'urspruengliches Instrument des Motifs' ,
  `category_id` INT UNSIGNED NOT NULL COMMENT 'Kategorie des Motifs' ,
  `numerator` INT UNSIGNED NOT NULL COMMENT 'Numerator des Takts (Anzahl der Viertelnoten pro Takt)' ,
  `denominator` INT UNSIGNED NOT NULL COMMENT 'Denominator des Takts (Basis)' ,
  `music_key` VARCHAR(2) NOT NULL COMMENT 'key of musicfile e.g.: F#',
  `major` TINYINT NOT NULL COMMENT '0 if major, 1 if minor',
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `beatinmotif`
--

CREATE  TABLE `pbmc`.`beatinmotif` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `motif_id` INT UNSIGNED NOT NULL COMMENT 'ID des Motifs' ,
  `beat_id` INT UNSIGNED NOT NULL COMMENT 'ID des Beats' ,
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `beattransition`
--

CREATE  TABLE `pbmc`.`beattransition` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `from_note` VARCHAR(2) NOT NULL COMMENT 'note as string e.g.: F#',
  `to_note` VARCHAR(2) NOT NULL COMMENT 'note as string e.g.: F#',
  `probability` INT UNSIGNED NOT NULL COMMENT 'Wahrscheinlichkeit des Taktuebergangs' ,
  `category_id` INT UNSIGNED NOT NULL COMMENT 'Kategorie des Motifs' ,
  PRIMARY KEY (`id`) );

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `user`
--

CREATE TABLE IF NOT EXISTS `user` (
  `id` int(11) NOT NULL,
  `name` text NOT NULL COMMENT 'user name',
  `password` char(32) NOT NULL COMMENT 'user password'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Daten für Tabelle `user`
--

INSERT INTO `user` (`id`, `name`, `password`) VALUES
(0, 'eidenberger', '1a1dc91c907325c69271ddf0c944bc72');
INSERT INTO `user` (`id`, `name`, `password`) VALUES
(1, 'tom', MD5('pbmc'));
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;