SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE "item" ( "item_id" uuid PRIMARY KEY DEFAULT (uuid_generate_v4()), "name" text NOT NULL, "image" text NOT NULL, "description" text NOT NULL ); CREATE TABLE "profile" ( "profile_id" uuid PRIMARY KEY DEFAULT (uuid_generate_v4()), "name" text NOT NULL, "total_points" bigint NOT NULL DEFAULT 0 ); CREATE TABLE "auction" ( "auction_id" uuid PRIMARY KEY DEFAULT (uuid_generate_v4()), "item_id" uuid NOT NULL, "unit_price" bigint NOT NULL, "created_at" timestamp NOT NULL DEFAULT (now() at time zone 'utc'), "quantity" bigint NOT NULL, "is_completed" boolean NOT NULL DEFAULT (false) ); CREATE TABLE "bid" ( "bid_id" uuid PRIMARY KEY DEFAULT (uuid_generate_v4()), "profile_id" uuid NOT NULL, "auction_id" uuid NOT NULL, "bid_price" bigint NOT NULL, "created_at" timestamp NOT NULL DEFAULT (now() at time zone 'utc'), "is_winning_bid" boolean NOT NULL DEFAULT (false) ); ALTER TABLE "auction" ADD FOREIGN KEY ("item_id") REFERENCES "item" ("item_id"); ALTER TABLE "bid" ADD FOREIGN KEY ("profile_id") REFERENCES "profile" ("profile_id"); ALTER TABLE "bid" ADD FOREIGN KEY ("auction_id") REFERENCES "auction" ("auction_id"); INSERT INTO item VALUES ( 'ce753590-d3c2-4355-a4db-728dd640fe91', 'Special Coin', 'https://i.pinimg.com/736x/a4/b2/1a/a4b21a6dc0bed9447b45b4f98214917c--bullion-coins-silver-bullion.jpg', 'Limited collection of special coin' ); INSERT INTO item VALUES ( '7f53d8f9-425c-4238-857a-34eb53e7c580', 'Teddy Bear', 'https://nationaltoday.com/wp-content/uploads/2021/08/Teddy-Bear-Day-640x514.jpg', 'An amazing collection of a bear' ); INSERT INTO item VALUES ( '77910083-2e84-4ef5-a57f-9d886a9a9fd2', 'Rolex Submariner Oyster Watch', 'https://www.thewatchmart.in/wp-content/uploads/2021/07/Rolex-Submariner-Blue-Dial-Stainless-Steel-and-18K-Yellow-Gold-Oyster-Watch-116613BLSO_3c30285b-b494-4f2d-aa83-5883e7b5214b-1024x1024.jpg', 'Very small collection of exclusive Rolex' ); INSERT INTO auction (item_id, unit_price, quantity) VALUES ( 'ce753590-d3c2-4355-a4db-728dd640fe91', 2000, 4 ); INSERT INTO auction (item_id, unit_price, quantity) VALUES ( '77910083-2e84-4ef5-a57f-9d886a9a9fd2', 1000, 5 ); INSERT INTO auction (item_id, unit_price, quantity) VALUES ( '7f53d8f9-425c-4238-857a-34eb53e7c580', 5000, 5 );
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear