Foreign Key problem.....

  • Hi, for some reason I can create the table but the foreign key references are not there.

    This is the script:

    -- Dimension Product

    CREATE TABLE dimProduct (

    productId int,

    productName varchar (40),

    categoryName varchar (15),

    unitPrice money,

    primary key (productID)

    )

    -- Dimension Employee

    CREATE TABLE dimEmployee (

    employeeId int,

    Name varchar (20),

    city varchar (15),

    region varchar (15),

    country varchar (15),

    primary key (employeeID)

    )

    -- Dimension Client

    CREATE TABLE dimClient (

    clientId varchar(10),

    Name varchar (40),

    primary key (clientId)

    )

    CREATE TABLE SalesFact (

    clientId varchar(10),

    productId int,

    employeeId int,

    unitPrice varchar (10),

    quantity varchar (10),

    discount varchar (5),

    foreign key (clientId)references dimClient(clientId),

    foreign key (productId) references dimProduct(productId),

    foreign key (employeeId)references dimEmployee(employeeId)

    )

    the foreign keys of SalesFact r just not there O.o

  • I've just run the script and it executes and shows the foreign keys under the table ok.

    What permissions do you have to the databases, SA? dbo? ddladmin?

    Can you see the tables?

  • Maybe you need to do a refresh of the Object Explorer?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • maybe you are scripting the table in SSMS, and it doesn't show the foreign keys because the scripting option for that is False instead of True?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Is dbo.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply