Prompt to add comments and normalize your script schema like the example.

#5
by rvian - opened

I tested Google Bard in normalizing the script to match the model example.
Edit the prompt to your need.

Prompt:
"
Giving the following sql database create table scripts, add a small comment that describe the meaning of each column, consider that the column names are in PT-BR but the comments should be in english. The scripts represent the database schema of a Profit and Loss datawarehouse in starschema model.

Input Example:
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(50),
price DECIMAL(10,2),
quantity INTEGER
);

Here is a expected response example:

CREATE TABLE products (
product_id INTEGER PRIMARY KEY, -- Unique ID for each product
name VARCHAR(50), -- Name of the product
price DECIMAL(10,2), -- Price of each unit of the product
quantity INTEGER -- Current quantity in stock
);

The response should contain only the original script with the column description besides the column declaration on the script.
"

After sending this first instruction, paste your sql script and the LLM should return the script with briefly comments.

add this to retrieve the relationships using the column name:

"
Give the relationship between tables like the example bellow. Maintain the same pattern "table_name.column_name can be joined to table_name.column.name:

OUTPUT EXPECTED (do not use this in the output, use for reference only):
-- sales.product_id can be joined with products.product_id
-- sales.customer_id can be joined with customers.customer_id
-- sales.salesperson_id can be joined with salespeople.salesperson_id
-- product_suppliers.product_id can be joined with products.product_id

Use the column name to identify foreign keys. The column that matchs the name from another table is considered a relationship.
"

Sign up or log in to comment