Skip to main content

Java Database Connectivity

Relational Database Basicsโ€‹

Schemaโ€‹

A schema represents a logical grouping, or namespace, for database objects such as tables, views, and procedures. In some database systems, like PostgreSQL and Oracle, the term schema is used to
represent the namespace within a database where objects are organized. These systems can have multiple schemas within a single database. In other database systems, like MySQL, the term schema is often used interchangeably with database.

Common Database Objectsโ€‹

ObjectDescription
tableA table stores rows or records of data, in attribute fields, with values specific to that record.
indexAn index consists of a table name, a key value and a record locator field, to quickly access a record from a table. A primary key is a unique identifier for a record.
viewA view is a stored query, which can be accessed like a table, but hides the details of the table implementation from the client.
userA user represents a package a privileges to database artifacts given to an account.

SQLโ€‹

In databases, the language lets us create objects, populate them with information, create relationships, and query data. This language is called the Structured Query Language, or SQL.

DDLโ€‹

The Data Definition Language is used to define, create, manage, and modify the database objects. DDL statements don't manipulate the data in the object, instead they manipulate data structures, that store and organize the data.

CommandDescription
createUsed to create database objects like tables, indexes, views, and schemas.
alterUsed to modify the structure of existing database objects.
dropUsed to delete or remove database object.
truncateUsed to remove all rows from a table while keeping the table structure intact.
renameUsed to rename database objects.

DMLโ€‹

The Data Manipulation Language, is used to interact with, and manipulate, the data stored within the database objects or artifacts. DML statements perform operations like inserting, updating, retrieving, and deleting data in the database.

CommandDescription
selectUsed to retrieve data from one or more tables.
insertUsed to add new rows of data into a table.
updateUsed to modify existing data in a table.
deleteUsed to remove rows from a table.

Relationsโ€‹

Database tables can be associated with one another, through different kinds of relationships.

RelationshipDescription
One to OneOne row in the first table is related to only one row in a second table.
One to ManyOne row in the first table is related to many rows in a second table.
Many to ManyMany rows in the first table are related to many rows in a second table.

Normalization & Joinโ€‹

On normalization and normal forms check out this. A join is a SQL clause, that combines rows from two or more tables, based on a common field.

Join TypeResult
inner joinReturns all rows from both tables where the join condition is met
left joinReturns all rows from the left table, even if there is no matching row in the right table.
right joinReturns all rows from the right table, even if there is no matching row in the left table.
full joinReturns all rows from both tables, regardless of whether there is a matching row in the other table.
cross joinReturns all possible combinations of rows from the two tables.