Monday, February 11, 2013

Sample Apps: Spring data MongoDB and JSF Integration Tutorial (PART 2)


Table of Contents:
1. Introduction to sample application (MongoShop Product Catalog)
2. MongoDB schema design and data preparation
3. JSF (PrimeFaces) and Spring data MongoDB Integration
4. Enquriy data with spring data repository and mongotemplate
5. Create, Edit and delete data


MongoDB schema design and data preparation



MongoDB Introduction
MongoDB is a open-source scalable, high-performance NoSQL database. It is a document-oriented Storage. It can store JSON-style documents with dynamic schemas. In this application, each product is stored as JSON-style document in MongoDB.


Schema Design in MongoDB
Each product in the catalog contains general product information (e.g. sku, title, and product type), price details (e.g. retail and list price) and product sub-details (e.g. tracks of audio CDs / chapters of books).

In this application, MongoDB is used. The schema design will be focus more on the data usage. It is different from traditional RDBMS schema design. The schema design in MongoDB should be:


Sample Data:
x= {
  sku: "1000001",
  type: "Audio Album",
  title: "A Love Supreme",
  description: "by John Coltrane",
  publisher: "Sony Music",
  pricing: {
    list: 1200,
    retail: 1100
  },

  details: {
    title: "A Love Supreme [Original Recording Reissued]",
    artist: "John Coltrane",
    genre:  "Jazz" ,
    tracks: [
      "A Love Supreme Part I: Acknowledgement",
      "A Love Supreme Part II - Resolution",
      "A Love Supreme, Part III: Pursuance",
      "A Love Supreme, Part IV-Psalm"
    ],
  }
}

y= {
  sku: "1000002",
  type: "Audio Album",
  title: "Love Song",
  description: "by Khali Fong",
  publisher: "Sony Music",
  pricing: {
    list: 1000,
    retail: 1200
  },

  details: {
    title: "Long Song [Original Recording Reissued]",
    artist: "Khali Fong",
    genre:  "R&B",
    tracks: [
      "Love Song",
      "Spring Wind Blow",
      "Red Bean",
      "SingAlongSong"
    ],
  }
}


z= {
  sku: "1000003",
  type: "Book",
  title: "Node.js for PHP Developers",
  description: "by Owen Peter",
  publisher: "OReilly Media",

  pricing: {
    list: 2500,
    retail: 2100
  },

  details: {
    title: "Node.js for PHP Developers",
    author: "Mark Owen",
    genre:  "Technology",
    chapters: [
      "Introduction to Node",
      "Server-side JS",
      "PHP API",
      "Example"
    ],
  }
}


Sample query to add the data:
db.product.save(x);
db.product.save(y);
db.product.save(z);

Sample query to test the sample data:
db.product.find({'sku':'1000004'});
db.product.find({'type':'Audio Album'});
db.product.find({'type':'Audio Album', 'details.genre': 'Jazz'});

Part 3 of the tutorial ...

4 comments:

balamurugan said...

Excellent post and it is really useful for most of the freshers.
Node JS Training in Chennai
Node JS Advanced Training
IELTS Training in Chennai
Japanese Language Course in Chennai
TOEFL Training in Chennai
French Language Classes in Chennai
content writing course in chennai
spanish coaching in chennai
Node JS Training in Adyar
Node JS Training in Anna Nagar

The India said...


Delhi Agra Jaipur Tour by Bus
Delhi to Jaipur Same Day Tour
Delhi One Day Tour Package
Delhi Sightseeing One Day
Delhi Sightseeing Tour by Bus
Delhi Jaipur One Day Tour Package
Haridwar, Rishikesh Tours by Volvo

merlin said...

I'm very pleased to discover this site. I need to to thank you for ones time just for this wonderful read!!
Selenium Training in chennai | Selenium Training in annanagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery

Maradona Jons said...

Kardinal Stick Siam - relx a great promotion. Express delivery in 3 hours.

ufa football betting, casino, slots, lottery, direct website 1688, stable financial, 100% UFABET168.

Online Baccarat FOXZ24 Easy to apply, fast, บาคาร่า deposit-withdraw 10 seconds with the system.

Watch movies online sa-movie.com, watch new movies, series Netflix HD 4K ดูหนังออนไลน์, watch free movies on your mobile phone, Tablet, watch movies on the web.

SEE4K Watch movies, watch movies, free series, load without interruption, sharp images in HD FullHD 4k, ดูหนังใหม่ all matters, all tastes, see anywhere, anytime, on mobile phones, tablets, computers.

GangManga read manga, read manga, read manga online for free, fast loading, clear images in HD quality, อ่านการ์ตูน all titles, anywhere, anytime, on mobile, tablet, computer.

Watch live football ผลบอลสด, watch football online, link to watch live football, watch football for free.