Csc 1302, Honors Principles of Computer Science II (Fall 2021)

Week 11 (5 November 2021)

semanticCheckAndSetSchemaAndDataTypes in Expression Tree

During this week you will complete the following method from RANode.java:
  public String semanticCheckAndSetSchemaAndDataTypes(Database db) {
    // This method checks for Semantic Errors and returns an error message
    // if there is a semantic error. If there are no semantic errors then this method
    // sets the following 3 instance variables for RANode class:
    // public ArrayList<String> joinColumns; // set this only for join
    // public ArrayList<String> schemaColumns;
    // public ArrayList<String> schemaDataTypes;
    // and returns "OK"

    if(rnodetype.equals("relation")){
      // week 11
      // SEMANTIC ERROR CHECK: 
      // (1) Relation not in database

    }
    else if(rnodetype.equals("union") ||
            rnodetype.equals("minus") ||
            rnodetype.equals("intersect")){
      // week 11
      // SEMANTIC ERROR CHECKS:
      // (1) The two relations have different number of attributes
      // (2) The two relations have mismatched attribute datatypes

    }
    else if(rnodetype.equals("times")){
      return "OK";
    }
    else if(rnodetype.equals("join")){
      return "OK";
    }
    else if(rnodetype.equals("rename")){
      return "OK";
    }
    else if(rnodetype.equals("project")){
      return "OK";
    }
    else if(rnodetype.equals("select")){
      return "OK";
    }
    else {
      return "SOMETHING STRANGE TOOK PLACE!";
    }
  }