DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Create table

  1. #1
    Join Date
    Jun 2014
    Posts
    3

    Create table

    Hello! I never learned oracle sql developer and my boss asked me to do this simple database with urgency (the content is made up for giving an example):SEE FIGURE.
    A.JPGA.JPG
    I am very worried I will not be able to do it. Please help me. I would be so grateful for any help at all! So many many thanks!

  2. #2
    Join Date
    Jun 2014
    Posts
    3

    Create table

    Hello! I never learned oracle sql developer and my boss asked me to do this simple database with urgency (the content is made up for giving an example):SEE FIGURE.
    A.JPG
    I am very worried I will not be able to do it. Please help me. I would be so grateful for any help at all! So many many thanks!

  3. #3
    Join Date
    Jun 2014
    Posts
    3
    thank you very much for your answer and help.


    the goal of this work is, given the example (but what i have is a table with +- 3000 lines):


    [question] which countries? [answer] uk, belgium


    [question] in UK how many names? [answer] one


    which simpler software would you advise me to use for this goal?


    thank you so so much.

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    You need more than one table. You need to think about the cardinality between the data
    and figure out how each piece of data relates to every other piece of data. Do you have
    stock meals or meals for individuals. Your chart is lacking from a design perspective.

    Code:
    CREATE SEQUENCE person_seq;
    
    CREATE TABLE person (
       person_id           NUMBER,
       person_title        VARCHAR2(64),
       person_first_name   VARCHAR2(64),
       person_middle_name  VARCHAR2(64),
       person_last_name    VARCHAR2(64),
       city                VARCHAR2(64),
       county              VARCHAR2(64),
       country             VARCHAR2(64),
       postal_code         VARCHAR2(64),
       CONSTRAINT person_pkey
       PRIMARY KEY ( person_id) );
    
    CREATE TRIGGER on person
       BEFORE INSERT FOR EACH ROW
    DECLARE
       v_person_id NUMBER;
    BEGIN
       SELECT person_seq
         INTO v_person_id
         FROM dual;
    
       :NEW.person_id := v_person_id;
    END;
    /
    
    
    CREATE TABLE ingredients (
       ingredient_name          VARCHAR2(64),
       ingredient_calories      VARCHAR2(64),
       ingredient_fat_grams     VARCHAR2(64),
       ingredient_sat_fat_grams VARCHAR2(64),
       ingredient_salt_mg       VARCHAR2(64),
       ingredient_fiber_grams   VARCHAR2(64),
       CONSTRAINT person_pkey
       PRIMARY KEY ( ingredient_name ));
    
    
    CREATE TABLE foods (
       food_name           VARCHAR2(64),
       health_food         VARCHAR2(3)  CHECK IN ('YES','NO'),
       food_type           VARCHAR2(64),
       CONSTRAINT person_pkey
       PRIMARY KEY ( food_name ));
    
    CREATE TABLE food_ingredients (
       food_name           VARCHAR2(64),
       ingredient_name     VARCHAR2(64),
       quantity            NUMBER,
       CONSTRAINT person_pkey
       PRIMARY KEY ( food_name, ingredient_name ));
    
    CREATE TABLE person_meals (
       person_id           NUMBER,
       food_name           VARCHAR2(64),
       date_consumed       DATE,
       CONSTRAINT person_pkey
       PRIMARY KEY ( person_id, food_name ));

  5. #5
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool

    Quote Originally Posted by sarahhh View Post
    . . .
    . . . (but what i have is a table with +- 3000 lines):
    . . .
    This table you have, is it a spread-sheet? a flat file?
    Does it have the same format you posted in the picture?
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

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


Click Here to Expand Forum to Full Width