Guest User

Untitled

a guest
Oct 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace CSE462
  7. {
  8. class Program
  9. {
  10. #region Methods (1) 
  11.  
  12. // Private Methods (1) 
  13.  
  14. static void Main(string[] args)
  15. {
  16. var es = new Schema(
  17. "Employee",
  18. new Attribute("Name"),
  19. new Attribute("EmpId"),
  20. new Attribute("DeptName"),
  21. new Attribute( "CompanyAge" )
  22. );
  23.  
  24. var ds = new Schema(
  25. "Dept",
  26. new Attribute( "DeptName" ),
  27. new Attribute( "Manager" ),
  28. new Attribute( "DeptAge" )
  29. );
  30.  
  31. var employees = new Relation(es);
  32. var depts = new Relation(ds);
  33.  
  34. employees.AddTuples(
  35. new Tuple( "Harry", "3415", "Finance", "10" ),
  36. new Tuple( "Sally", "2241", "Sales", "7" ),
  37. new Tuple( "George", "3401", "Finance", "8" ),
  38. new Tuple( "Harriet", "2202", "Sales", "1" )
  39. );
  40.  
  41. depts.AddTuples(
  42. new Tuple( "Finance", "George", "20" ),
  43. new Tuple( "Sales", "Harriet", "1" ),
  44. new Tuple( "Production", "Charles", "2" )
  45. );
  46.  
  47.  
  48. var result = RelationalAlgebra.Rename(
  49. RelationalAlgebra.Projection(
  50. RelationalAlgebra.Selection(
  51. RelationalAlgebra.NaturalJoin(
  52. employees,
  53. depts
  54. ), new Predicate("Manager = 'Harriet' && EmpId > 2240")
  55. ) ,new Attribute("EmpId"), new Attribute("DeptName")),
  56. new Attribute("Banana"), new Attribute("Boo"));
  57.  
  58.  
  59. System.Console.Write(result);
  60. System.Console.ReadLine();
  61. }
  62.  
  63. #endregion Methods 
  64. }
  65. }
Add Comment
Please, Sign In to add comment