-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
data_structures/src/KeyPatterns/SlidingWindow/MinMaxExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package KeyPatterns.SlidingWindow; | ||
|
||
public class MinMaxExample { | ||
public static void Examples() { | ||
basic(); | ||
findingSmallerLarger(); | ||
dailyTempleratureMonitoring(); | ||
keepingValueWithinRange(); | ||
comparingTransactionLimits(); | ||
gamingHealh(); | ||
} | ||
|
||
private static void gamingHealh() { | ||
System.out.println("\n(Min Max) Gaming Health ==> "); | ||
int health = 90, maxHealth = 100; | ||
health = Math.min(health + 20, maxHealth); | ||
System.out.println("Current Health ==> " + health); | ||
} | ||
|
||
private static void comparingTransactionLimits() { | ||
System.out.println("\n(Min Max) Comparing Transation Limits ==> "); | ||
double withdrawAmount = 500.0, balance = 300.0; | ||
double maxWithdraw = Math.max(withdrawAmount, balance); | ||
System.out.println("Allowed withdrawal: $" + maxWithdraw); | ||
} | ||
|
||
private static void keepingValueWithinRange() { | ||
System.out.println("\n(Min Max) Keeping value within range ==> "); | ||
int value = 120, min = 0, max = 100; | ||
int clampedValue = Math.max(min, Math.min(value, max)); | ||
System.out.println("clampedValue ==> " + clampedValue); | ||
} | ||
|
||
private static void dailyTempleratureMonitoring() { | ||
System.out.println("\n(Min Max) Daily Temperature Monitoring ==> "); | ||
double templ1 = 18.5, temp2 = 22.1; | ||
double lowest = Math.min(templ1, temp2); | ||
double highest = Math.max(templ1, temp2); | ||
System.out.println("Lowest temp : " + lowest); | ||
System.out.println("Highest temp : " + highest); | ||
} | ||
|
||
private static void findingSmallerLarger() { | ||
System.out.println("\n(Min Max) Finding the Smaller/Larger Number in a List ==> "); | ||
int[] numbers = { 15, 3, 7, 22, 10 }; | ||
int minVal = numbers[0], maxVal = numbers[0]; | ||
for (int num : numbers) { | ||
minVal = Math.min(minVal, num); | ||
maxVal = Math.max(maxVal, num); | ||
} | ||
System.out.println("Min: " + minVal + ", Max: " + maxVal); | ||
} | ||
|
||
private static void basic() { | ||
System.out.println("\n(Min Max) basic Usage ==> "); | ||
int a = 10, b = 20; | ||
System.out.println(Math.min(a, b)); | ||
System.out.println(Math.max(a, b)); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
sql/full_course/multi_tenant_ecommerce/db_tables/tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
USE multi_tenant_ecom_db; | ||
|
||
CREATE TABLE Users ( | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(255) NOT NULL, | ||
email VARCHAR(255) NOT NULL, | ||
uesr_type VARCHAR(50) CHECK (user_type IN ('customer', 'vendor')) NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TABLE Vendors ( | ||
id SERIAL PRIMARY KEY, | ||
user_id INT UNIQUE NOT NULL REFERENCES Users(id), | ||
company_name VARCHAR(255) NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TABLE Products ( | ||
id SERIAL PRIMARY KEY, | ||
vendor_id INT NOT NULL REFERENCES Vendors(id), | ||
name VARCHAR(255) NOT NULL, | ||
description TEXT, | ||
price DECIMAL(10, 2) NOT NULL, | ||
stock_quantity INT NOT NULL CHECK (stock_quantity >= 0), | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TABLE Orders( | ||
id SERIAL PRIMARY KEY, | ||
customer_id INT NOT NULL REFERENCES Users(id), | ||
status VARCHAR(50) CHECK (status IN ('pending', 'shipped', 'delivered', 'cancelled')) DEFAULT 'pending', | ||
total_price DECIMAL(10, 2) NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); |