• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java project

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I appreciate some help regarding a personal java project I am doing. (This is actually slightly modified version of Video Store at javaranch cattle drive)

Some intro to that:
I have a small application with one JTable, two buttons and few text fields for data entry. Table displays list of videos from database (MySql). And the buttons, one to add a new video to the video store and one to remove video.

Now I want to expand this application by introducing users to the Video store (this idea - courtesy of Ulf Dittmer). New users should be able to register and old users should be able to login with id/pwd.
And every user should be able to check out selected videos .
So I should create an account for each user.

This is where I am stuck. Where to store user information other than than id/pwd? Like user-borrowed videos etc. How is this usually done in commercial apps? I browsed the web but did not find specific design issues. Can someone please point to a resource that explains such things?

Thanks!
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Preeti,

A common way of doing that is using a relational database system (such as Oracle, MS SQL Plus or IBM DB2). MySQL and PostgreSQL are free database systems that you can download and install on your machine. In order to have your application "talking" to those systems, you will need to study SQL and JDBC.

There are frameworks that can be used, so you have the abstration of storing objects inside the database, such as Hybernate.

Well... as you can see that will involve a lot of homework for you

If you want to focus on your Java learning (and will not sell your application), perhaps you can consider simplifying it like having a helper class that receives your objects and is responsible for storing it. A first version can do nothing... a second one stores the values in a text file (or properties file)... and you can enhance as you feel comfortable to do bigger steps.

Hope it helps.
[ June 09, 2008: Message edited by: Rodrigo Tomita ]
 
Preeti Yarla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A common way of doing that is using a relational database system (such as Oracle, MS SQL Plus or IBM DB2). MySQL and PostgreSQL are free database systems that you can download and install on your machine. In order to have your application "talking" to those systems, you will need to study SQL and JDBC.



I am done with that first part.

perhaps you can consider simplifying it like having a helper class that receives your objects and is responsible for storing it. A first version can do nothing... a second one stores the values in a text file (or properties file)... and you can enhance as you feel comfortable to do bigger steps.



I am trying to clarify: does that mean getting the userinfo to an object and then write it to the database? Can you elaborate that in some more steps please?
[ June 09, 2008: Message edited by: Preeti Yarla ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you would need at least 3 tables:

- videos (primary key video_id) - it sounds as if you have that already

- users (primary key user_id, with fields like "login_name", "first_name", "last_name", "password")

- loaned_videos - basically an n:m mapping between video_id and user_id, possibly with additional fields like "date_loaned" and "date_due_back"

Whether you use straight JDBC -or some object wrapper between the application logic and the database- isn't important for getting the application logic right. If this project is a Java learning opportunity, I'd suggest to use just JDBC, and not bother with more advanced ways of accessing databases.

Does that help?
[ June 10, 2008: Message edited by: Ulf Dittmer ]
 
Rodrigo Tomita
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Preeti Yarla:

I am trying to clarify: does that mean getting the userinfo to an object and then write it to the database? Can you elaborate that in some more steps please?



Yes... you probably already have a class like User or Person. I think the simplest way would be to do something like getting the user info (each attribute value) from the objects of that class and store it in the database, one attribute per field - as Ulf has mentioned.

You will need methods to store the values to the database and to fetch the data from the database and "re-assemble" the objects.
 
Preeti Yarla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

loaned_videos - basically an n:m mapping between video_id and user_id, possibly with additional fields like "date_loaned" and "date_due_back"



This is what I am missing. I will go ahead with this approach first and then try the object wrapper in between as a next step. Thanks Ulf and Rodrigo!
 
reply
    Bookmark Topic Watch Topic
  • New Topic