p_810020_tsql.app_car_sales

We are going to create a web APP, build with ONLY t-sql

You will be able to create this Web APP by only asking ONE question to the AI. Then you DROP the created script into "TSQL.APP" here:

near the end of this document we will add a second question to add an instant report to the app

Let's start:

Question to AI:

mssql; can you create schema code and sample data for the easiest car sales registration database application you can think of? It needs to have 10 car brands and car models and 10 customers in a costomer table. All tables may be simple and use an Auto-Incrementing Primary Key.

Reply from ChatGPT:

All right, I'll create a simplified schema for a car sales registration database application. Keep in mind, this is going to be basic.

Here's how we're going to structure it:

CarBrands Table: Holds information about different car brands. CarModels Table: Contains car models, each linked to a brand. Customers Table: Stores customer data. Sales Table: Records each sale, linking a customer to a car model. I'll give you SQL scripts for creating these tables and inserting some sample data. Remember, this is just a starting point. If you want a fully functional database for a real-world application, you'd need to put in more effort than this.

SQL Script for Creating Tables with Auto-Incrementing Primary Key

-- Create CarBrands Table
        CREATE TABLE CarBrands (
            BrandID INT PRIMARY KEY IDENTITY(1,1),
            BrandName VARCHAR(255)
        );
        
        -- Create CarModels Table
        CREATE TABLE CarModels (
            ModelID INT PRIMARY KEY IDENTITY(1,1),
            ModelName VARCHAR(255),
            BrandID INT,
            FOREIGN KEY (BrandID) REFERENCES CarBrands(BrandID)
        );
        
        -- Create Customers Table
        CREATE TABLE Customers (
            CustomerID INT PRIMARY KEY IDENTITY(1,1),
            CustomerName VARCHAR(255)
        );
        
        -- Create Sales Table
        CREATE TABLE Sales (
            SaleID INT PRIMARY KEY IDENTITY(1,1),
            CustomerID INT,
            ModelID INT,
            FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),
            FOREIGN KEY (ModelID) REFERENCES CarModels(ModelID)
        );
        

SQL Script for Inserting Sample Data


        
        -- Inserting data into CarBrands
        INSERT INTO CarBrands (BrandName) VALUES
        ('Ford'), ('Toyota'), ('Honda'),
        ('Chevrolet'), ('Nissan'), ('BMW'),
        ('Mercedes'), ('Audi'), ('Hyundai'), ('Kia');
        
        
        -- Inserting data into CarModels with dynamic lookup of BrandID
        INSERT INTO CarModels (ModelName, BrandID) VALUES
        ('Model A', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Ford')),
        ('Model B', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Toyota')),
        ('Model C', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Honda')),
        ('Model D', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Chevrolet')),
        ('Model E', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Nissan')),
        ('Model F', (SELECT BrandID FROM CarBrands WHERE BrandName = 'BMW')),
        ('Model G', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Mercedes')),
        ('Model H', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Audi')),
        ('Model I', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Hyundai')),
        ('Model J', (SELECT BrandID FROM CarBrands WHERE BrandName = 'Kia'));
        
        
        -- Inserting data into Customers
        INSERT INTO Customers (CustomerName) VALUES
        ('John Doe'), ('Jane Smith'), ('Alice Johnson'),
        ('Bob Williams'), ('Tom Brown'), ('Linda Davis'),
        ('Mike Wilson'), ('Sarah Miller'), ('Chris Taylor'), ('Patricia Anderson');
        
        -- Optionally, insert data into Sales when you have actual sales data
        

We feed the script to TSQL.APP

After "feeding" the script, the robots of TSQL.APP immediately create one CARD per database table into the Web APP. Then the cards get their default options, like Create, Retrieve, Update and Delete buttons as well as buttons to go to Related cards. Any other number of buttons can be added to enhance the cards with so called "actions", which are plain t-sql code to alter data or to engage user interaction.

The created cards are immediately visible in the [APICARD] meta-data table:

All 4 cards are pre-populated due to the provided script by the AI. So there are already Brands, Models ans Customer Names available.

Clicking button "Open Cardlist" opens the selected card: "Carbrands"

Car Brands has a relation to card: "Car Models"

Note that Nissan has "Bicycle_Green_AIR", which was not coming from the AI script; It was entered manually by clicking the card button: Insert. Clicking "Insert" on a card opens the card in a "Form View" modus, allowing the user to input data.

Adding an action to a card:

To add an action to a card is just as simple as adding data, because the whole TSQL.APP actually "is" data!

In this case I will let the AI generate the script code:

Question to AI:

I would like you to create tsql.app action code for a report that shows all CarBrands with their available CarModels. I would like to group by CarBrand and I want to be able to print it and export it to Excel.

Reply from ChatGPT:

Lets us click Script on the card: After clicking the "Script" button, a modal opens.

On the modal, click the button: "Action Script". A script entry form opens. Here you will:

After saving the script, the card: "Car Brands" will contain an action button called "my_first_report".

When you click your brand new button, it will display your first data report in your Web App:

Now you can choose to Print it to your local printer:

Or download it to Excel:

Conclusion:

With this TSQL.APP Framework, everyone can create exactly this kind of apps with zero programming if you use the AI Assistent coming with the framework.

By using the AI, this demo app can be realized in less than 5 minutes!

You have FULL control over the complete web application by writing t-sql code only!

Using the AI (currently) requires a subscription at openAI.org

You can subscribe for as little as $20 per month (20-12-2023). With this subscription **everyone can ask the GPT about TSQl.APP here: https://t-sql.app

If you are interrested in the TSQL.APP technology, you might like to check out our over 400 !! Stored Procedures that are part of our magnific framework TSQl.APP FRAMEWORK !!

Get your Virtual Private TSQL.APP MSSQL Database API, IDE and React Client and start building Amazing Solutions from only $99 per month !! Mail us via HELLO AT TSQL.APP