What are the challenges you face when working across database platforms? Take the survey

Putting values in a SQL Matrix.- it has a compound key

I create a table....

create table matrix (x int not null,y int not null,element numeric(18,2) not null PRIMARY KEY (x,y))

I want to populate it with values for a matrix of 15(x) by 15(y). This would mean I'd want all unique combinations OF x AND y up to 15 in each case. I don't seem to be able to do it with SQL Data Generator.

Compound keys consist of several columns, in which all values are known (not null) and, in combination, are unique.


  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Andrew,

    I'd like to know what problem you run into. When I use your table, I set the table settings so that 15 rows are generated and when data is invalid, to skip the row. The downside is I always end up with very predictable data:
    x y
    1 1
    2 2
    3 3
    ... ...
    Changing the column settings for x and y to use a range between 1 and 15 and randomizing generates more realism:
    x y
    1 9
    2 3
    4 11
    ... ...
Sign In or Register to comment.