Generally I wish to understand how SQL choose is implemented within the lower level, it appears like

the formula they using is near to O(1)..... in Java you are able to only accomplish this by utilizing

hashmaps, I wander the way they made it happen

EXAMPLE:

If I've got a number of student, and number of classes, to be able to choose any one of student goes that classes

or any class holds which number of students, I'd design a relational database, which 3 tables :

student table, class table, relation table

that ought to represent most of the-to-many relationship

if however I'd rather not use SQL , JDBC, create and design the tables

how do i implement this in pure java

I'd like something similar to

List<Student> getStudentsByClass(String className) 

or

 List<Class> getClassesByStudent(String StudentName)

Ideally I'll possess a hashMap using unique studentID as key and also the actual studentObject as value and the other hasMap uing classID as key and classObject as value

a relation ArrayList holds all of the relation objects, within the relation object you've 2 files, the classID and studentID

the issue is I'd rather not loop with the relation ArrayList each time after i carrying out a search

I understand there's a compare method on object that we can override with that only allows you to sort the obejcts it does not help much with choose is not?

there's a hyperlink, I realize everything, although not the choosing bit, anyone any tips please!

http://www.javaworld.com/javaworld/jw-11-2004/jw-1122-select.html?page=3

You are able to iterate over your "table" and appearance the items for that specified criteria. This works with O(n) complexity. If you wish to build your program faster create type of indexes using Map (e.g. HashMap or TreeMap) (O(1)) or/and sort data and employ binary search (log(n)).

Object serialization may meet your needs here...

public static void testSerialization() {
  String filename = "person.txt";
  StudentDetails s1 = new PersonDetails("hemanth", 10, "Male");
  StudentDetails s2 = new PersonDetails("bob", 12, "Male");
  StudentDetails s3 = new PersonDetails("Richa", 10, "Female");
  List list = new ArrayList();
  list.addAll(Arrays.asList(s1, s2, s3));
  FileOutputStream fos = null;
  ObjectOutputStream out = null;
  try {
    fos = new FileOutputStream(filename);
    out = new ObjectOutputStream(fos);
    out.writeObject(list);
    out.close();
    System.out.println("Object Persisted");
  } catch (IOException ex) {
    ex.printStackTrace();
  }
} 

Obviously, reading through can be really similar. Sadly, getting "choose" queries on this isn't trivial. I recommend searching in the H2 database. It's trivially simple and easy , is effective. This is a small example that produces the database, a table, card inserts stuff and reads everything out again.

public static void h2test() throws SQLException {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:testdb/somedb");

    Connection connection = ds.getConnection();
    PreparedStatement statement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
    System.out.println(statement.execute());

    statement = connection.prepareStatement("INSERT INTO TEST VALUES(10, 'ten')");
    System.out.println(statement.executeUpdate());
    connection.commit();

    statement = connection.prepareStatement("SELECT * FROM TEST");
    ResultSet resultSet = statement.executeQuery();

    while (resultSet.next()) {
        System.out.println(resultSet.getInt(resultSet.findColumn("ID")) + ", " + resultSet.getString(resultSet.findColumn("NAME")));
    }
}

public static void main(String[] args) throws SQLException {
    System.out.println("Hello world");
    h2test();
}

I'm able to really recommend it.

You can just build multiple indexed sights to fulfill the queries you need to resolve.

HashMap<String, List<Student>> studentsByClassId;
HashMap<String, List<SchoolClass>> classesByStudentId;

HashMap<String, Student> studentByStudentId;
HashMap<String, SchoolClass> classByClassId;

Maintain these in one class which functions as the data access layer and offers research techniques as if you suggest. CRUD procedures undergo that class.

Should you later desired to change to a database implementation, then your implementation of the data access class changes. But when you have done an acceptable job then it is interface will not.