1. Database Design Basics

Pulkit
2 min readJun 23, 2024

--

What is a Database?
A database is a structured and systematic way of storing information to be accessed, analyzed, transformed, updated, and moved to other databases. It is a critical tool for managing and analyzing large amounts of data, and its components and types vary depending on the specific needs of the organization using it.

Objectives of Database
1. Fast Reads: Ensure that data can be retrieved quickly and efficiently.
2. Fast Writes: Allow data to be inserted, updated, and deleted rapidly.
3. Persistent Data: Ensure that data is stored securely and reliably.

Database Implementation
1. Array: Read is O(n) and Write is O(1). Suitable for small datasets.
2. Append Only Log: Always search from bottom to top. Useful for logging purposes.
3. Hashmap: Only good if the whole hashmap can fit in memory. Efficient for lookups.
4. Indexing: Keep extra data on each write to improve database writes.

Types of Indexes
1. Hash Indexes: Relies on hashmap, so all keys should fit in memory. Bad for range queries.
2. SSTables and LSM Trees: Write goes to an in-memory balanced search tree and eventually written to disk. Uses a write-ahead log to increase persistence.
3. B Trees: Efficient for both reads and writes, but can be complex to implement.

Database Design Process
1. Determine the Purpose of Your Database: Write down the purpose of the database, including how it will be used and by whom.
2. Find and Organize the Information Required: Gather all types of information you might want to record in the database.
3. Divide the Information into Tables: Divide your information items into major entities or subjects, such as Products or Orders.
4. Turn Information Items into Columns: Decide what information you want to store in each table.
5. Specify Primary Keys: Choose each table’s primary key, which is used to uniquely identify each row.
6. Set Up Table Relationships: Look at each table and decide how the data in one table is related to the data in other tables.
7. Refine Your Design: Analyze your design for errors, create sample data, and test the design.
8. Apply Normalization Rules: Ensure that the database is structured correctly to avoid redundancy and ensure data integrity.

Conclusion
Database design is essential for managing and organizing data effectively. It ensures data is stored efficiently, retrieved quickly, and maintained consistently. By following a structured approach, organizations can create databases that not only store data but also provide optimal performance and flexibility for various applications

--

--