コード例 #1
0
ファイル: Database.cs プロジェクト: nmplcpimenta/dw_project
        public void ApplyFlatSchema()
        {
            IEnumerable<Table> minEntities = GetMinEntities();

            Database flat = new Database("Flat Schema");

            foreach (Table t in minEntities)
            {
                Table table = new Table(t.Name);

                Dictionary<String, Column> columns = new Dictionary<string, Column>();
                GetColumns(t, columns, x => false);

                foreach (Column c in columns.Values)
                {
                    table.AddColumn(c);
                }

                foreach (Column pk in t.PrimaryKeys.Values)
                {
                    if (pk.ForeignKeyTable == null)
                        table.AddPrimaryKey(pk.Name);

                    else
                    {
                        IEnumerable<Column> pks = GetPrimaryKey(pk, x => false);

                        foreach (Column c in pks)
                        {
                            table.AddPrimaryKey(c.Name);
                        }
                    }
                }

                flat.AddTable(table);
            }

            Schemas.Add(flat.Name, flat);
        }
コード例 #2
0
ファイル: Database.cs プロジェクト: nmplcpimenta/dw_project
        public void ApplyTerraceSchema()
        {
            IEnumerable<Table> transactionEntities = Tables.Values.Where(t => t.EntityType == EntityType.Transaction);

            Database terrace = new Database("Terrace Schema");

            foreach (Table transactionEntity in transactionEntities)
            {
                Table table = new Table(transactionEntity.Name);

                Dictionary<String, Column> columns = new Dictionary<string, Column>();
                GetColumns(transactionEntity, columns, x => x.EntityType == EntityType.Transaction);

                foreach (Column c in columns.Values)
                {
                    table.AddColumn(c);
                }

                foreach (Column pk in transactionEntity.PrimaryKeys.Values)
                {
                    if (pk.ForeignKeyTable == null || (pk.ForeignKeyTable != null && pk.ForeignKeyTable.EntityType == EntityType.Transaction))
                        table.AddPrimaryKey(pk.Name);

                    else
                    {
                        IEnumerable<Column> pks = GetPrimaryKey(pk, x => x.EntityType == EntityType.Transaction);

                        foreach (Column c in pks)
                        {
                            table.AddPrimaryKey(c.Name);
                        }
                    }
                }

                foreach (Column fk in transactionEntity.ForeignKeys.Values)
                {
                    if (fk.ForeignKeyTable.EntityType == EntityType.Transaction)
                    {
                        table.AddForeignKey(fk.Name, fk.ForeignKeyTableName, fk.ForeignKeyTable);
                    }
                }

                terrace.AddTable(table);
            }

            Schemas.Add(terrace.Name, terrace);
        }
コード例 #3
0
ファイル: Database.cs プロジェクト: nmplcpimenta/dw_project
        public void ApplyStarSchema(Table t)
        {
            if (t.EntityType != EntityType.Transaction)
                return; //dar erro

            Database star = new Database("Star Schema For " + t.Name);

            Table factTable = new Table(t.Name);

            foreach (Column column in t.Columns.Values)
            {
                factTable.AddColumn(new Column(column.Name, column.Type));
            }

            foreach (Column column in t.PrimaryKeys.Values)
            {
                factTable.AddPrimaryKey(column.Name);
            }

            star.AddTable(factTable);

            foreach (Column column in t.ForeignKeys.Values)
            {
                if (column.ForeignKeyTable.EntityType != EntityType.Transaction)
                {
                    Table dimensionTable = new Table(column.ForeignKeyTable.Name);

                    Dictionary<String, Column> columns = new Dictionary<string, Column>();
                    GetColumns(column.ForeignKeyTable, columns, x => false);

                    foreach (Column c in columns.Values)
                    {
                        dimensionTable.AddColumn(c);
                    }

                    foreach (Column pk in column.ForeignKeyTable.PrimaryKeys.Values)
                    {
                        if (pk.ForeignKeyTable == null)
                            dimensionTable.AddPrimaryKey(pk.Name);

                        else
                        {
                            IEnumerable<Column> pks = GetPrimaryKey(pk, x => false);

                            foreach (Column c in pks)
                            {
                                dimensionTable.AddPrimaryKey(c.Name);
                            }
                        }
                    }

                    factTable.AddForeignKey(column.Name, dimensionTable.Name, dimensionTable);

                    star.AddTable(dimensionTable);
                }

            }
            Schemas.Add(star.Name, star);
        }