private void ProcessTernary(RelationshipData rd, string nameRalationship, Table t1, Table t2, Table t3) { ProcessTernary(rd, nameRalationship, t1, t2, t3, false); }
/// <summary> /// Xử lý các trường hợp mối liên kết ba ngôi: 1-1-1, 1-1-n, 1-n-m, n-m-l, associative entity /// Lưu ý: Thứ tự t1,t2,t3 ảnh hưởng/tác dụng tới từng trường hợp cụ thể /// 1-1-1: t1,t2,t3 | /// 1-1-n: t3,t1,t2 | /// 1-n-1: t2,t1,t3 | /// n-1-1: t1,t2,t3 | /// 1-n-m: t2,t3,t1 | /// n-1-m: t1,t3,t2 | /// n-m-1: t1,t2,t3 | /// n-m-l: t1,t2,t3,true | /// associative entity: t1,t2,t3,true | /// </summary> /// <param name="t1">Table 1 trong Relationship Ternary</param> /// <param name="t2">Table 2 trong Relationship Ternary</param> /// <param name="t3">Table 3 trong Relationship Ternary</param> /// <param name="f"> default : FALSE, f = true trường hợp n-m-l, f = false các trường hợp còn lại</param> private void ProcessTernary(RelationshipData rd, string nameRelationship, Table t1, Table t2, Table t3, bool f) { List<Column> pk1 = t1.GetPrimaryKey(); List<Column> pk2 = t2.GetPrimaryKey(); List<Column> pk3 = t3.GetPrimaryKey(); bool hasPrimaryKey = false; Table t4 = new Table(nameRelationship, rd.x, rd.y, rd.w, rd.h); AttributeData mulAttribute = new AttributeData(); foreach (AttributeData ad in rd.Attributes) { //Composite Attribute if (ad.AttributeChilds.Count > 0) { foreach (AttributeData adChild in ad.AttributeChilds) t4.AddColumn(adChild); } else { if (ad.type == AttributeType.Simple) { Column c = new Column(ad.name, ad.DataType, ad.Length, ad.AllowNull, ad.Description); t4.AddColumn(c); } if (ad.type == AttributeType.Key) { hasPrimaryKey = true; Column c = new Column(ad.name, ad.DataType, ad.Length, ad.AllowNull, true, false, ad.Description); t4.AddPrimaryKey(c); } if (ad.type == AttributeType.MultiValued) mulAttribute = ad; } } if (hasPrimaryKey) { t4.AddColumnFK(pk1); t4.AddColumnFK(pk2); t4.AddColumnFK(pk3); } else { t4.AddPrimaryKeyForeignKey(pk1); t4.AddPrimaryKeyForeignKey(pk2); if (f) t4.AddPrimaryKeyForeignKey(pk3); else t4.AddColumnFK(pk3); } mdp.AddTable(t4); mdp.AddForeignKey(nameRelationship + "1", t1, pk1, t4, pk1); mdp.AddForeignKey(nameRelationship + "2", t2, pk2, t4, pk2); mdp.AddForeignKey(nameRelationship + "3", t3, pk3, t4, pk3); //Xử lý trường hợp Multivalue if (mulAttribute.name != String.Empty) EntityHasMultivalueAttribute(t4, mulAttribute); }
public IMetaData getMetaData() { RelationshipData relationship = new RelationshipData(this.sName, this.type, this.Location.X, this.Location.Y, this.Width, this.Height); return (IMetaData)relationship; }
/// <summary> /// Xử lý các trường hợp mối liên kết ba ngôi: 1-1-1, 1-1-n, 1-n-m, n-m-l, associative entity /// Lưu ý: Thứ tự t1,t2,t3 ảnh hưởng/tác dụng tới từng trường hợp cụ thể /// 1-1-1: t1,t2,t3 | /// 1-1-n: t3,t1,t2 | /// 1-n-1: t2,t1,t3 | /// n-1-1: t1,t2,t3 | /// 1-n-m: t2,t3,t1 | /// n-1-m: t1,t3,t2 | /// n-m-1: t1,t2,t3 | /// n-m-l: t1,t2,t3,true | /// associative entity: t1,t2,t3,true | /// </summary> /// <param name="t1">Table 1 trong Relationship Ternary</param> /// <param name="t2">Table 2 trong Relationship Ternary</param> /// <param name="t3">Table 3 trong Relationship Ternary</param> /// <param name="f"> default : FALSE, f = true trường hợp n-m-l, f = false các trường hợp còn lại</param> private void ProcessTernary(RelationshipData rd, string nameRelationship, Table t1, Table t2, Table t3, bool f) { List <Column> pk1 = t1.GetPrimaryKey(); List <Column> pk2 = t2.GetPrimaryKey(); List <Column> pk3 = t3.GetPrimaryKey(); bool hasPrimaryKey = false; Table t4 = new Table(nameRelationship, rd.x, rd.y, rd.w, rd.h); AttributeData mulAttribute = new AttributeData(); foreach (AttributeData ad in rd.Attributes) { //Composite Attribute if (ad.AttributeChilds.Count > 0) { foreach (AttributeData adChild in ad.AttributeChilds) { t4.AddColumn(adChild); } } else { if (ad.type == AttributeType.Simple) { Column c = new Column(ad.name, ad.DataType, ad.Length, ad.AllowNull, ad.Description); t4.AddColumn(c); } if (ad.type == AttributeType.Key) { hasPrimaryKey = true; Column c = new Column(ad.name, ad.DataType, ad.Length, ad.AllowNull, true, false, ad.Description); t4.AddPrimaryKey(c); } if (ad.type == AttributeType.MultiValued) { mulAttribute = ad; } } } if (hasPrimaryKey) { t4.AddColumnFK(pk1); t4.AddColumnFK(pk2); t4.AddColumnFK(pk3); } else { t4.AddPrimaryKeyForeignKey(pk1); t4.AddPrimaryKeyForeignKey(pk2); if (f) { t4.AddPrimaryKeyForeignKey(pk3); } else { t4.AddColumnFK(pk3); } } mdp.AddTable(t4); mdp.AddForeignKey(nameRelationship + "1", t1, pk1, t4, pk1); mdp.AddForeignKey(nameRelationship + "2", t2, pk2, t4, pk2); mdp.AddForeignKey(nameRelationship + "3", t3, pk3, t4, pk3); //Xử lý trường hợp Multivalue if (mulAttribute.name != String.Empty) { EntityHasMultivalueAttribute(t4, mulAttribute); } }