-
Notifications
You must be signed in to change notification settings - Fork 4
- kg3159 Khaliun Gerel
- wrote the template
Organizations generate and store huge amounts of data and this data is often stored in relational databases like PostgreSQL, MySQL, or Snowflake. These databases are great for organizing and storing data, but working with them can be a challenge, especially for people who don’t know SQL or other programming languages. Here are the main issues:
- Anyone can access data: People who don’t know SQL or programming often rely on technical teams to write queries and fetch data for them. This slows things down.
- Understanding Data: Even when you have the data, making sense of it—like creating graphs, dashboards, or summaries—can require more advanced tools and skills.
- Working Together: Data work is often not a solo task. Teams need to collaborate, share insights, and review each other’s work, which many existing tools don’t make easy.
- Switching Tools: To analyze data, you might need one tool for querying, another for writing code, and yet another for creating dashboards.
Hex brings everything related to data into one tool. It connects directly to relational databases, so you can access your data without needing to export it or move it to another tool. Here's how Hex solves the main problems:
- SQL and Python: Hex allows you to write SQL queries to fetch data from relational databases. If you’re comfortable with Python, you can use that too. For beginners, it offers features like autocomplete and templates to guide you.
- No-Code Options: For people who don’t know SQL or Python, Hex provides a drag-and-drop interface. This means anyone can build dashboards, charts, and graphs without writing a single line of code.
- Collaboration: Hex is like Google Docs for data. Multiple people can work together on the same project, leave comments, and see updates in real time.
- Interactive Visualizations: Hex helps turn tables into interactive charts and dashboards. These can be shared with others or embedded into websites.
There are other tools like Tableau, Looker, and Jupyter Notebooks that people use to work with data. But Hex stands out because it combines the best parts of these tools into one platform:
- Compared to Tableau: Tableau is great for creating visualizations, but you need to prepare your data beforehand. Hex lets you query, analyze, and visualize data all in one place.
- Compared to Looker: Looker focuses on predefined data models. Hex gives you more freedom to explore and work with raw data directly.
- Compared to Jupyter Notebooks: Jupyter Notebooks are loved by data scientists but lack collaboration features and polished dashboards. Hex offers both.
Drawbacks
- Hex relies on the underlying database for query execution and optimization. If the database is not properly indexed, optimized, or performant, Hex can feel slow, especially with large datasets or complex queries.
- Hex’s visualization capabilities, while powerful, are not as advanced or customizable as dedicated visualization tools like Tableau or Power BI. Users requiring highly detailed or specialized charts (e.g., advanced geospatial visualizations, highly customized dashboards) may find Hex lacking.
- Hex is primarily designed as an online, collaborative platform. Exporting dashboards or results to other formats (e.g., offline Excel files, PDFs) can be limited or less streamlined.
- Hex focuses on relational databases and may have limited functionality or compatibility with non-relational (NoSQL) databases like MongoDB or DynamoDB.
- Relational Model and Querying: Hex directly connects to these relational databases. Users can write SQL queries to select, filter, and combine data from multiple tables.
- Constraints and Data Integrity: In relational databases, constraints like primary keys and foreign keys ensure that the data stays accurate and consistent. Hex respects these constraints when querying data. If you try to insert or update data in a way that breaks these rules, Hex will show the error message from the database. For example, If your database has a foreign key constraint between posts and comments, Hex ensures your queries follow these rules.
- Query Optimization: Hex doesn’t directly optimize queries, but it relies on the database to do this work. Hex gives users tools to write efficient queries, like suggesting indexes or writing subqueries. For example, If you’re running a slow query, Hex suggest simplifying it or using indexed columns.
- Transactions and ACID Properties: Relational databases handle transactions using ACID properties (atomicity, consistency, isolation, durability) to ensure data reliability. When you use Hex to update data or run complex workflows, it communicates with the database to ensure all changes are handled as transactions. For example, If you update a post's content and it fails halfway, the database will roll back to ensure no partial changes are saved.
- Turning Data into Visual Insights: Hex simplifies the process of turning query results into actionable insights. For example, the output of a SQL query (a table) can be immediately visualized as a bar chart or line graph, making it easier to understand trends.
Hex connects to relational databases like PostgreSQL, Snowflake, and MySQL. This means you can directly fetch, analyze, and manipulate data stored in these systems without needing extra tools. How It Works:
- Connect Your Database: Use Hex’s simple interface to connect to your database by providing credentials, such as the database URL, username, and password.
- Run Queries: Write SQL queries in Hex to interact with your database.
- Hex provides auto-complete for SQL, so even beginners can quickly write queries without knowing all the exact syntax.
- While Hex doesn’t directly optimize queries, it relies on the underlying database to do so. Hex’s interface allows you to focus on writing queries while the database ensures efficient execution.
One standout feature of Hex is its Writeback capability. Unlike traditional analytics tools that are “read-only” (you can only view data), Hex allows you to update, insert, and delete data directly in your database. Writeback lets users modify data in the database from within Hex. This is especially useful for tasks like:
- Updating incorrect data in real-time.
- Adding new records (e.g., writing new comment).
- Cleaning up outdated or incorrect records.
- Testing changes in sandbox environments before implementing them in production.
How to Use Writeback:
- Enable Writeback: Database administrators must enable write permissions for Hex. This ensures only authorized users can modify data.
- Run SQL Commands: Insert, Update, etc
- Preview Changes: Hex provides a “preview” mode to check your updates before applying them, reducing the chance of errors.
- Track Changes: Hex logs changes made through Writeback, so you can always see who modified what and when.
Advantages of Writeback
- Reduces the need for switching between tools like database clients and analytics platforms.
- Allows quick, real-time corrections or updates without needing a developer or database admin.
Hex ensures transactional consistency when using the Writeback feature. For example:
BEGIN TRANSACTION;
INSERT INTO Comment (comment_id, date, text) VALUES (1001, '2024-12-08', 'Great player!');
INSERT INTO like (comment_id, email) VALUES (1001, '[email protected]');
COMMIT;
Hex ensures that if one query fails (e.g., adding the like), the entire transaction rolls back to maintain consistency.
Hex supports Python for advanced data manipulation and analytics. This is helpful when SQL alone isn’t enough, such as for Complex data transformations, Machine learning workflows and Advanced statistical analysis. You can query data in SQL and then process it further using Python libraries like Pandas, NumPy, or Matplotlib.
Hex turns raw data into interactive, shareable dashboards. Instead of just viewing query results in a table, you can create graphs, charts, and maps directly in Hex. How It Works:
- Choose Visualization Type: Hex offers a variety of visualization types, including: Bar charts, Line graphs, Scatter plots, Heatmaps
- Drag-and-Drop Interface: For non-technical users, Hex provides an easy drag-and-drop tool to build dashboards without coding.
- Dynamic Dashboards: Dashboards update in real-time based on changes to the underlying data or filters added by the user.
- Embed or Share: Share dashboards via a link or embed them in external applications.
Hex is designed for teams, making it easy to work together on data projects. Multiple people can edit a Hex project simultaneously, similar to Google Docs. Team members can leave comments on SQL queries, Python code, or visualizations to ask questions or suggest changes. Hex automatically saves versions of your projects. You can track changes made over time and restore earlier versions if needed.
Set Up Your Database in Hex:
- Log in to your Hex account.
- Navigate to "Data Sources" and select the type of database you are using (e.g., PostgreSQL, MySQL).
- Provide the connection details (e.g., host, port, username, password, and database name) to link Hex with your database. Test the Connection:
- Use Hex’s interface to run a simple query and ensure the connection is working


You can query a table by clicking on the Query Table option for a table, or by creating an SQL query frame from the notebook
Example: Fetch how many players are associated with each team in descending order:
SELECT t.team_id, t.team_name, COUNT(*) AS c
FROM team t JOIN team_player tp ON t.team_id = tp.team_id
GROUP BY t.team_id
ORDER BY c desc
Result:

Example Query: Get Top 5 Rated Players
SELECT
p.player_name,
AVG(ur.score) AS avg_rating
FROM
kg3159.player as p
JOIN
kg3159.user_rating as ur ON p.player_id = ur.player_id
GROUP BY
p.player_name
ORDER BY
avg_rating DESC
LIMIT 5;
After running the query, go to the Chart tab where you can select a chart type, such as Column, Bar, Line, etc. Once you select a chart type, specify the required chart inputs, such as the x-axis and y-axis, and the visualization will be displayed.
Hex’s Writeback feature lets you modify data directly from your interface. Example Use Case: Update Player Information Let’s say a player's points value needs to be corrected. You can use a query like this:
UPDATE kg3159.player
SET points = 50
WHERE player_id = 22;
Enable Writeback for your database in Hex (this requires administrator permissions). Execute the query above to update the player's stats.

Once your queries and visualizations are complete, you can build a dashboard in Hex for your team to explore:
- Add interactive filters, such as team_name and avg_rating, to allow users to explore data dynamically.
- Customize the dashboard by adding titles, descriptions, and explanations for your visualizations.
- Generate a shareable link or embed the dashboard in a web application.
