Database Schema Designer
Run ID: 69cd11603e7fb09ff16a79d82026-04-01Development
PantheraHive BOS
BOS Dashboard

Step 2 of 3: Generated Database Schema Code (SQL DDL)

This document provides the comprehensive, detailed, and production-ready SQL Data Definition Language (DDL) code for a sample database schema, generated based on the "Database Schema Designer" workflow. This output is designed to be directly actionable, allowing you to create the foundational structure of your database.


1. Introduction

This deliverable contains the SQL DDL script necessary to create a relational database schema. For demonstration purposes, we have chosen a common application domain: a Simple Blog Platform. This schema includes tables, columns, primary keys, foreign keys, unique constraints, and appropriate data types, all designed for robust data integrity and efficient querying.

The generated code is clean, well-commented, and follows industry best practices, making it easy to understand, deploy, and maintain.

2. Assumptions & Context

3. Sample Database Schema Design (Conceptual Overview)

Our sample blog platform schema is composed of the following core entities and their relationships:

* Attributes: User ID, Username, Email, Password Hash, Registration Date.

* Attributes: Category ID, Name, Slug (URL-friendly name), Description.

* Attributes: Post ID, Author ID (FK to Users), Category ID (FK to Categories), Title, Slug, Content, Excerpt, Status (Draft, Published, Archived), Publication Date, Last Updated Date.

* Attributes: Tag ID, Name, Slug.

* Attributes: Post ID (FK), Tag ID (FK).

* Attributes: Comment ID, Post ID (FK to Posts), Author ID (FK to Users, nullable for guest comments), Content, Publication Date, Parent Comment ID (for nested comments).

Relationships:

4. Generated Code (SQL DDL Script)

Below is the production-ready SQL DDL script for the Simple Blog Platform schema.

sql • 9,900 chars
--
-- SQL Data Definition Language (DDL) Script
-- Database Schema: Simple Blog Platform
-- Generated by PantheraHive's Database Schema Designer
--
-- This script creates the necessary tables, columns, primary keys,
-- foreign keys, unique constraints, and indexes for a blog application.
--
-- Target RDBMS: PostgreSQL (syntax largely compatible with MySQL, SQL Server)
--

-- Ensure idempotency: Drop tables in reverse order of dependency
-- This allows re-running the script without issues if tables already exist.
DROP TABLE IF EXISTS Comments CASCADE;
DROP TABLE IF EXISTS PostTags CASCADE;
DROP TABLE IF EXISTS Tags CASCADE;
DROP TABLE IF EXISTS Posts CASCADE;
DROP TABLE IF EXISTS Categories CASCADE;
DROP TABLE IF EXISTS Users CASCADE;

--
-- Table: Users
-- Stores user account information.
--
CREATE TABLE Users (
    user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Unique identifier for the user (UUID recommended for distributed systems)
    username VARCHAR(50) NOT NULL UNIQUE,              -- Unique username for login
    email VARCHAR(100) NOT NULL UNIQUE,                -- Unique email address for notifications and password recovery
    password_hash VARCHAR(255) NOT NULL,               -- Hashed password for security (e.g., bcrypt)
    registration_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, -- Date and time of user registration
    last_login_date TIMESTAMP WITH TIME ZONE,          -- Date and time of the last user login
    is_active BOOLEAN DEFAULT TRUE                     -- Flag to indicate if the user account is active
);

COMMENT ON TABLE Users IS 'Stores information about registered users of the blog platform.';
COMMENT ON COLUMN Users.user_id IS 'Primary key: Unique identifier for each user.';
COMMENT ON COLUMN Users.username IS 'Unique username for login purposes.';
COMMENT ON COLUMN Users.email IS 'Unique email address for communication and account recovery.';
COMMENT ON COLUMN Users.password_hash IS 'Hashed password for secure authentication.';
COMMENT ON COLUMN Users.registration_date IS 'Timestamp when the user registered.';
COMMENT ON COLUMN Users.last_login_date IS 'Timestamp of the user''s last successful login.';
COMMENT ON COLUMN Users.is_active IS 'Boolean flag indicating if the user account is currently active.';


--
-- Table: Categories
-- Stores categories for blog posts.
--
CREATE TABLE Categories (
    category_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Unique identifier for the category
    name VARCHAR(100) NOT NULL UNIQUE,                 -- Name of the category (e.g., "Technology", "Lifestyle")
    slug VARCHAR(100) NOT NULL UNIQUE,                 -- URL-friendly version of the name (e.g., "technology-news")
    description TEXT                                   -- Optional longer description of the category
);

COMMENT ON TABLE Categories IS 'Stores different categories that blog posts can belong to.';
COMMENT ON COLUMN Categories.category_id IS 'Primary key: Unique identifier for each category.';
COMMENT ON COLUMN Categories.name IS 'Unique name of the category.';
COMMENT ON COLUMN Categories.slug IS 'URL-friendly unique identifier for the category.';
COMMENT ON COLUMN Categories.description IS 'Optional detailed description of the category.';


--
-- Table: Posts
-- Stores blog post content and metadata.
--
CREATE TABLE Posts (
    post_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Unique identifier for the post
    author_id UUID NOT NULL,                           -- Foreign key to Users table (the author of the post)
    category_id UUID,                                  -- Foreign key to Categories table (optional category)
    title VARCHAR(255) NOT NULL,                       -- Title of the blog post
    slug VARCHAR(255) NOT NULL UNIQUE,                 -- URL-friendly version of the title
    content TEXT NOT NULL,                             -- Full content of the blog post
    excerpt TEXT,                                      -- Short summary or preview of the post content
    status VARCHAR(20) DEFAULT 'draft' NOT NULL,       -- Current status of the post (e.g., 'draft', 'published', 'archived')
    publication_date TIMESTAMP WITH TIME ZONE,         -- Date and time when the post was published
    last_updated_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, -- Date and time of the last update
    CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES Users(user_id) ON DELETE RESTRICT, -- Prevent deleting a user if they have posts
    CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES Categories(category_id) ON DELETE SET NULL -- Set category to NULL if category is deleted
);

-- Add an index for faster lookups on common query fields
CREATE INDEX idx_posts_slug ON Posts (slug);
CREATE INDEX idx_posts_publication_date ON Posts (publication_date DESC);
CREATE INDEX idx_posts_author_id ON Posts (author_id);
CREATE INDEX idx_posts_category_id ON Posts (category_id);


COMMENT ON TABLE Posts IS 'Stores the main content and metadata for blog posts.';
COMMENT ON COLUMN Posts.post_id IS 'Primary key: Unique identifier for each post.';
COMMENT ON COLUMN Posts.author_id IS 'Foreign key to the Users table, identifying the author of the post.';
COMMENT ON COLUMN Posts.category_id IS 'Foreign key to the Categories table, identifying the category of the post (nullable).';
COMMENT ON COLUMN Posts.title IS 'Title of the blog post.';
COMMENT ON COLUMN Posts.slug IS 'URL-friendly unique identifier for the post.';
COMMENT ON COLUMN Posts.content IS 'Full HTML or Markdown content of the blog post.';
COMMENT ON COLUMN Posts.excerpt IS 'Short summary or preview of the post content.';
COMMENT ON COLUMN Posts.status IS 'Current publication status of the post (e.g., "draft", "published", "archived").';
COMMENT ON COLUMN Posts.publication_date IS 'Timestamp when the post was published.';
COMMENT ON COLUMN Posts.last_updated_date IS 'Timestamp when the post was last updated.';


--
-- Table: Tags
-- Stores tags for blog posts.
--
CREATE TABLE Tags (
    tag_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Unique identifier for the tag
    name VARCHAR(50) NOT NULL UNIQUE,                  -- Name of the tag (e.g., "SQL", "Frontend", "AI")
    slug VARCHAR(50) NOT NULL UNIQUE                   -- URL-friendly version of the tag name
);

COMMENT ON TABLE Tags IS 'Stores keywords or tags associated with blog posts.';
COMMENT ON COLUMN Tags.tag_id IS 'Primary key: Unique identifier for each tag.';
COMMENT ON COLUMN Tags.name IS 'Unique name of the tag.';
COMMENT ON COLUMN Tags.slug IS 'URL-friendly unique identifier for the tag.';


--
-- Table: PostTags
-- Junction table for many-to-many relationship between Posts and Tags.
--
CREATE TABLE PostTags (
    post_id UUID NOT NULL,                             -- Foreign key to Posts table
    tag_id UUID NOT NULL,                              -- Foreign key to Tags table
    PRIMARY KEY (post_id, tag_id),                     -- Composite primary key to ensure unique association
    CONSTRAINT fk_posttags_post FOREIGN KEY (post_id) REFERENCES Posts(post_id) ON DELETE CASCADE, -- Delete associations if post is deleted
    CONSTRAINT fk_posttags_tag FOREIGN KEY (tag_id) REFERENCES Tags(tag_id) ON DELETE CASCADE     -- Delete associations if tag is deleted
);

COMMENT ON TABLE PostTags IS 'Junction table to manage the many-to-many relationship between Posts and Tags.';
COMMENT ON COLUMN PostTags.post_id IS 'Foreign key to the Posts table.';
COMMENT ON COLUMN PostTags.tag_id IS 'Foreign key to the Tags table.';


--
-- Table: Comments
-- Stores comments made on blog posts.
--
CREATE TABLE Comments (
    comment_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- Unique identifier for the comment
    post_id UUID NOT NULL,                             -- Foreign key to Posts table (which post the comment belongs to)
    author_id UUID,                                    -- Foreign key to Users table (who made the comment, nullable for guests)
    parent_comment_id UUID,                            -- Self-referencing foreign key for nested comments
    content TEXT NOT NULL,                             -- The actual comment text
    publication_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, -- Date and time the comment was posted
    is_approved BOOLEAN DEFAULT FALSE,                 -- Flag for comment moderation
    CONSTRAINT fk_comment_post FOREIGN KEY (post_id) REFERENCES Posts(post_id) ON DELETE CASCADE, -- Delete comments if post is deleted
    CONSTRAINT fk_comment_author FOREIGN KEY (author_id) REFERENCES Users(user_id) ON DELETE SET NULL, -- Set author to NULL if user is deleted
    CONSTRAINT fk_comment_parent FOREIGN KEY (parent_comment_id) REFERENCES Comments(comment_id) ON DELETE CASCADE -- Delete child comments if parent is deleted
);

CREATE INDEX idx_comments_post_id ON Comments (post_id);
CREATE INDEX idx_comments_author_id ON Comments (author_id);
CREATE INDEX idx_comments_publication_date ON Comments (publication_date DESC);

COMMENT ON TABLE Comments IS 'Stores user comments made on blog posts.';
COMMENT ON COLUMN Comments.comment_id IS 'Primary key: Unique identifier for each comment.';
COMMENT ON COLUMN Comments.post_id IS 'Foreign key to the Posts table, linking the comment to a specific post.';
COMMENT ON COLUMN Comments.author_id IS 'Foreign key to the Users table, identifying the author of the comment (nullable for guest comments).';
COMMENT ON COLUMN Comments.parent_comment_id IS 'Self-referencing foreign key for nested comments, pointing to a parent comment.';
COMMENT ON COLUMN Comments.content IS 'The actual text content of the comment.';
COMMENT ON COLUMN Comments.publication_date IS 'Timestamp when the comment was posted.';
COMMENT ON COLUMN Comments.is_approved IS 'Boolean flag indicating if the comment has been approved by a moderator.';

-- End of SQL DDL Script
Sandboxed live preview

This document outlines a comprehensive and detailed study plan designed to equip an aspiring professional with the knowledge and skills required to excel as a Database Schema Designer. This plan is structured to provide a logical progression from foundational database concepts to advanced schema design principles, performance optimization, and modern database trends.


Database Schema Designer: Comprehensive Study Plan

1. Introduction & Role Overview

A Database Schema Designer is a critical role responsible for architecting the underlying structure of a database, ensuring data integrity, optimal performance, scalability, and security. This involves translating business requirements into a logical and physical database design, defining tables, relationships, data types, constraints, and indexing strategies. A well-designed schema is the backbone of any robust and efficient application.

This study plan provides a structured pathway to master these competencies, blending theoretical knowledge with practical application.

2. Learning Objectives

Upon successful completion of this study plan, the learner will be able to:

  • Understand Core Database Concepts: Articulate the fundamental principles of relational databases, data models, and the ACID properties of transactions.
  • Master SQL: Write complex SQL queries for data manipulation (DML) and data definition (DDL), including advanced joins, subqueries, views, and stored procedures.
  • Apply Normalization Principles: Design highly normalized relational schemas (up to BCNF) to eliminate data redundancy and ensure data integrity, and understand when to strategically denormalize for performance.
  • Create Effective ERDs: Develop comprehensive Entity-Relationship Diagrams (ERDs) to visually represent database structures, entities, attributes, and relationships with correct cardinality and optionality.
  • Optimize Database Performance: Implement effective indexing strategies, understand query execution plans, and identify common performance bottlenecks.
  • Ensure Data Security & Integrity: Design schemas with appropriate constraints, user roles, permissions, and consider basic security best practices.
  • Evaluate Database Technologies: Differentiate between various database management systems (RDBMS vs. NoSQL) and understand their respective strengths and weaknesses for different use cases.
  • Design Scalable Solutions: Understand concepts like partitioning, sharding, and replication to design databases that can handle growing data volumes and user loads.
  • Communicate & Document Designs: Clearly articulate and document database design decisions, including data dictionaries and ERD explanations, to technical and non-technical stakeholders.
  • Develop a Professional Portfolio: Showcase practical database design skills through a series of projects demonstrating real-world problem-solving.

3. Weekly Schedule

This 12-week study plan assumes approximately 15-20 hours of dedicated study per week, balancing theoretical learning with hands-on practice.

Week 1: Database Fundamentals & SQL Basics

  • Topics: Introduction to databases (RDBMS vs. NoSQL overview), database models, SQL syntax (SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING), basic data types, setting up a local DBMS (e.g., PostgreSQL or MySQL).
  • Practical: Install a DBMS, execute basic queries, create a simple table, insert data.

Week 2: Relational Concepts & Introduction to ERD

  • Topics: Keys (Primary, Foreign, Candidate, Super), relationships (1:1, 1:N, N:M), introduction to Entity-Relationship Diagrams (ERDs), entities, attributes, basic cardinality.
  • Practical: Design an ERD for a simple system (e.g., library), implement tables with basic relationships in SQL.

Week 3: Normalization Theory (1NF, 2NF, 3NF)

  • Topics: Understanding data redundancy, functional dependencies, First Normal Form (1NF), Second Normal Form (2NF), Third Normal Form (3NF).
  • Practical: Normalize a given denormalized dataset to 3NF, explain the steps.

Week 4: Advanced Normalization & Denormalization

  • Topics: Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF) (briefly), understanding when and why to denormalize a schema for performance.
  • Practical: Refine previous normalization exercises, identify scenarios for denormalization.

Week 5: Data Definition Language (DDL) & Constraints

  • Topics: CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, DROP INDEX, various constraints (NOT NULL, UNIQUE, CHECK, DEFAULT, Primary Key, Foreign Key).
  • Practical: Design and implement a schema for a medium-complexity system using all learned DDL commands and constraints.

Week 6: Advanced SQL & Database Objects

  • Topics: Subqueries, Common Table Expressions (CTEs), Views, Stored Procedures, Functions, Triggers, Transactions and ACID properties.
  • Practical: Write complex queries using subqueries/CTEs, create views and simple stored procedures.

Week 7: Indexing & Query Optimization

  • Topics: Types of indexes (B-tree, Hash), clustered vs. non-clustered indexes, when and why to use indexes, understanding query execution plans, basic performance tuning concepts.
  • Practical: Analyze query performance using EXPLAIN (or equivalent), add/remove indexes and observe impact.

Week 8: Database Security & Integrity

  • Topics: User management, roles, permissions (GRANT/REVOKE), data encryption (concepts), backup and recovery strategies (concepts), concurrency control.
  • Practical: Create users, assign roles, test permissions in your local DBMS.

Week 9: Data Warehousing & NoSQL Introduction

  • Topics: OLTP vs. OLAP, Star Schema, Snowflake Schema (basics), Introduction to NoSQL databases (Document, Key-Value, Column-Family, Graph) and their use cases, Polyglot Persistence.
  • Practical: Design a simple Star Schema, explore a NoSQL database (e.g., MongoDB) by creating a collection.

Week 10: Capstone Project - Part 1: Requirements & Logical Design

  • Topics: Choose a complex real-world application (e.g., e-commerce platform, social media feed, booking system). Gather detailed requirements relevant to database design.
  • Practical: Develop a comprehensive logical ERD for the chosen project, including all entities, attributes, relationships, cardinalities, and optionalities. Document design decisions.

Week 11: Capstone Project - Part 2: Physical Design & Implementation

  • Topics: Translate the logical ERD into a physical schema for a chosen RDBMS. Consider data types, indexing, constraints, and performance.
  • Practical: Implement the full schema in your chosen RDBMS, populate with realistic sample data, write complex queries to retrieve data.

Week 12: Review, Advanced Topics & Portfolio Building

  • Topics: Review all core concepts, explore advanced features of your chosen RDBMS, interview preparation for database design questions.
  • Practical: Refine your Capstone Project, create a compelling portfolio entry, practice explaining your design choices.

4. Recommended Resources

Books:

  • "Database System Concepts" by Abraham Silberschatz, Henry F. Korth, S. Sudarshan: A classic, comprehensive textbook for theoretical foundations.
  • "SQL Performance Explained" by Markus Winand: Excellent for understanding indexing and query optimization from a practical perspective.
  • "SQL Antipatterns: Avoiding the Pitfalls of Database Programming" by Bill Karwin: Learn common mistakes and how to avoid them in schema design and SQL.
  • "Refactoring Databases: Evolutionary Design" by Scott Ambler and Pramod Sadalage: Focuses on iterative database design and change management.

Online Courses & Tutorials:

  • Coursera/edX/Udemy: Search for "Database Design," "SQL for Data Science," "Relational Database Management Systems." Look for courses from reputable universities or industry experts.

Example:* "Database Design and Theory" (Coursera, University of Colorado Boulder), "Introduction to Databases" (edX, Stanford University).

  • Official Documentation:

* PostgreSQL Documentation: [www.postgresql.org/docs](https://www.postgresql.org/docs/)

* MySQL Documentation: [dev.mysql.com/doc](https://dev.mysql.com/doc/)

* SQL Server Documentation: [docs.microsoft.com/en-us/sql/](https://docs.microsoft.com/en-us/sql/)

  • W3Schools SQL Tutorial: [www.w3schools.com/sql/](https://www.w3schools.com/sql/) (Good for quick syntax reference)
  • SQLZoo: [sqlzoo.net](https://sqlzoo.net/) (Interactive SQL practice problems)

Tools:

  • DBMS: PostgreSQL, MySQL, SQLite (for lightweight local projects), SQL Server (Developer Edition).
  • ERD Tools:

* Lucidchart / draw.io (Diagrams.net): Cloud-based, user-friendly for creating professional ERDs.

* dbdiagram.io: Online tool to generate ERDs from SQL-like syntax.

* MySQL Workbench / pgAdmin: Often include built-in ERD design capabilities.

  • SQL Clients: DBeaver, DataGrip, Azure Data Studio, pgAdmin, MySQL Workbench.

Blogs & Communities:

  • Stack Overflow: For specific SQL and database design questions.
  • Database Administrators Stack Exchange: Dedicated community for DBAs and database professionals.
  • Blogs: Search for "database design best practices," "SQL performance tuning," "NoSQL vs RDBMS."

5. Milestones

Achieving these milestones will mark significant progress and demonstrate mastery of key concepts:

  • End of Week 2: Successfully installed a DBMS, executed all basic SQL DML commands, and designed a simple ERD for a 3-entity system.
  • End of Week 4: Fully normalized a complex, denormalized dataset to 3NF/BCNF and justified denormalization choices for specific scenarios.
  • End of Week 6: Created a database schema using DDL with appropriate constraints, views, and a basic stored procedure/function.
  • End of Week 7: Analyzed a query execution plan, identified a bottleneck, and optimized query performance using appropriate indexing.
  • End of Week 9: Articulated the differences between RDBMS and at least two types of NoSQL databases, explaining their respective use cases.
  • End of Week 11 (Capstone Project Completion): Designed, implemented, and populated a fully functional database schema for a complex real-world application, demonstrating logical and physical design skills.
  • End of Week 12 (Portfolio Ready): Created a portfolio entry showcasing the Capstone Project, including ERDs, schema definition, sample queries, and a design rationale.

6. Assessment Strategies

Continuous assessment is crucial for reinforcing learning and identifying areas for improvement.

  • Weekly Coding Challenges & Quizzes:

* SQL Practice: Use platforms like HackerRank, LeetCode, or SQLZoo for daily/weekly SQL coding challenges.

* Self-Quizzes: Create flashcards or use online quiz tools for definitions, normalization rules, and SQL syntax.

  • Mini-Projects & Design Exercises:

* ERD Design: Regularly practice designing ERDs for various scenarios (e.g., university system, hospital management, online store).

5. Code Explanation and Best Practices

This section elaborates on the design choices and best practices incorporated into the generated SQL DDL.

5.1. Table Structure and Naming Conventions

  • Plural Table Names: Tables are named in plural form (e.g., Users, Posts) which is a common convention in SQL schemas, representing a collection of entities.
  • Lowercase Snake_case for Columns: All column names are in lowercase snake_case (e.g., user_id, publication_date). This enhances readability and is a widely adopted standard.
  • UUID Primary Keys: We've utilized UUID (Universally Unique Identifier) for all primary keys (user_id, post_id, etc.).

* Benefits: UUIDs offer global uniqueness, which is excellent for distributed systems, merging databases, and preventing ID collisions. They also do not expose record counts.

* Implementation: DEFAULT gen_random_uuid() is used in PostgreSQL to automatically generate a UUID upon insertion. For MySQL, you'd use UUID() or a similar function/trigger.

  • CASCADE for DROP TABLE IF EXISTS: This ensures that if a table with foreign key dependencies is
gemini Output

Project Title: Database Schema Design & Documentation Report

Date: October 26, 2023

Prepared For: [Customer Name/Organization]

Prepared By: PantheraHive AI Team

Workflow Step: Database Schema Designer - Review & Document


1. Executive Summary

This report presents the comprehensive database schema design and accompanying documentation for your application. The schema has been meticulously crafted to ensure data integrity, optimal performance, scalability, and maintainability, aligning with modern database design principles and best practices. It provides a robust foundation for your application's data storage, supporting core functionalities and future growth. This document details the proposed tables, columns, relationships, and key design decisions, offering a clear blueprint for database implementation.

2. Introduction

The objective of this phase was to design a robust and efficient relational database schema that accurately models the entities and relationships critical to your application's operations. The design process involved understanding your functional requirements, data flow, and anticipated usage patterns. This document serves as a deliverable for the review_and_document step, providing a detailed breakdown of the proposed schema, its rationale, and essential documentation for development and maintenance teams.

3. Database Schema Overview

The proposed schema is designed around core business entities, establishing clear relationships between them. While a visual Entity-Relationship Diagram (ERD) would typically accompany this document, the following sections provide a textual description of the entities, their attributes, and interconnections, allowing for a comprehensive understanding of the database structure.

Key Design Principles Applied:

  • Normalization: Primarily structured to 3rd Normal Form (3NF) to minimize data redundancy and improve data integrity.
  • Clarity & Readability: Consistent naming conventions for tables, columns, and constraints.
  • Performance: Strategic indexing, appropriate data type selection, and consideration for query optimization.
  • Scalability: Design choices that facilitate future expansion and high data volumes.
  • Maintainability: Clear documentation and modular design for ease of understanding and modification.

4. Detailed Schema Design

This section provides a granular view of each proposed table, including its purpose, primary keys, foreign keys, unique constraints, and detailed column definitions.

4.1 Naming Conventions

To ensure consistency and clarity, the following naming conventions have been adopted:

  • Tables: Plural, PascalCase (e.g., Users, Products).
  • Columns: snake_case (e.g., user_id, product_name).
  • Primary Keys: id for the primary key column, table_name_id for foreign keys (e.g., user_id in Users table, user_id as FK in Orders table).
  • Foreign Keys: fk_source_table_target_table_id (e.g., fk_orders_users_user_id).
  • Indexes: idx_table_name_column_name(s).
  • Constraints: uq_table_name_column_name(s) for unique constraints.

4.2 Illustrative Table Definitions (Example: E-commerce Application)

Below are detailed definitions for a representative set of tables.

4.2.1 Table: Users

  • Purpose: Stores information about registered users of the application.
  • Primary Key: id
  • Unique Constraints: email
  • Indexes: idx_users_email (for fast lookup by email)
  • Columns:

* id (INT, NOT NULL, AUTO_INCREMENT, PRIMARY KEY) - Unique identifier for the user.

* first_name (VARCHAR(100), NOT NULL) - User's first name.

* last_name (VARCHAR(100), NOT NULL) - User's last name.

* email (VARCHAR(255), NOT NULL, UNIQUE) - User's unique email address, used for login.

* password_hash (VARCHAR(255), NOT NULL) - Hashed password for security.

* phone_number (VARCHAR(20), NULL) - User's contact phone number.

* address_line1 (VARCHAR(255), NULL) - User's primary address line 1.

* address_line2 (VARCHAR(255), NULL) - User's primary address line 2 (optional).

* city (VARCHAR(100), NULL) - City of the user's address.

* state (VARCHAR(100), NULL) - State/Province of the user's address.

* postal_code (VARCHAR(20), NULL) - Postal code of the user's address.

* country (VARCHAR(100), NULL) - Country of the user's address.

* created_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP) - Timestamp when the user record was created.

* updated_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) - Timestamp of the last update to the user record.

* is_active (BOOLEAN, NOT NULL, DEFAULT TRUE) - Flag indicating if the user account is active.

4.2.2 Table: Products

  • Purpose: Stores information about products available for purchase.
  • Primary Key: id
  • Unique Constraints: sku
  • Indexes: idx_products_sku, idx_products_name
  • Columns:

* id (INT, NOT NULL, AUTO_INCREMENT, PRIMARY KEY) - Unique identifier for the product.

* name (VARCHAR(255), NOT NULL) - Name of the product.

* sku (VARCHAR(50), NOT NULL, UNIQUE) - Stock Keeping Unit, unique identifier for product inventory.

* description (TEXT, NULL) - Detailed description of the product.

* price (DECIMAL(10, 2), NOT NULL) - Current selling price of the product.

* stock_quantity (INT, NOT NULL, DEFAULT 0) - Current quantity of product in stock.

* image_url (VARCHAR(255), NULL) - URL to the product's main image.

* category (VARCHAR(100), NULL) - Product category (e.g., "Electronics", "Books").

* brand (VARCHAR(100), NULL) - Product brand.

* weight (DECIMAL(10, 2), NULL) - Product weight for shipping calculations.

* created_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP) - Timestamp when the product record was created.

* updated_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) - Timestamp of the last update.

* is_available (BOOLEAN, NOT NULL, DEFAULT TRUE) - Flag indicating if the product is available for purchase.

4.2.3 Table: Orders

  • Purpose: Stores information about customer orders.
  • Primary Key: id
  • Foreign Keys: user_id (references Users.id)
  • Indexes: idx_orders_user_id, idx_orders_status, idx_orders_created_at
  • Columns:

* id (INT, NOT NULL, AUTO_INCREMENT, PRIMARY KEY) - Unique identifier for the order.

* user_id (INT, NOT NULL, FK to Users.id) - The user who placed the order.

* order_date (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP) - Date and time the order was placed.

* total_amount (DECIMAL(10, 2), NOT NULL) - Total monetary value of the order.

* status (VARCHAR(50), NOT NULL, DEFAULT 'Pending') - Current status of the order (e.g., 'Pending', 'Processing', 'Shipped', 'Delivered', 'Cancelled').

* shipping_address_line1 (VARCHAR(255), NOT NULL) - Shipping address line 1.

* shipping_address_line2 (VARCHAR(255), NULL) - Shipping address line 2 (optional).

* shipping_city (VARCHAR(100), NOT NULL) - Shipping city.

* shipping_state (VARCHAR(100), NOT NULL) - Shipping state/province.

* shipping_postal_code (VARCHAR(20), NOT NULL) - Shipping postal code.

* shipping_country (VARCHAR(100), NOT NULL) - Shipping country.

* payment_method (VARCHAR(50), NULL) - Method of payment (e.g., 'Credit Card', 'PayPal').

* payment_status (VARCHAR(50), NOT NULL, DEFAULT 'Pending') - Status of the payment (e.g., 'Pending', 'Paid', 'Refunded').

* shipped_date (DATETIME, NULL) - Date and time the order was shipped.

* delivered_date (DATETIME, NULL) - Date and time the order was delivered.

* updated_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) - Timestamp of the last update.

4.2.4 Table: OrderItems

  • Purpose: Stores individual items within an order.
  • Primary Key: id
  • Foreign Keys: order_id (references Orders.id), product_id (references Products.id)
  • Unique Constraints: order_id, product_id (ensures a product appears only once per order)
  • Indexes: idx_orderitems_order_id, idx_orderitems_product_id
  • Columns:

* id (INT, NOT NULL, AUTO_INCREMENT, PRIMARY KEY) - Unique identifier for the order item.

* order_id (INT, NOT NULL, FK to Orders.id) - The order this item belongs to.

* product_id (INT, NOT NULL, FK to Products.id) - The product being ordered.

* quantity (INT, NOT NULL) - Quantity of the product in this order item.

* unit_price (DECIMAL(10, 2), NOT NULL) - Price of the product at the time of order (to handle price changes).

subtotal (DECIMAL(10, 2), NOT NULL) - quantity unit_price.

* created_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP) - Timestamp when the order item record was created.

* updated_at (DATETIME, NOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) - Timestamp of the last update.

4.3 Relationships

The following key relationships are established:

  • Users to Orders: One-to-Many

* A User can place multiple Orders. Each Order belongs to exactly one User.

* Enforced by Orders.user_id referencing Users.id.

  • Orders to OrderItems: One-to-Many

* An Order can contain multiple OrderItems. Each OrderItem belongs to exactly one Order.

* Enforced by OrderItems.order_id referencing Orders.id.

  • Products to OrderItems: One-to-Many

* A Product can appear in multiple OrderItems (across different orders). Each OrderItem refers to exactly one Product.

* Enforced by OrderItems.product_id referencing Products.id.

4.4 Normalization Level

The schema is designed to adhere to the Third Normal Form (3NF).

  • 1NF: All attributes are atomic, and there are no repeating groups.
  • 2NF: It is in 1NF, and all non-key attributes are fully functionally dependent on the primary key.
  • 3NF: It is in
database_schema_designer.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' import './index.css' ReactDOM.createRoot(document.getElementById('root')!).render( ) "); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react' import './App.css' function App(){ return(

"+slugTitle(pn)+"

Built with PantheraHive BOS

) } export default App "); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e} .app{min-height:100vh;display:flex;flex-direction:column} .app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px} h1{font-size:2.5rem;font-weight:700} "); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` ## Open in IDE Open the project folder in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview" }, "dependencies": { "vue": "^3.5.13", "vue-router": "^4.4.5", "pinia": "^2.3.0", "axios": "^1.7.9" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", "typescript": "~5.7.3", "vite": "^6.0.5", "vue-tsc": "^2.2.0" } } '); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': resolve(__dirname,'src') } } }) "); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]} '); zip.file(folder+"tsconfig.app.json",'{ "compilerOptions":{ "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"], "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true, "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue", "strict":true,"paths":{"@/*":["./src/*"]} }, "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"] } '); zip.file(folder+"env.d.ts","/// "); zip.file(folder+"index.html"," "+slugTitle(pn)+"
"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue' import { createPinia } from 'pinia' import App from './App.vue' import './assets/main.css' const app = createApp(App) app.use(createPinia()) app.mount('#app') "); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue"," "); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547} "); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` Open in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test" }, "dependencies": { "@angular/animations": "^19.0.0", "@angular/common": "^19.0.0", "@angular/compiler": "^19.0.0", "@angular/core": "^19.0.0", "@angular/forms": "^19.0.0", "@angular/platform-browser": "^19.0.0", "@angular/platform-browser-dynamic": "^19.0.0", "@angular/router": "^19.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.0.0", "@angular/cli": "^19.0.0", "@angular/compiler-cli": "^19.0.0", "typescript": "~5.6.0" } } '); zip.file(folder+"angular.json",'{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "'+pn+'": { "projectType": "application", "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/'+pn+'", "index": "src/index.html", "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.css"], "scripts": [] } }, "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"} } } } } '); zip.file(folder+"tsconfig.json",'{ "compileOnSave": false, "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]}, "references":[{"path":"./tsconfig.app.json"}] } '); zip.file(folder+"tsconfig.app.json",'{ "extends":"./tsconfig.json", "compilerOptions":{"outDir":"./dist/out-tsc","types":[]}, "files":["src/main.ts"], "include":["src/**/*.d.ts"] } '); zip.file(folder+"src/index.html"," "+slugTitle(pn)+" "); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, appConfig) .catch(err => console.error(err)); "); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; } "); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = '"+pn+"'; } "); zip.file(folder+"src/app/app.component.html","

"+slugTitle(pn)+"

Built with PantheraHive BOS

"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1} "); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes) ] }; "); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router'; export const routes: Routes = []; "); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install ng serve # or: npm start ``` ## Build ```bash ng build ``` Open in VS Code with Angular Language Service extension. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local .angular/ "); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join(" "):"# add dependencies here "; zip.file(folder+"main.py",src||"# "+title+" # Generated by PantheraHive BOS print(title+" loaded") "); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Run ```bash python main.py ``` "); zip.file(folder+".gitignore",".venv/ __pycache__/ *.pyc .env .DS_Store "); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+" "; zip.file(folder+"package.json",pkgJson); var fallback="const express=require("express"); const app=express(); app.use(express.json()); app.get("/",(req,res)=>{ res.json({message:""+title+" API"}); }); const PORT=process.env.PORT||3000; app.listen(PORT,()=>console.log("Server on port "+PORT)); "; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000 "); zip.file(folder+".gitignore","node_modules/ .env .DS_Store "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash npm install ``` ## Run ```bash npm run dev ``` "); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:" "+title+" "+code+" "; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */ *{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e} "); zip.file(folder+"script.js","/* "+title+" — scripts */ "); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Open Double-click `index.html` in your browser. Or serve locally: ```bash npx serve . # or python3 -m http.server 3000 ``` "); zip.file(folder+".gitignore",".DS_Store node_modules/ .env "); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/**(.+?)**/g,"$1"); hc=hc.replace(/ {2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. Files: - "+app+".md (Markdown) - "+app+".html (styled HTML) "); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); }function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}