CodeSmith Community
Your Code. Your Way. Faster!

Table tUrlRate does not have a primary key, it will not be generated...

Latest post 05-25-2006 3:27 PM by atmosferico. 6 replies.
  • 05-25-2006 6:46 AM

    • atmosferico
    • Not Ranked
    • Joined on 05-25-2006
    • Gaia - Portugal
    • Posts 8
    • Points 230

    Table tUrlRate does not have a primary key, it will not be generated...

    Ola,

    I’m a newbie regarding the use of the great potential of NetTiers. 

    In the netTiers Generation Report i have a couple of messages like this one..

    "Table tUrlRate does not have a primary key, it will not be generated..."

    This table has a combined primary key of two fields and is used to deal with a many-to-many relationship between two other tables. 

    why does this problem occur?And how can i solve it?

    Tanks

    Pedro Machado

    J. Pedro Machado
    • Post Points: 75
  • 05-25-2006 6:52 AM In reply to

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Strange, we do support composite primary keys so i wouldn't see how that's happening, could you script out the table, and remove all the columns except for the primary keys and indexes and post it up here?

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 05-25-2006 8:25 AM In reply to

    • atmosferico
    • Not Ranked
    • Joined on 05-25-2006
    • Gaia - Portugal
    • Posts 8
    • Points 230

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Here it is,

    CREATE TABLE [dbo].[tUrlRate_Raw](

    [idUrl] [numeric](18, 0) NOT NULL,

    [idRate] [numeric](18, 0) NOT NULL,

    CONSTRAINT [PK_tUrlRate_Raw] PRIMARY KEY CLUSTERED

    (

    [idUrl] ASC,

    [idRate] ASC

    )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] WITH CHECK ADD CONSTRAINT [FK_tUrlRate_Raw_tRate] FOREIGN KEY([idRate])

    REFERENCES [dbo].[tRate] ([rate])

    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] CHECK CONSTRAINT [FK_tUrlRate_Raw_tRate]

    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] WITH CHECK ADD CONSTRAINT [FK_tUrlRate_Raw_tURL_Raw] FOREIGN KEY([idUrl])

    REFERENCES [dbo].[tURL_Raw] ([idURL])

    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] CHECK CONSTRAINT [FK_tUrlRate_Raw_tURL_Raw]

    this is the script of one of the tables that netTiers wont generate code for... 

     

    J. Pedro Machado
    • Post Points: 35
  • 05-25-2006 11:04 AM In reply to

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Thanks for that, I'll try it out this evening and let you know what I find.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
  • 05-25-2006 1:24 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 735
    • Points 17,045

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Pedro,

    In your script i don't see where you set keys for tUrlRate_Raw table. Can you execute the following statement. It would make both idUrl and idRate a composite primary keys:

    ALTER TABLE [dbo].[tUrlRate_Raw] ADD
     CONSTRAINT [PK_tUrlRate_Raw] PRIMARY KEY  NONCLUSTERED
     (
      [idUrl],
      [idRate]
     )  ON [PRIMARY]
    GO

    Thanks,
    Michael

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 5
  • 05-25-2006 1:30 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 735
    • Points 17,045

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Pedro,

    Here is complete script i used to run .nettiers against - successfully. See if it helps you.


    CREATE TABLE [dbo].[tRate] (
     [idRate] [numeric](18, 0) NOT NULL
    ) ON [PRIMARY]
    GO

    CREATE TABLE [dbo].[tURL_Raw] (
     [idUrl] [numeric](18, 0) NOT NULL
    ) ON [PRIMARY]
    GO

    CREATE TABLE [dbo].[tUrlRate_Raw] (
     [idUrl] [numeric](18, 0) NOT NULL ,
     [idRate] [numeric](18, 0) NOT NULL
    ) ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[tRate] ADD
     CONSTRAINT [PK_tRate] PRIMARY KEY  CLUSTERED
     (
      [idRate]
     )  ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[tURL_Raw] ADD
     CONSTRAINT [PK_tURL_Raw] PRIMARY KEY  CLUSTERED
     (
      [idUrl]
     )  ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] ADD
     CONSTRAINT [PK_tUrlRate_Raw] PRIMARY KEY  CLUSTERED
     (
      [idUrl],
      [idRate]
     )  ON [PRIMARY]
    GO

    ALTER TABLE [dbo].[tUrlRate_Raw] ADD
     CONSTRAINT [FK_tUrlRate_Raw_tRate] FOREIGN KEY
     (
      [idRate]
     ) REFERENCES [dbo].[tRate] (
      [idRate]
     ),
     CONSTRAINT [FK_tUrlRate_Raw_tURL_Raw] FOREIGN KEY
     (
      [idUrl]
     ) REFERENCES [dbo].[tURL_Raw] (
      [idUrl]
     )
    GO

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 05-25-2006 3:27 PM In reply to

    • atmosferico
    • Not Ranked
    • Joined on 05-25-2006
    • Gaia - Portugal
    • Posts 8
    • Points 230

    Re: Table tUrlRate does not have a primary key, it will not be generated...

    Mike and Robert

    tank you very much for your help. Problem solved.

    Best Regards

    Pedro Machado

    J. Pedro Machado
    • Post Points: 5
Page 1 of 1 (7 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems