Developer Guideline
  • Home
  • 🧠Must you know
    • Algorithm
    • Architecture
      • API
    • Comparison
      • ID Token vs Access Token
      • Lazy Loading vs Eager Loading
      • Morphs vs Foreign Key
      • UUID vs ULID
      • GraphQL vs REST
      • Cache vs CDN
      • Concurrency vs Parallelism
      • Null vs Not Null
    • Diagram
      • CI/CD Pipeline
      • High Performance Culture
  • ☂️Laravel
    • Template
      • Template System Check in Route on Laravel
      • Template Function in FormController on Laravel
      • Template Route call FormController on Laravel
      • Template Route Prefix Name on Laravel
      • Template Basic and Custom Pagination on Laravel
      • Template PHP Artisan Command
      • Template Route for App Environment
    • Feature
      • Data Type
      • Mailables
      • Rules
    • Package
    • Document
  • 🫖Collaboration Agreement
    • Naming Convention
      • Naming Convention for Git Branch
      • Naming Convention for Environment Variable
    • Rule
      • Rule of Commit Message
      • Semantic Versioning
  • 🦣Project Manager
    • Requirements
      • System Requirements
      • Technical Requirements
      • Functional Requirements
Powered by GitBook
On this page
  • 🆚 Comparison
  • 🅰️ UUID
  • 🅱️ ULID
  1. Must you know
  2. Comparison

UUID vs ULID

UUID และ ULID ทั้งสองวิธีที่ใช้สำหรับการสร้างค่าที่ไม่ซ้ำกัน แต่มีคุณสมบัติและการใช้งานที่แตกต่างกันไป

🆚 Comparison

Feature
UUID
ULID

Full Name

Universally Unique Identifier

Universally Unique Lexicographically Sortable Identifier

Length

128 bits (32 hex digits, 36 characters with hyphens)

128 bits (26 characters in Base32)

Characters

Hexadecimal (0-9, a-f)

Crockford's Base32 (0-9, A-Z excluding I, L, O, U)

Structure

Randomly generated or timestamp-based

Timestamp + Randomness

Timestamp

Optional (only for UUIDv1)

Yes (48-bit timestamp in milliseconds)

Random Component

Yes

Yes

Lexicographically Sortable

No

Yes

URL Safe

No (requires encoding)

Yes

Collision Probability

Very low

Very low

Variants

UUIDv1, UUIDv2, UUIDv3, UUIDv4, UUIDv5

One primary format

Common Use Cases

Database keys, distributed systems, object identifiers

Database keys, log entries, event sourcing

RFC Specification

RFC 4122

No formal RFC; specification available at ulid.dev

Generation Libraries

Widely available in most languages

Available in many languages

Advantages

Widely supported, standard format

Lexicographically sortable, URL safe

Disadvantages

Not sortable, longer representation

Less widely known, fewer implementations

🅰️ UUID

การใช้งาน : นิยมใช้ในหลากหลายระบบ เช่น ระบบฐานข้อมูล ระบบการจัดการไฟล์ ระบบเครือข่าย เป็นต้น

ข้อดี : ง่ายต่อการสร้างและไม่จำเป็นต้องพึ่งพาเวลา

ข้อเสีย : ไม่สามารถเรียงลำดับตามเวลาได้ ทำให้ไม่เหมาะกับการใช้งานที่ต้องการการจัดเรียงข้อมูลตามเวลา

123e4567-e89b-12d3-a456-426614174000

🅱️ ULID

การใช้งาน : เหมาะกับระบบที่ต้องการการจัดเรียงข้อมูลตามเวลา เช่น การเก็บล็อก หรือการจัดการฐานข้อมูลที่ต้องการการสืบค้นที่เร็ว

ข้อดี : สามารถเรียงลำดับตามเวลาได้อย่างมีประสิทธิภาพ

ข้อเสีย : มีความยาวของอักขระที่มากกว่า UUID เล็กน้อย และไม่เป็นที่รู้จักหรือใช้แพร่หลายเท่ากับ UUID

01BX5ZZKBKACTAV9WEVGEMMV2M

PreviousMorphs vs Foreign KeyNextGraphQL vs REST

Last updated 10 months ago

🧠