Skip to content

Commit

Permalink
create tables housy database #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ElhamFadel committed Oct 25, 2021
1 parent 0b3fdac commit 053aedd
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions server/database/config/bulid.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
BEGIN;
DROP TABLE IF EXISTS admins,estates,agents,images;
CREATE TABLE admins(
id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE agents(
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE,
phone VARCHAR(255) NOT NULL UNIQUE,
image TEXT,
location VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
);
CREATE TABLE estates(
id SERIAL PRIMARY KEY,
agent_id INTEGER REFERENCES agents(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
price DECIMAL NOT NULL,
description TEXT NOT NULL,
type VARCHAR(255) NOT NULL,
category VARCHAR(255) NOT NULL,
street VARCHAR(255) NOT NULL,
city VARCHAR(255) NOT NULL,
region VARCHAR(255) NOT NULL,
bathrooms INTEGER DEFAULT 0,
bedrooms INTEGER DEFAULT 0,
rooms INTEGER DEFAULT 0,
space DECIMAL NOT NULL ,
approved BOOLEAN DEFAULT FALSE,
rate INTEGER DEFAULT 0,
available BOOLEAN DEFAULT TRUE
);

CREATE TABLE images(
id SERIAL PRIMARY KEY,
estate_id INTEGER REFERENCES estates(id) ON DELETE CASCADE,
image TEXT
);
COMMIT;

0 comments on commit 053aedd

Please sign in to comment.