Relationships Database designer are disabled

eliteel5

Member
Messages
63
Reaction score
1
Points
8
HI all , hope all well

Ive hit an issue this morning regarding db design Time UK 00:20hrs , Yep I do work some very long hours Strange as that may seem not to mention study and researching

Working on my local server I can create a relation database as you would normally comprising 3 tables , master table with two child tables with one to one relationship and one to many

How ever for some reason after setting up a procedure which should make this all easy , then on opening designer for the layout and plan of this using phpmyadmin on x10 then I have these issues below

1: Unable to see any relations btw tables
2: Unable to create relations btw tables

As such Im uploading code which for you to inspect hoping that some one can explain why that might be

I am also attaching image created from personal webserver running phpmyadmin using mariadb
Please see attached so that others can see the relationship diagram created as per code below



SQL:
DELIMITER $$
-- These tables are to be added to the eliteel5_PowerReadingsDB
CREATE PROCEDURE CreateOfficeAndPowerTables()
BEGIN
    -- Create Offices table (Parent)
    IF NOT EXISTS (
        SELECT * FROM information_schema.TABLES
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'Offices'
    ) THEN
        CREATE TABLE Offices (
            Office_ID VARCHAR(10) PRIMARY KEY ,
            Salutation ENUM('MR', 'MRS', 'MISS') NOT NULL,
            Name VARCHAR(10) NOT NULL,
            Surname VARCHAR(20) NOT NULL,
            Site_Name VARCHAR(20),
            Office_Number VARCHAR(10),
            Street VARCHAR(20),
            Town VARCHAR(20),
            County VARCHAR(20),
            Postcode VARCHAR(20),
            Email VARCHAR(50),
            Date_Registered DATE ,
            Contact_Number VARCHAR(20),
            Notes TEXT,
            Status ENUM('Active', 'Inactive') DEFAULT 'Active'
        );
    END IF;

    -- Create PowerReadings table (Child)
    IF NOT EXISTS (
        SELECT * FROM information_schema.TABLES
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'PowerReadings'
    ) THEN
        CREATE TABLE PowerReadings (
            Reading_ID INT PRIMARY KEY AUTO_INCREMENT,
            Office_ID VARCHAR(10) NOT NULL,
            Date_Of_Reading DATE,
            Time_Of_Reading TIME,
            Network_Baud_Rate INT,
            Total_system_power_demand DECIMAL(10,2),
            Maximum_total_system_power_demand DECIMAL(10,2),
            Current_system_positive_power_demand DECIMAL(10,2),
            Maximum_system_positive_power_demand DECIMAL(10,2),
            Current_system_reverse_power_demand DECIMAL(10,2),
            Maximum_system_reverse_power_demand DECIMAL(10,2),
            Current_demand DECIMAL(10,2),
            Voltage DECIMAL(10,2),
            Current DECIMAL(10,2),
            Active_Power DECIMAL(10,2),
            Apparent_Power DECIMAL(10,2),
            Reactive_Power DECIMAL(10,2),
            Power_Factor DECIMAL(5,2),
            Phase_Angle DECIMAL(5,2),
            Frequency DECIMAL(6,3),
            Import_Active_Energy DECIMAL(12,2),
            Export_Active_Energy DECIMAL(12,2),
            Import_Reactive_Energy DECIMAL(12,2),
            Maximum_current_Demand DECIMAL(10,2),
            Export_Reactive_Energy DECIMAL(12,2),
            Total_Active_Energy DECIMAL(12,2),
            Total_Reactive_Energy DECIMAL(12,2),
            FOREIGN KEY (Office_ID) REFERENCES Offices(Office_ID)
                ON DELETE CASCADE
                ON UPDATE CASCADE
        );
    END IF;




    -- Create PiDevices table with one-to-one Office_ID link
    IF NOT EXISTS (
        SELECT * FROM information_schema.TABLES
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'PiDevices'
    ) THEN
        CREATE TABLE PiDevices (
            Pi_ID INT PRIMARY KEY AUTO_INCREMENT,
            Office_ID VARCHAR(10) UNIQUE,
            CPU_Number VARCHAR(64),
            Machine_ID VARCHAR(64),
            Boot_ID VARCHAR(64),
            Operating_System VARCHAR(100),
            MAC_Address VARCHAR(20),
            IP_Address VARCHAR(45),
            Date_Installed DATE ,
            Date_Changed DATE ,
            Licensed ENUM('Yes', 'No') DEFAULT 'No',
            FOREIGN KEY (Office_ID) REFERENCES Offices(Office_ID)
                ON DELETE CASCADE
                ON UPDATE CASCADE
        );
    END IF;

END $$

DELIMITER ;
 

Attachments

  • DBDesign.jpg
    DBDesign.jpg
    98 KB · Views: 3
Last edited:

mrburnsx

Community Advocate
Community Support
Messages
717
Reaction score
70
Points
28
I believe relations is disabled on free hosting. Theres a chance your code may be wrong

 

eliteel5

Member
Messages
63
Reaction score
1
Points
8
What Ive done is re written my code for the database which is as follows just in case
Then double checked on my own server so it does look as though this has been disabled

Is this just a limitation on free accounts and could there be any possibility or having this enabled as when designing any relational database then this becomes quite important

Thanking you for prompt reply and answers

Code:
DELIMITER $$

CREATE PROCEDURE CreateOfficeAndPowerTables()
BEGIN
    -- ================================
    -- Create Offices table (Parent)
    -- ================================
    CREATE TABLE IF NOT EXISTS Offices (
        Office_ID VARCHAR(10) PRIMARY KEY,
        Salutation ENUM('MR', 'MRS', 'MISS') DEFAULT NULL,
        Name VARCHAR(10) DEFAULT NULL,
        Surname VARCHAR(20) DEFAULT NULL,
        Site_Name VARCHAR(20),
        Office_Number VARCHAR(10),
        Street VARCHAR(20),
        Town VARCHAR(20),
        County VARCHAR(20),
        Postcode VARCHAR(20),
        Email VARCHAR(50),
        Date_Registered DATE,
        Contact_Number VARCHAR(20),
        Notes TEXT,
        Status ENUM('Active', 'Inactive') DEFAULT 'Active'
    );

    -- ================================
    -- Create PowerReadings table (Live snapshot per office)
    -- ================================
    CREATE TABLE IF NOT EXISTS PowerReadings (
        Office_ID VARCHAR(10) PRIMARY KEY,  -- Enforce one row per office
        Last_Updated DATETIME,
        Network_Baud_Rate INT,
        Total_system_power_demand DECIMAL(10,2),
        Maximum_total_system_power_demand DECIMAL(10,2),
        Current_system_positive_power_demand DECIMAL(10,2),
        Maximum_system_positive_power_demand DECIMAL(10,2),
        Current_system_reverse_power_demand DECIMAL(10,2),
        Maximum_system_reverse_power_demand DECIMAL(10,2),
        Current_demand DECIMAL(10,2),
        Voltage DECIMAL(10,2),
        Current DECIMAL(10,2),
        Active_Power DECIMAL(10,2),
        Apparent_Power DECIMAL(10,2),
        Reactive_Power DECIMAL(10,2),
        Power_Factor DECIMAL(5,2),
        Phase_Angle DECIMAL(5,2),
        Frequency DECIMAL(6,3),
        Import_Active_Energy DECIMAL(12,2),
        Export_Active_Energy DECIMAL(12,2),
        Import_Reactive_Energy DECIMAL(12,2),
        Maximum_current_Demand DECIMAL(10,2),
        Export_Reactive_Energy DECIMAL(12,2),
        Total_Active_Energy DECIMAL(12,2),
        Total_Reactive_Energy DECIMAL(12,2),

        CONSTRAINT fk_power_office FOREIGN KEY (Office_ID)
            REFERENCES Offices(Office_ID)
            ON DELETE CASCADE
            ON UPDATE CASCADE
    );

    -- ================================
    -- Create PiDevices table (One-to-one with Offices)
    -- ================================
    CREATE TABLE IF NOT EXISTS PiDevices (
        Pi_ID INT PRIMARY KEY AUTO_INCREMENT,
        Office_ID VARCHAR(10) UNIQUE,  -- One-to-one relationship
        CPU_Number VARCHAR(64),
        Machine_ID VARCHAR(64),
        Boot_ID VARCHAR(64),
        Operating_System VARCHAR(100),
        MAC_Address VARCHAR(20),
        IP_Address VARCHAR(45),
        Date_Installed DATE,
        Date_Changed DATE,
        Licensed ENUM('Yes', 'No') DEFAULT 'No',

        CONSTRAINT fk_pi_office FOREIGN KEY (Office_ID)
            REFERENCES Offices(Office_ID)
            ON DELETE CASCADE
            ON UPDATE CASCADE
    );
END$$

DELIMITER ;



Next I tested locally and on your server

Here are the results in attached image Its been disabled
 

Attachments

  • Screenshot_20250801_204456.png
    Screenshot_20250801_204456.png
    322.6 KB · Views: 2
  • Screenshot_20250801_204835.png
    Screenshot_20250801_204835.png
    313.3 KB · Views: 2
Top