Database Shape
Learn how to use the Database cylinder shape for data storage operations in ISO 5807 flowcharts
Database Shape
The Database shape is a cylinder that represents database operations and data storage in your flowchart. It indicates reading from or writing to a database system.
What is a Database Shape?
The Database shape (also called Database Cylinder or Storage Cylinder) represents:
- Database query operations
- Data retrieval from databases
- Storing data in databases
- Database transactions
- Persistent data storage
According to ISO 5807, the cylinder shape specifically represents stored data in a database or direct-access storage device.
When to Use
Use the Database shape for:
- Database queries: "SELECT user FROM users", "Query customer records"
- Data storage: "Save order to database", "Insert new record"
- Data updates: "Update user profile", "Modify inventory"
- Data deletion: "Delete expired records", "Remove user account"
- Transactions: "Begin transaction", "Commit changes"
ISO 5807 Standard
According to ISO 5807, the Database symbol is defined as:
- A cylinder shape (3D drum/barrel)
- Represents direct-access storage
- Used for database operations
- Indicates persistent data storage
This shape specifically denotes database or random-access storage, distinct from sequential file storage.
Visual Appearance
In DiagramKit.AI, the Database shape appears as:
- Dimensions: 180×110 pixels
- Color: Light emerald (#ecfdf5)
- Border: Emerald green (#059669)
- Shape: Cylinder with curved top and bottom
Best Practices
✅ Good Usage
[Start]
   ↓
[Get user ID]
   ↓
[Query user from database]
   ↓
<User found?>
  ↙        ↘
Yes        No
 ↓          ↓
[Load     [Create
 profile]   new user]
   ↓          ↓
[Save to database]
   ↓
[End]
- Specify the operation type (Query, Save, Update, Delete)
- Include table/collection name when relevant
- Use database terminology (SELECT, INSERT, UPDATE, etc.)
- Show what data is being stored or retrieved
❌ Avoid
- ❌ File operations: "Read from file" (use Stored Data instead)
- ❌ Processing: "Calculate total" (use Process shape)
- ❌ Too vague: "Database" (what operation?)
- ❌ Multiple operations: "Query and update database" (split them)
Common Examples
Example 1: User Authentication
[Start]
   ↓
[Get credentials]
   ↓
[Query user by username
 from database]
   ↓
<User exists?>
  ↙        ↘
Yes        No
 ↓          ↓
<Password  [Return
 matches?>  error]
  ↙    ↘
Yes    No
 ↓      ↓
[Login] [Error]
Example 2: CRUD Operations
[Receive request]
   ↓
<Operation type?>
  ↙   ↓    ↓   ↘
Create Read Update Delete
  ↓    ↓    ↓     ↓
[Insert [SELECT [UPDATE [DELETE
 into DB] from DB] in DB] from DB]
Example 3: Transaction Processing
[Begin transaction]
   ↓
[Insert order to database]
   ↓
[Update inventory in database]
   ↓
<Success?>
  ↙      ↘
Yes      No
 ↓        ↓
[Commit  [Rollback
 trans]   trans]
Label Writing Guidelines
Strong Labels (Recommended)
- "Query products from inventory table"
- "Insert new user record to database"
- "Update order status in orders table"
- "Delete expired sessions from database"
- "Fetch customer by ID from database"
Weak Labels (Avoid)
- "Database" (what operation?)
- "Get data" (use Process or I/O instead)
- "Save" (where specifically?)
- "Storage" (too generic)
AI Prompt Tips
Use these prompts to add Database shapes with AI:
add a database query to fetch user data
insert a database operation to save the order
create a database step that updates inventory
add a database lookup for customer records
Programming Equivalents
Database shapes represent database operations:
SQL Queries:
-- Database: Query user from database
SELECT * FROM users WHERE id = ?;
-- Database: Insert order to database
INSERT INTO orders (user_id, total, date) VALUES (?, ?, ?);
-- Database: Update inventory in database
UPDATE products SET quantity = quantity - 1 WHERE id = ?;
-- Database: Delete expired records from database
DELETE FROM sessions WHERE expires_at < NOW();
JavaScript/TypeScript (with ORM):
// Database: Query user from database
const user = await db.users.findOne({ id: userId });
// Database: Save new user to database
await db.users.create({ name, email, password });
// Database: Update user profile in database
await db.users.update({ id: userId }, { name: newName });
// Database: Delete user from database
await db.users.delete({ id: userId });
Python (with SQLAlchemy):
# Database: Query products from database
products = session.query(Product).filter_by(category='electronics').all()
# Database: Insert new record to database
new_user = User(name='John', email='john@example.com')
session.add(new_user)
session.commit()
# Database: Update record in database
user = session.query(User).filter_by(id=user_id).first()
user.status = 'active'
session.commit()
Database Operations Categories
Read Operations (SELECT)
- "Query user by email"
- "Fetch all products"
- "Get order details"
- "Retrieve customer history"
- "Lookup inventory status"
Write Operations (INSERT)
- "Insert new customer"
- "Save order to database"
- "Create user record"
- "Add log entry"
Update Operations (UPDATE)
- "Update user status"
- "Modify product price"
- "Change order status"
- "Increment page views"
Delete Operations (DELETE)
- "Delete expired tokens"
- "Remove user account"
- "Clear old logs"
- "Purge archived data"
Transaction Patterns
Simple Transaction
[Begin transaction]
   ↓
[Update account A in database]
   ↓
[Update account B in database]
   ↓
<All success?>
  ↙        ↘
Yes        No
 ↓          ↓
[Commit]  [Rollback]
With Validation
[Validate input]
   ↓
<Valid?>
  ↙    ↘
Yes    No
 ↓      ↓
[Query [Return
 user]  error]
 ↓
<Exists?>
 ↙    ↘
Yes   No
 ↓     ↓
[Update] [Insert]
 database database
Connections
Database shapes typically connect:
Input from:
- Process shapes (before DB operation)
- Data I/O shapes (after getting input)
- Decision shapes (conditional queries)
- Preparation shapes (transaction setup)
Output to:
- Decision shapes (to check results)
- Process shapes (to handle data)
- Other Database shapes (chained operations)
- End symbols (after final save)
Database vs. Other Storage Shapes
| Use Database | Use Different Shape | |--------------|---------------------| | SQL database | Stored Data for files | | NoSQL database | Cloud if cloud-hosted | | In-memory DB | Process if temporary | | Query operation | Data I/O for general I/O |
Common Patterns
Check Before Insert
[Get new username]
   ↓
[Query user by username
 from database]
   ↓
<Already exists?>
  ↙            ↘
Yes            No
 ↓              ↓
[Error:       [Insert new
 duplicate]     user to DB]
Load-Modify-Save
[Query record from database]
   ↓
[Modify values]
   ↓
[Validate changes]
   ↓
<Valid?>
  ↙    ↘
Yes    No
 ↓      ↓
[Update [Discard
 in DB]  changes]
Cascade Operations
[Delete user from database]
   ↓
[Delete user orders from database]
   ↓
[Delete user sessions from database]
   ↓
[Update audit log in database]
Common Mistakes
Mistake 1: Using for File Operations
❌ Wrong: [Read from CSV file] (Database shape)
✅ Correct: [Read from CSV file] (Stored Data or Data I/O shape)
Mistake 2: Processing Instead of Query
❌ Wrong: [Calculate user age] (Database shape)
✅ Correct: [Query user birthdate from database] → [Calculate age] (Process)
Mistake 3: Too Generic
❌ Wrong: [Database operation]
✅ Correct: [Update user status to 'active' in database]
Mistake 4: Multiple Operations
❌ Wrong: [Query and update database]
✅ Correct: Split into [Query from database] → [Process] → [Update database]
Performance Considerations
Index Usage
[Check if user exists]
   ↓
<Uses indexed
 column?>
  ↙        ↘
Yes        No
 ↓          ↓
[Fast     [Slow
 query]    scan]
 from DB    in DB
Caching Strategy
[Need data]
   ↓
<In cache?>
  ↙      ↘
Yes      No
 ↓        ↓
[Use    [Query
 cache]  from DB]
          ↓
        [Update
         cache]
Security Patterns
SQL Injection Prevention
[Receive user input]
   ↓
[Sanitize input]
   ↓
[Prepare parameterized
 query]
   ↓
[Execute query
 on database]
Access Control
[Get user request]
   ↓
<Has
 permission?>
  ↙        ↘
Yes        No
 ↓          ↓
[Query    [Return
 from DB]  403 error]
Related Shapes
- Stored Data - For file-based storage
- Cloud - For cloud database services
- Data I/O - For general I/O operations
- Process - For data transformation
- Decision - For conditional queries
Pro Tip: Always specify the SQL operation in your database labels: "SELECT users WHERE...", "INSERT INTO orders...", "UPDATE inventory SET...". This makes your flowchart a great reference for developers!
Next Steps
- Learn about Stored Data for file operations
- Explore Cloud for cloud services
- Understand Data I/O for general I/O
- Review transaction patterns for complex flows
