Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AV-68634] Capella Developer Tutorial Intro Pages #314

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions modules/develop/pages/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ It also provides links to the documentation for software development kits and ot

include::ROOT:partial$component-signpost.adoc[]

ifdef::flag-devex-tutorial[]
== Developer Tutorial

This tutorial provides an introductory worked example for developers, showing how to use a software development kit with a simple database.

* xref:tutorials:couchbase-tutorial-student-records.adoc[]
endif::flag-devex-tutorial[]

== Connect

Expand Down
156 changes: 0 additions & 156 deletions modules/tutorials/pages/.couchbase-tutorial-student-records.adoc

This file was deleted.

116 changes: 116 additions & 0 deletions modules/tutorials/pages/couchbase-tutorial-student-records.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
= Developer Tutorial: Student Record System
:description: Learn how to create and deploy a student records database on Capella Operational and connect it to your application.
:page-topic-type: tutorial
:page-pagination: next
:page-toclevels: 2

[abstract]
{description}

== Introduction
Couchbase is a schema-less JSON document database designed for high performance, scalability, and fast development. This tutorial teaches you about the key concepts behind Couchbase and how they differ from traditional SQL database systems like MySQL and Oracle.

IMPORTANT: This tutorial is designed for use with Capella Operational cloud services.
If you wish to use a standalone or Docker installation of Couchbase, see xref:server:tutorials:couchbase-tutorial-student-records.adoc[].

[#database-design]
== Data Model

The model consists of three record types:

[horizontal]
*student*:: Information about individual students, like name and date of birth.
*course*:: Courses the students can take. Includes course name, faculty, and the number of credit points associated with the course. Students can take more than one course at a time.
*enrollment*:: Information related to courses the students are taking. In a relational database, this is usually a link record that creates a relationship between a student and a course.

=== Relational Model

In a relational model, the database contains a list of students and a list of courses. Each student can enroll in multiple courses.

A student’s enrollment record is stored in a separate table called `enrollment`, which links that record to the courses they are enrolling in.

[plantuml,student-record-erd,svg]
....
include::partial$diagrams/student-record-erd.puml[]
....

The `enrollment` table highlights a challenge with the relational model: each table is based on a fixed schema that only supports a single data object type, which means you cannot store a student in the same table as their enrollment record.

=== Document Model

Couchbase uses a document model that stores each record as a JSON document. The document model:

- Contains simple scalar types and complex types, like nested records and arrays

- Lets you store complex types without decomposing them to a second table

In this tutorial, the document model stores the list of enrollment records with the student records. Each enrollment record contains a reference to the course that it relates to.

[plantuml,student-document-database-design,svg]
....
include::partial$diagrams/student-document-database-design.puml[]
....

With JSON, you can change the structure of the document without having to rebuild schemas. For example, you can add a new field to store students' email addresses without migrating existing data to a new schema.

In a document database, a student’s record and their course records can look similar to this:

.Student record
[source, json]
----
{
"student-id": "000001",
"name": "Hilary Smith",
"date-of-birth": "21-12-1980",
"enrollments": [
{
"course-id": "ART-HISTORY-00003",
"date-enrolled": "07-9-2021"
},
{
"course-id": "GRAPHIC-DESIGN-00001",
"date-enrolled": "15-9-2021"
}
]
}
----

.Art history course record
[source, json]
----
{
"course-id": "ART-HISTORY-00003",
"course-name": "art history",
"faculty": "fine art",
"credit-points" : 100
}
----

.Graphic design course record
[source, json]
----
{
"course-id": "GRAPHIC-DESIGN-00001",
"course-name": "graphic design",
"faculty": "media and communication",
"credit-points" : 200
}
----

Hilary’s enrollment is stored in the same document as her student details, which means child information is stored with its parent. This structure lets you access and retrieve all of Hilary’s details with one search and without the need for complex table joins.

NOTE: You should not store a student with their course record as it can lead to data duplication and make it difficult to maintain your data. For example, you would need to access every single student record in your cluster to change the `credit-points`.

== Next Steps

To complete this tutorial, follow these steps:

[horizontal]
Step 1:: xref:create-couchbase-cluster.adoc[Create and Deploy a Cluster with Capella Free Tier]
Step 2:: xref:buckets-scopes-and-collections.adoc[Implement a Data Model]
Step 3:: xref:java-tutorial/install-couchbase-java-sdk.adoc[Set Up and Connect the Couchbase Java SDK]
Step 4:: xref:java-tutorial/create-records.adoc[Create Student and Course Records]
Step 5:: xref:java-tutorial/retrieving-documents.adoc[Retrieve Records]
Step 6:: xref:java-tutorial/adding-course-enrollments.adoc[Add Course Enrollments]

rakhi-prathap marked this conversation as resolved.
Show resolved Hide resolved
For troubleshooting information, see the xref:java-tutorial/tutorial-troubleshooting.adoc[troubleshooting page].
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
= Troubleshooting
:description: This page addresses errors you might come across when following the Student Record System tutorial.
:page-topic-type: tutorial

[abstract]
{description}

**Authentication error**

If you get an authentication error when running Maven commands in your console, confirm that the username and password in your Java file matches the username and password you used when setting up the Couchbase cluster in your browser.

If they do not match, you can edit the Java file to add the correct username or password and try compiling and running the Maven command again.

**IP address error**

If you get a `DnsSrvLookupFailedEvent` error to specify your IP address in your console, go to your Java file and replace `localhost` with the IP address of your local Couchbase cluster in your browser.

**Other build errors**

For any other build errors in your console, run `mvn install` and try the original command again.
14 changes: 7 additions & 7 deletions modules/tutorials/partials/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
* xref:tutorials:couchbase-tutorial-student-records.adoc[Developer Tutorial]
** xref:tutorials:install-couchbase-server.adoc[]
** xref:tutorials:buckets-scopes-and-collections.adoc[]
** xref:tutorials:java-tutorial/install-couchbase-java-sdk.adoc[]
** xref:tutorials:java-tutorial/creating-the-students-collection.adoc[]
** xref:tutorials:java-tutorial/creating-the-courses-collection.adoc[]
** xref:tutorials:java-tutorial/retrieving-documents.adoc[]
** xref:tutorials:java-tutorial/adding-course-enrollments.adoc[]
// ** xref:tutorials:install-couchbase-server.adoc[]
// ** xref:tutorials:buckets-scopes-and-collections.adoc[]
// ** xref:tutorials:java-tutorial/install-couchbase-java-sdk.adoc[]
// ** xref:tutorials:java-tutorial/creating-the-students-collection.adoc[]
// ** xref:tutorials:java-tutorial/creating-the-courses-collection.adoc[]
// ** xref:tutorials:java-tutorial/retrieving-documents.adoc[]
// ** xref:tutorials:java-tutorial/adding-course-enrollments.adoc[]
2 changes: 0 additions & 2 deletions modules/tutorials/partials/tutorial-globals.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@

:java-sample-location: java-sdk:student:example$

:point-to-capella: pass:q[This tutorial is designed for use with standalone or Docker installations of the Couchbase Server. If you wish to use https://www.couchbase.com/products/capella[the Couchbase Capella cloud service] then you can run through the tutorials for https://docs.couchbase.com/cloud/get-started/get-started.html[Getting Started with Couchbase Capella].]