title: Turning a fact table into a schema in sql oracle
body: <p>I'm trying to create a schema that collects a group of other schema but also include a Sum. This is what I have so far:</p>
  
  <p>Create DDL -</p>
  
  <pre><code>CREATE TABLE ticket_sales 
    ( 
       theatreid     NUMBER(4) CONSTRAINT fk1 REFERENCES theatre, 
       trowid        NUMBER(4) CONSTRAINT fk2 REFERENCES theatre_row, 
       seasonid      NUMBER(4) CONSTRAINT fk3 REFERENCES season, 
       productionid  NUMBER(4) CONSTRAINT fk4 REFERENCES production, 
       clientid      NUMBER(4) CONSTRAINT fk5 REFERENCES client, 
       ticketrevenue NUMBER(7) NOT NULL, 
       CONSTRAINT pk PRIMARY KEY (theatreid, trowid, seasonid, productionid, 
       clientid) 
    ); 
  </code></pre>
  
  <p>Insert DML -</p>
  
  <pre><code>INSERT INTO ticket_sales 
  SELECT theatreid, 
         trowid, 
         seasonid, 
         productionid, 
         clientid, 
         ticketrevenue 
  FROM   ( 
                  SELECT   theatre.theatreid, 
                           theatre_row.trowid, 
                           season.seasonid, 
                           production.productionid, 
                           client.clientid, 
                           SUM(totalamount) ticketrevenue 
                  FROM     notmydatabase.ticketpurchase 
                  WHERE    extract(month FROM notmydatabase.preformance.pdate)=season.month 
                  AND      to_number(to_char(notmydatabase.performance.pdate, 'WW'))=season.week
                  AND      extract(day FROM notmydatabase.performance.pdate)=season.day 
                  GROUP BY theatre.theatreid, 
                           theatre_row.trowid, 
                           season.seasonid, 
                           production.productionid, 
                           client.clientid);
  </code></pre>
  
  <p>when I run the insert part, it just comes up with table or view does not exist. I have no idea why. Can anyone help?</p>
  
  <p>Thanks in advance</p>