Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2015
    Posts
    1

    Unhappy Unanswered: help!!! CANT GET THIS TABLE TO RUN

    HELLO,

    I AM A BEGINNER AT SQL. I CANT GET THIS TO RUN CAN ANYONE HELP

    create table GROUP_MEMBER(
    signEmail varChar(100) NOT NULL,
    groupId Int NULL,
    CONSTRAINT group_member_PK PRIMARY KEY(signEmail, groupId),
    CONSTRAINT Profile_FK FOREIGN KEY(signEmail),
    REFERENCES PROFILE(signEmail)
    ON DELETE CASCADE,
    CONSTRAINT group_FK FOREIGN KEY(groupid)
    REFERENCES group1(groupId)
    ON DELETE CASCADE
    );

    create table GROUP1(
    groupId int NOT NULL,
    groupDescr text NOT NULL,
    groupCreatedDate date NULL,
    groupType enum('Alumni Group', 'Corporate Group', 'Conference Group', 'Networking Group', 'Non-Profit Organization', 'Professional Group', 'Other') NOT NULL,
    memberCount int NOT NULL,
    groupOwner char(15) NOT NULL,
    groupWebUrl varChar NULL,
    CONSTRAINT group_PK PRIMARY KEY (groupId)
    );

  2. #2
    Join Date
    Mar 2015
    Posts
    1
    Quote Originally Posted by joavila92 View Post
    HELLO,

    I AM A BEGINNER AT SQL. I CANT GET THIS TO RUN CAN ANYONE HELP

    create table GROUP_MEMBER(
    signEmail varChar(100) NOT NULL,
    groupId Int NULL,
    CONSTRAINT group_member_PK PRIMARY KEY(signEmail, groupId),
    CONSTRAINT Profile_FK FOREIGN KEY(signEmail),
    REFERENCES PROFILE(signEmail)
    ON DELETE CASCADE,
    CONSTRAINT group_FK FOREIGN KEY(groupid)
    REFERENCES group1(groupId)
    ON DELETE CASCADE
    );

    create table GROUP1(
    groupId int NOT NULL,
    groupDescr text NOT NULL,
    groupCreatedDate date NULL,
    groupType enum('Alumni Group', 'Corporate Group', 'Conference Group', 'Networking Group', 'Non-Profit Organization', 'Professional Group', 'Other') NOT NULL,
    memberCount int NOT NULL,
    groupOwner char(15) NOT NULL,
    groupWebUrl varChar NULL,
    CONSTRAINT group_PK PRIMARY KEY (groupId)
    );
    A couple of points:

    1. MySQL table names are usually case sensitive, unless you're on Windows or OS X with HFS+. So you need to be consistent when you refer to table group1.
    2. Lowercase table names (with underscore to separate words), or sometimes camel-case, are probably what is mostly used. Uppercase is a bit weird.
    3. You can't refer to tables group1 and profile before they have been created. So you should first create group1 and profile, then the group_member table (or GROUP_MEMBER - I would recommend using lowercase though.)
    4. You have to specify the length of varchar columns.

    So the following would work:
    Code:
    create table group1( 
      groupId int NOT NULL, 
      groupDescr text NOT NULL, 
      groupCreatedDate date NULL, 
      groupType enum('Alumni Group', 'Corporate Group', 'Conference Group', 'Networking Group', 'Non-Profit Organization', 'Professional Group', 'Other') NOT NULL, 
      memberCount int NOT NULL, 
      groupOwner char(15) NOT NULL, 
      groupWebUrl varChar(255) NULL, 
      CONSTRAINT group_PK PRIMARY KEY (groupId) 
    );
    
    create table profile (signEmail varchar(100) NOT NULL PRIMARY KEY);
    
    create table group_member( 
      signEmail varChar(100) NOT NULL, 
      groupId Int NULL, 
      CONSTRAINT group_member_PK PRIMARY KEY(signEmail, groupId), 
      CONSTRAINT Profile_FK FOREIGN KEY(signEmail) REFERENCES profile(signEmail) ON DELETE CASCADE, 
      CONSTRAINT group_FK FOREIGN KEY(groupid) REFERENCES group1(groupId) ON DELETE CASCADE 
    );
    I hope that helps.

Posting Permissions

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