Skip to content

Instantly share code, notes, and snippets.

View mjapanwala's full-sized avatar

MJ mjapanwala

View GitHub Profile
interface Schedule {
starting:string,
ending:string,
enabled:boolean
day?:string
}
interface Scheduling {
[k:string]: Schedule
}
@mjapanwala
mjapanwala / gist:75a12ddef9f241e469a7aedfdd4c3285
Last active June 28, 2023 05:59
One - Many Relationship
In a one to many relationship these things are key.
Suppose you have two tables, one users and the other is orders. In the users table you can have columns such as
PRIMARY_KEY UNIQUE AUTO_INCREMENT number, VARCHAR(255) email.
The orders table you have the column order_date date, PRIMARY_KEY AUTO_INCREMENT UNIQUE, price FLOAT, FOREIGN_KEY users.PRIMARY_KEY
This would be a parent - child relationship, the parent is the users and the child is the orders.
If you have two tables suppose Users table and a UsersProfile Table.
In your users table you will have things like user_id PRIMARY_KEY AUTO_INCREMENT/SERIAL, email VARCHAR(244), password varchar(12)
In your user_profile table you will have PRIMARY_KEY users.user_id FOREIGN_KEY users.user_id, first_name VARHCAR(122), last_name VARCHAR(133)
The primary and foreign key needs to be referencing the users table. The reason for this because it forces data integrity, and forcing a one to one relationship
between the two tables.
One-toOne relationships are typically used to split the data that may not always be needed together or to seperate sensitive information into
a seperate table,
const sum = [5, 1, 4, 8]
const reduceFunction = sum.reduce(function(accumulator, currentValue) {
return accumulator + currentValue
},0)
accumulator is either the initial value to begin with which is the second argument, or the total of the iteration, the last iteration will be the result.
current value will be each element.
const menuAndCategory = [
{
menu_name: "First Menu",
menu_description: "I love menus and everything it brings me ",
menu_unique_menu_id: "7d491498-8702-41ba-af53-4dff90f46fc8",
category_name: "Breakfast",
unique_category_id: "71f317cb-6376-4435-ba6c-3a57d006bca6",
product_id: "eda57dcf-234f-423a-9ee3-433e8264ab91",
},
{