Anyone like to share Java Data Modeling for Couchbase Examples?

Hi All,

May be the community can help by sharing programming techniques and OO patterns when dealing with Couchbase java SDK .
Anyone like to share implementations of Lookup Pattern Example and Counter-ID Pattern and Dao implementations etc .
I am interested in plain Java without Spring -Data but anything people share is welcome even in other languages.
I’m looking in general for couchbase Java examples in general to get ideas on Data modelling .

Thanks

Hey @GeorgeLeon,

We have quite a few SDK examples in our Couchbase Labs GitHub repository. This includes the Java SDK. The general repository can be found here:

https://github.com/couchbaselabs

In particular, if you’re using Couchbase 4.0, there is a good Java SDK example called try-cb-java that makes use of a sample bucket included in Couchbase 4.0. A direct link to this repository can be found here:

I also did a blog post on the subject:

http://blog.couchbase.com/traveling-with-couchbase-using-the-java-sdk

Although the travel sample is not directly on the subject of data modeling, you may still find it very useful.

Best,

1 Like

Cheers man @nraboy

Thanks it really helps I go have a look

Circle back if you have any questions about what you find :slight_smile:

1 Like

I like it but we can’t use Spring any chance non-spring examples if any ?

Hey @GeorgeLeon,

You don’t need to use Spring. In fact I was only using Spring-Boot to make a more appealing demo. It is less appealing to see Couchbase in action via a command line driven application.

Did you have a framework you preferred to use when it comes to Java? If you’re looking at the try-cb-java blog post I did, just ignore the stuff in the Application.java class (that relates to Spring) and look at the stuff in the Database.class which is pretty generic.

Does that make sense?

Best,

1 Like

@nraboy Thanks

Yes is does.I have a question if ok to ask .
How would you deal with more complex relation ships and using lookups and the Key management if you have a composite keys what you think is a good strategy .

see example http://sslabmcs12.weebly.com/uploads/9/2/2/0/9220774/4880440_orig.jpg
say you need to model order and order details

Hey @GeorgeLeon,

Assuming I understand your question and the ERD that you listed, you can have several ways to model your data and your intention would better decide which way is best.

If you wanted to keep things similar to an RDBMS you could use whats called referred documents. If you wanted to keep like-data together you could use embedded documents. There are trade-offs in each. Then of course you could model your keys many different ways.

I encourage you to watch the following video as it should explain a lot:

http://connect15.couchbase.com/agenda/three-things-need-know-document-data-modeling/

Let me know what new (or old) questions you have after that :smile:

Best,

1 Like

Hey man,

Cool staff. That’s it !!! it really helped me You see I understand it in theory and at Example level just like to talk to others about ways to implement it as we can use different ways I guess we all implement in our own way as we see fit for our project .
I am implementing large scale project so I need to consider writing helper methods and a Data Access Layer that we can base our business layer on and its interesting challenge on how to do it . Once i get further along I should report back my input too. For now big thanks

Cheers from Greece

2 Likes

Excellent!

Circle back to the forums if you have future questions :smile: