/*
 * Simple Database Interface
 */

/**
 * @author anwar
 */
public interface DBase extends Iterable<Student>{
   
    /**
    * Create new database with given name. You still have
    * to open() the database to access it. Return true
    * on success, false on failure.
    */
    public boolean create(String dbName);

    /**
    * Open existing database with given name. 
    * Return true on success, false on failure.
    */
    public boolean open(String dbname);
    /**
    * Close database, synchronizing changes (if any). 
    * Return true on success, false on failure.
    */
    public boolean close();
    /**
     * 
     * @return true if database is open. false otherwise
     */
    boolean isOpen();
    
    /**
    * Get the student by ID
    * Return Student on success, null on failure.
    */
    public Student get(String key);
    
    /**
    * Insert given student into database. If ID exists, update
    * existing student date with the given date. 
    * Return true on success, false on failure.
    */
    public boolean insert(Student s);

    /**
    * Remove the student with the given ID from database.
    * Return true on success, false on failure.
    */
    public boolean remove(String ID);
    
    /**
    * Find the student by name (either first or last name) from the database. \
    * Return bag with matching students. returns empty bag if no match
    */
    public Bag<Student> find(String name);
    
}
