File size: 1,500 Bytes
a38e4b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import sqlite3

# Connect to the SQLite database
conn = sqlite3.connect("restaurant_reservation.db")
cursor = conn.cursor()

# Create tables if they do not exist
cursor.executescript("""

CREATE TABLE IF NOT EXISTS restaurants (

    id TEXT PRIMARY KEY,

    name TEXT NOT NULL,

    cuisine TEXT,

    location TEXT,

    seating_capacity INTEGER,

    rating REAL,

    address TEXT,

    contact TEXT,

    price_range TEXT,

    special_features TEXT

);



CREATE TABLE IF NOT EXISTS tables (

    id TEXT PRIMARY KEY,

    restaurant_id TEXT,

    capacity INTEGER DEFAULT 4,

    FOREIGN KEY (restaurant_id) REFERENCES restaurants(id)

);



CREATE TABLE IF NOT EXISTS slots (

    id TEXT PRIMARY KEY,

    table_id TEXT,

    date TEXT,

    hour INTEGER,

    is_reserved INTEGER DEFAULT 0,

    FOREIGN KEY (table_id) REFERENCES tables(id)

);



CREATE TABLE IF NOT EXISTS reservations (

    id TEXT PRIMARY KEY,

    restaurant_id TEXT,

    user_name TEXT,

    contact TEXT,

    date TEXT,

    time INTEGER,

    party_size INTEGER,

    FOREIGN KEY (restaurant_id) REFERENCES restaurants(id)

);



CREATE TABLE IF NOT EXISTS reservation_tables (

    id TEXT PRIMARY KEY,

    reservation_id TEXT,

    table_id TEXT,

    FOREIGN KEY (reservation_id) REFERENCES reservations(id),

    FOREIGN KEY (table_id) REFERENCES tables(id)

);

""")

# Commit the changes
conn.commit()

# Close the connection
conn.close()

print("Tables have been created successfully!")