package org.eu.eark.denormalizedb.model;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class IdColumnTest {

    @Test
    public void shouldUseUniqueColumnsForId() {
        Table table = new Table();
        table.metaData().setTableName("country");

        ColumnMetaData idColumn = new ColumnMetaData();
        idColumn.setColumnName("country_id");
        table.metaData().addColumn(idColumn);

        ColumnMetaData nameColumn = new ColumnMetaData();
        nameColumn.setColumnName("country");
        table.metaData().addColumn(nameColumn);

        table.addRow(1, "Afghanistan");

        assertEquals("country/1/Afghanistan", table.idColumn().value(0));
    }

    // TODO ID Column, if it has too many columns, try to reduce for the key

    // * if there are more unique values, chose one (which one?)

    // * if there are more non-unique but in not overlapping dimensions, create different variations of id columns = multiple tables
    // * detect if a unique column is a subset of another unique column and sort these into groups (this is more than just ordering by count)

}

@@ -81,16 +81,41 @@
 quals;%0A%0A
+import org.junit.Ignore;%0A
 import o
@@ -198,14 +198,8 @@
 dUse
-Unique
 Colu
@@ -637,16 +637,87 @@
 istan%22);
+%0A        table.addRow(2, %22Algeria%22);%0A        table.addRow(4, %22Angola%22);
 %0A%0A      
@@ -790,16 +790,321 @@
 ;%0A    %7D%0A
+    %0A    @Test @Ignore%0A    public void shouldUseOneUniqeColumnInTheBeginningForId() %7B%0A        // TODO next if there are more unique values, chose one %0A        /* %0A         * (which one?)%0A         * if it is %3E 10 maybe not%0A         * if it is string and %3C= 10, good, else take numerical%0A         */%0A    %7D%0A%0A
 %0A    // 
@@ -1178,74 +1178,8 @@
 ey%0A%0A
-    // * if there are more unique values, chose one (which one?)%0A%0A
     

add next test (as TODO)