Chandan Shakya's Blog

SQL Conventions for Laravel

  1. Table Names:
    • Plural, snake_case (e.g., users, posts)
  2. Column Names:
    • Snake_case (e.g., user_id, created_at)
  3. Primary Keys:
    • id, auto-incrementing integer
  4. Foreign Keys:
    • Related table name + _id (e.g., user_id)
  5. Timestamps:
    • created_at, updated_at
  6. User Table:
    CREATE TABLE users (
        id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(255) NOT NULL,
        email VARCHAR(255) UNIQUE NOT NULL,
        password VARCHAR(255) NOT NULL,
        remember_token VARCHAR(100),
        created_at TIMESTAMP NULL,
        updated_at TIMESTAMP NULL
    );
    
  7. Posts Table:
    CREATE TABLE posts (
        id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        user_id BIGINT UNSIGNED NOT NULL,
        title VARCHAR(255) NOT NULL,
        body TEXT NOT NULL,
        created_at TIMESTAMP NULL,
        updated_at TIMESTAMP NULL,
        FOREIGN KEY (user_id) REFERENCES users(id)
    );
    
  8. Pivot Table:
    CREATE TABLE role_user (
        user_id BIGINT UNSIGNED NOT NULL,
        role_id BIGINT UNSIGNED NOT NULL,
        PRIMARY KEY (user_id, role_id),
        FOREIGN KEY (user_id) REFERENCES users(id),
        FOREIGN KEY (role_id) REFERENCES roles(id)
    );
    
  9. Indexing Conventions:
    • Define primary key (e.g., PRIMARY KEY (id))
    • Index foreign keys (e.g., INDEX (user_id))
    • Unique indexes for unique columns (e.g., UNIQUE (email))
  10. Data Types Conventions:
    • BIGINT UNSIGNED for primary keys, INT UNSIGNED for foreign keys
    • VARCHAR(255) for variable-length strings, TEXT for longer texts
    • TIMESTAMP, nullable by default for optional timestamps
read more

Quote from 10 Things I Hate About You

Mr. Morgan : All right… I assume everyone’s found time to complete their poem… except… for Mr. Donner.

[starts laughing]

Mr. Morgan : Who has an excuse

[laughs even harder, then stops]

Mr. Morgan : . Shaft! Lose the glasses.

[Joey removes his sunglasses, revealing his bruised nose from his earlier confrontation with Bianca]

Mr. Morgan : All right… anyone brave enough to read theirs aloud?

[Everyone looks at each other, waiting to see who goes first, Kat finally raises her hand]

Kat Stratford : I will.

Mr. Morgan : [rolls his eyes and sighs] Lord, here we go.

Kat Stratford : I hate the way you talk to me, and the way you cut your hair. I hate the way you drive my car. I hate it when you stare. I hate your big dumb combat boots, and the way you read my mind. I hate you so much it makes me sick; it even makes me rhyme.

[sighs]

Kat Stratford : I hate it, I hate the way you’re always right. I hate it when you lie. I hate it when you make me laugh, even worse when you make me cry.

[Kat’s voice breaks and she looks at Patrick]

Kat Stratford : I hate it when you’re not around, and the fact that you didn’t call.

[starts to cry]

Kat Stratford : But mostly I hate the way I don’t hate you. Not even close, not even a little bit, not even at all.

[Kat walks out the classroom]

read more

Welcome to Chandan Shakya's Blog

Welcome to all the readers to my first blog.

#include <stdio.h>
int main(void) {
    printf("Hello, World!\n");
    return 0;
}

Check out the Portfolio for my general portfolio.

Check out my GitHub for my repositories.

Check out my Twitter for things I post.

Check out my stackoverflow for my knowledge.

read more