Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how could I acheive this in Hibernate?

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there

I am working on registration part of my web application.There is two types of category one is employee and other is student.

And Employee further can be(Faculty,Accountant,Librain..) and Student can be from different course like(Technology,Management,Law,Fashion).
And further student inside that will be different category like
Technology(B.Tech,BCA,MCA,Bsc.IT),
Management(MCA,BCA,BBA)
Law(LLM,LLB)
like this

And then each course category will contain data of 1st,2nd,3rd,4th year students.

I want to store seprate table for students of different courses and different course category.

And I have make only one simple model class Student in my project.

How could I acheive this.?

If I am not able to describe my problem statement fully please ask

Thanks
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"I want to store seprate table for students of different courses and different course category."

Not sure I understand this bit?
You're not saying you want a StudentTechnology table as well as a StudentLaw table and so on?
That sounds wrong to me.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how you will save different data of student of a particular category sub category like Tech->B.Tech(CS,IT)


The approach I am thinking is making seprate model class for StudentTechCs,StudentTechIT...and Similar for each category and sub category of all category
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Student (id, name, year, CourseCategoryId)
Course (id, name)
CourseCategory (id, name, CourseId)


That's what you've just described to me (I've left out Employee for now).
You might shift year out, and possibly map year to a CourseCategory. All depends what your requirements are.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have Model class Student(FirstName,LastName,DOB,Email,Join_Date,Mobile,Address(Current,Permanent))

I want to save data of each student of each category and all its subcategory.

Now challenge is I want to make seprate table for each category of each course
Suppose B.tech contain 4 subcategory(IT,CS,ME,ECE).


So I want 4 table
Student_info_btech_iT
Student_info_btech_cs
student_info_btech_me
student_info_btech_ece

The approach I am thinking is making 4 model class for same data.

It sounds odd for me.The only thing is I want that data to be store in different table based on some Input condition.

But there seems no way to change JPA Entity name at runTime
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why all those tables?
That is plain incorrect data modelling.

What is wrong with the model I gave?

BTech is a Category, not a table.
IT is a SubCategory, not a table.

I'm probably mixing your terms a bit, but the concept stands.

Whatever a BTech is, it is a row in a table.
Whatever IT is, it is a row in a different table, with a foreign key to the BTech row in the other table.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have student record of 50,000 will it give fast speed while I search in database?
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it won't.
Databases are designed to work with large amounts of indexed data.
Putting them into separate tables will result in you having to manage where to pull data from.
For example a query on "get me all students in BTech" will involve pulling data from 4 tables, instead of a simple "SELECT * FROM Student WHERE CategoryId = <whatever the BTech id happens to be>".

I don't have a handy link, but I would recommend some reading up on how to structure database tables.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave

One more question I have relational data like a Student has(
His Address(current,permanent),
His Library Record(Books Issued),
His Finacial Information(Fees,Dues),
His Genral information(dob,email,phone number,father's name)

and many more.

How to store this data.

All these information are not updated or added at the same time.

Like His Genral Information will be add when he is enrolled in university.
His Libraray information is when he started learning
His Finance information what he paid and what is pending and so on.

So How to store this data

Approach I am think is some one to many and many to one and many to many associations in hibernate,But I don't know how to implement this in hibernate.

Library will be a seprate model class(which contain some attribute in it like book date,number,issue date...)

And similarly Finance information is also a Model class.

How to link these two model class with a Student_id?

Thanks
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really would read up on database modelling.
You need to know this stuff if you're going to be building database apps.

Also start with the smallest possible usable thing.
Skip the library stuff until you have the base STudent stuff down.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok
thanks for reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic