public void Add(AttributeSet set) { foreach (char attribute in set._attributes) { if (!_attributes.Contains(attribute)) _attributes.Add(attribute); } _attributes.Sort(); }
public bool Contains(AttributeSet set) { foreach (char attribute in set._attributes) { if (!_attributes.Contains(attribute)) return false; } return true; }
public void AddDependency(AttributeSet x, AttributeSet y) { this.AddDependency(new FunctionalDependency(x, y)); }
private bool _EvaluateTransitiveClosure(AttributeSet x) { bool closureGrowing = true; bool closureGrew = false; while (closureGrowing) { closureGrowing = false; foreach (KeyValuePair<AttributeSet, AttributeSet> pair in _closures) { if (_closures[x].Contains(pair.Key) && !_closures[x].Contains(pair.Value)) { _closures[x].Add(pair.Value); closureGrowing = true; closureGrew = true; } } } return closureGrew; }
private void _SyncUiData() { Paragraph closureContainer; TextBlock closure; AttributeSet filter = new AttributeSet(this.closureFilterTextBox.Text); RadialGradientBrush greenLed = new RadialGradientBrush(); RadialGradientBrush redLed = new RadialGradientBrush(); greenLed.GradientStops.Add(new GradientStop(Colors.Lime, 0.0)); greenLed.GradientStops.Add(new GradientStop(Colors.Green, 2.0)); redLed.GradientStops.Add(new GradientStop(Colors.Red, 0.0)); redLed.GradientStops.Add(new GradientStop(Colors.Firebrick, 2.0)); this.fdDocument.Blocks.Clear(); this.closureDocument.Blocks.Clear(); foreach (FunctionalDependency fd in _schema.Dependencies) { this.fdDocument.Blocks.Add(_CreateDependencyEntry(fd)); } foreach (KeyValuePair<AttributeSet, AttributeSet> pair in _schema.Closures) { if (filter.Contains(pair.Key) && (this.closureTrivialCheckBox.IsChecked.Value || (pair.Key.Count != pair.Value.Count))) { closure = new TextBlock(); closure.Inlines.Add(pair.Key.ToString()); closure.Inlines.Add(new Run("+") { FontSize = 10, BaselineAlignment = BaselineAlignment.Top }); closure.Inlines.Add(" = "); closure.Inlines.Add(pair.Value.ToString()); if (_schema.CandidateKeys.Contains(pair.Key)) { closure.Foreground = Brushes.ForestGreen; closure.FontWeight = FontWeights.Bold; } else if (_schema.SuperKeys.Contains(pair.Key)) { closure.Foreground = Brushes.DarkBlue; closure.FontWeight = FontWeights.Bold; } closureContainer = new Paragraph(); closureContainer.Margin = new Thickness(10.0, 2.5, 5.0, 2.5); closureContainer.Inlines.Add(closure); this.closureDocument.Blocks.Add(closureContainer); } } if (_schema.IsBoyceCoddNormalForm()) { this.bcnfLed.Background = greenLed; } else { this.bcnfLed.Background = redLed; } if (_schema.IsThreeNormalForm()) { this.tnfLed.Background = greenLed; } else { this.tnfLed.Background = redLed; } }
public FunctionalDependency(AttributeSet x, AttributeSet y) { _x = x; _y = y; }
public FunctionalDependency(string x, string y) { _x = new AttributeSet(x); _y = new AttributeSet(y); }