MSQL Database
MSQL Database
MSQL Database
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> INSERT INTO Properties (address, type, size, price, status, owner_agent_id)
-> VALUES ('123 Main St', 'Residential', 2000.00, 500000.00, 'For Sale', 1);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
' 'For Sale', 1)' at line 2
mysql> INSERT INTO Properties (address, type, size, price, status, owner_agent_id)
-> VALUES
-> ('456 Elm St', 'Commercial', 3500.00, 850000.00, 'For Sale', 2),
-> ('789 Oak St', 'Residential', 1500.00, 300000.00, 'Sold', 1),
-> ('321 Pine St', 'Residential', 2500.00, 600000.00, 'For Rent', 3),
-> ('654 Maple Ave', 'Commercial', 4000.00, 950000.00, 'For Sale', 2),
-> ('987 Cedar Blvd', 'Residential', 1800.00, 450000.00, 'Under Contract',
1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`vbj`.`properties`, CONSTRAINT `properties_ibfk_1` FOREIGN KEY
(`owner_agent_id`) REFERENCES `agents` (`id`))
mysql> SELECT * FROM Agents;
Empty set (0.00 sec)
mysql> INSERT INTO Properties (address, type, size, price, status, owner_agent_id)
-> VALUES
-> ('123 Main St', 'Residential', 2000.00, 500000.00, 'For Sale', 1),
-> ('456 Elm St', 'Commercial', 3500.00, 850000.00, 'For Sale', 2),
-> ('789 Oak St', 'Residential', 1500.00, 300000.00, 'Sold', 1),
-> ('321 Pine St', 'Residential', 2500.00, 600000.00, 'For Rent', 3),
-> ('654 Maple Ave', 'Commercial', 4000.00, 950000.00, 'For Sale', 2);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql>
mysql> INSERT INTO Transactions (property_id, client_id, agent_id, sale_price,
date)
-> VALUES
-> (2, 1, 1, 300000.00, '2022-02-01'),
-> (1, 2, 2, 450000.00, '2022-03-01'),
-> (3, 3, 1, 600000.00, '2022-04-01');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`vbj`.`transactions`, CONSTRAINT `transactions_ibfk_1` FOREIGN KEY
(`property_id`) REFERENCES `properties` (`id`))
mysql> INSERT INTO Transactions (property_id, client_id, agent_id, sale_price,
date)
-> VALUES (1, 1, 1, 500000.00, '2022-01-01');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`vbj`.`transactions`, CONSTRAINT `transactions_ibfk_1` FOREIGN KEY
(`property_id`) REFERENCES `properties` (`id`))
mysql>
mysql> INSERT INTO Transactions (property_id, client_id, agent_id, sale_price,
date)
-> VALUES (1, 1, 1, 500000.00, '2022-01-01');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`vbj`.`transactions`, CONSTRAINT `transactions_ibfk_1` FOREIGN KEY
(`property_id`) REFERENCES `properties` (`id`))
mysql> SELECT * FROM Properties;
+----+---------------+-------------+---------+-----------+----------
+----------------+
| id | address | type | size | price | status |
owner_agent_id |
+----+---------------+-------------+---------+-----------+----------
+----------------+
| 6 | 123 Main St | Residential | 2000.00 | 500000.00 | For Sale |
1 |
| 7 | 456 Elm St | Commercial | 3500.00 | 850000.00 | For Sale |
2 |
| 8 | 789 Oak St | Residential | 1500.00 | 300000.00 | Sold |
1 |
| 9 | 321 Pine St | Residential | 2500.00 | 600000.00 | For Rent |
3 |
| 10 | 654 Maple Ave | Commercial | 4000.00 | 950000.00 | For Sale |
2 |
+----+---------------+-------------+---------+-----------+----------
+----------------+
5 rows in set (0.00 sec)
mysql> INSERT INTO Properties (address, type, size, price, status, owner_agent_id)
-> VALUES ('123 Main St', 'Residential', 2000.00, 500000.00, 'For Sale', 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Properties (address, type, size, price, status, owner_agent_id)
-> VALUES ('123 Main St', 'Residential', 2000.00, 500000.00, 'For Sale', 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO properties (id, adress, type, size, price, status)
-> VALUES (1, '123 Main St', 'Residential', 1500, 500000.00, 'Available');
ERROR 1054 (42S22): Unknown column 'adress' in 'field list'
mysql> INSERT INTO properties (id, address, type, size, price, status,
owner_agent_id)
-> VALUES (1, '123 Main St', 'Residential', 1500, 500000.00, 'Available', 1);
Query OK, 1 row affected (0.01 sec)
mysql>