Oracle Sub Types for Data Types: Exception Block

An unconstrained subtype has the same set of values as its base type, so it is only another name for the base type.

Syntax:

SUBTYPE subtype_name IS base_type
Example:
 
SUBTYPE "DOUBLE PRECISION" IS FLOAT
SUBTYPE Balance IS NUMBER;

Constrained SubType
 
SUBTYPE Balance IS NUMBER(8,2);

Oracle Exception Block Example:



Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm


						
						
						
		

Misc. Oracle: Data Types: Why a Data Type.

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/02_funds.htm

https://stackoverflow.com/questions/7425153/reason-why-oracle-is-case-sensitive

Oracle Data Types and Allowed Sizes:

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS99943

Oracle SIMPLE_FLOAT vs SIMPLE_DOUBLE

Ref: https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/datatypes.htm#CJAEAEJG

PLS_Integer vs Number

"The PLS_INTEGER data type has these advantages over the NUMBER data type and NUMBER subtypes:

  • PLS_INTEGER values require less storage.
  • PLS_INTEGER operations use hardware arithmetic, so they are faster than NUMBER operations,

"

Ref: https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS319

Hardly anything is by me. All are from external sources. Credit belongs to them.

Oracle Data types, ROWID, PLS_INTEGER vs INTEGER

Data Types

Ref: https://docs.oracle.com/cd/A97630_01/server.920/a96524/c13datyp.htm

(Click on the image to see it properly)

Why PLS_Integer:

https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/03_types.htm

“You use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -231 .. 231. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic. For efficiency, use PLS_INTEGER for all calculations that fall within its magnitude range.”

ROWID vs ROWNUM

ROWID is useful when you need to refer to a specific row in a table without using a primary key or unique constraint. Hence, ROWNUM is a pseudocolumn that assigns a unique row number to each row in a result set, while ROWID is a physical address that identifies a specific row in a table

https://www.c-sharpcorner.com/interview-question/what-is-the-difference-between-rownum-and-rowed

Simple Integer vs PLS_integer

https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-data-types.html

“SIMPLE_INTEGER has the same range as PLS_INTEGER and has a NOT NULL constraint. It differs significantly from PLS_INTEGER in its overflow semantics. If you know that a variable will never have the value NULL or need overflow checking, declare it as SIMPLE_INTEGER rather than PLS_INTEGER .”

Algorithm Complexity: Notations and Comparisons

Algorithm Complexity Notations and Comparisons:

Ref: https://www.freecodecamp.org/news/big-o-notation-why-it-matters-and-why-it-doesnt-1674cfa8a23c/

Algorithm Complexity: A simple example

The complexity here is: 3n+2 i.e. O(n)

Ref: https://www2.cs.sfu.ca/CourseCentral/125/johnwill/Packet06.pdf

Java spring application demo

https://youtu.be/euJzoAbaXjc

Proxy Pattern

Proxy Pattern:

“Proxy is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.

A credit card is a proxy for a bank account, which is a proxy for a bundle of cash. Both implement the same interface: they can be used for making a payment. A consumer feels great because there’s no need to carry loads of cash around. A shop owner is also happy since the income from a transaction gets added electronically to the shop’s bank account without the risk of losing the deposit or getting robbed on the way to the bank.

Click on the images to see them clearly.

In the above UML class diagram, the Proxy class implements the Subject interface so that it can act as substitute for Subject objects. It maintains a reference (realSubject) to the substituted object (RealSubject) so that it can forward requests to it (realSubject.operation()).

UML Class Diagram

https://refactoring.guru/design-patterns/proxy

https://en.wikipedia.org/wiki/Proxy_pattern

Java: Facade Design Pattern

Façade Pattern

“Facade is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes.”

“When you call a shop to place a phone order, an operator is your facade to all services and departments of the shop. The operator provides you with a simple voice interface to the ordering system, payment gateways, and various delivery services.”

For a clear view, click on the images (images are from Wikipedia)

Ref: https://refactoring.guru/design-patterns/facade

https://en.wikipedia.org/wiki/Facade_pattern

Java : Decorator Design pattern

Decorator Design pattern:

Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.

Example:

Assume: A notifier class/object can send only email messages. But the application at a later time may want to use text/SMS, FB, or similar messages. With decorator pattern: decorate the Notifier class with other behaviours such as send SMS, send fb message, send twitter message (i.e. may create additional classes/objects (create link to original notifier class with interfaces/inheritance and aggregations/compositions) ). Then the client can use the original notifier class/object but dynamically point to the other classes/objects and use the corresponding sendMessage() method/behaviour for SMS, Text, FB, Twitter or similar messaging/notification.

Note: Inheritance/subclasses can be a choice but they have limitations. Aggregations/Compositions/interfaces will be used for the purpose of Decorator pattern.

Note: “When does a simple wrapper become the real decorator? As I mentioned, the wrapper implements the same interface as the wrapped object. That’s why from the client’s perspective these objects are identical.

Ref: https://refactoring.guru/design-patterns/decorator

https://en.wikipedia.org/wiki/Decorator_pattern

Java Structural Design Patterns

Adapter Design Patterns

Ref: A good read: https://refactoring.guru/design-patterns/adapter

Ref: Wikipedia

Ref: https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/