create database on sqlite3 (foreign key issues)

Discussion in 'Mac Programming' started by perwyl, Jun 9, 2010.

  1. perwyl macrumors newbie

    Joined:
    Jun 9, 2010
    #1
    Hi everyone

    I have 3 table:

    CREATE TABLE Destination (DestinationID INTEGER NOT NULL PRIMARY KEY, Destination TEXT NOT NULL, NoGoing INTEGER NOT NULL);

    CREATE TABLE User(UserID INTEGER NOT NULL PRIMARY KEY, UserName TEXT NOT NULL);

    CREATE TABLE Query(UserID INTEGER, DestinationID INTEGER, noPeople INTEGER NOT NULL, PRIMMAR KEY (UserID, DestinationID), CONSTRAINT UserID REFERENCES User(UserID), CONSTRAINT DestinationID REFERENCES Destination (DestinationID), CONSTRAINT noPeople = SUM"NoGoing");

    So the Query Table should be auto generated when a User Table interacts with the Destination Table since all the values for the Query Table is autoGenerated.

    But i am not sure on how to achive that using sqlite statements. The Constaint for the noPeople ...i not sure of how to go about calculating the SUM of NoGoing in Destination Table.

    I heard that usig triggers can solve the above issue but i am still confused by it.
     
  2. tekchic macrumors 65816

    tekchic

    Joined:
    Apr 19, 2010
    Location:
    Phoenix, AZ
    #2
    I'm sorry, but you are *so* in the wrong place for SQL issues. Try stackoverflow.com or experts-exchange.com for that.
     
  3. perwyl thread starter macrumors newbie

    Joined:
    Jun 9, 2010

Share This Page