diff --git a/.env b/.env index 6b111ae9d..a03f8c5bd 100644 --- a/.env +++ b/.env @@ -14,8 +14,8 @@ LOCAL_DB_USER='postgres' LOCAL_DB_PASSWORD='postgres' ##### Heroku database ###### -DB_HOST= -DB_NAME= -DB_USER= -DB_PORT= -DB_PASSWORD= +DB_HOST=ec2-3-225-213-67.compute-1.amazonaws.com +DB_NAME=dcafujsnfvh3vf +DB_USER=gxhdxwiypuoagw +DB_PORT=5432 +DB_PASSWORD=7ca86887b1a9c84830bc056af1655ef2d61c199484e0c7a5e6f227b126d74f1f diff --git a/AppStore/settings.py b/AppStore/settings.py index e7500a271..489905cac 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -150,3 +150,6 @@ STATIC_URL = '/static/' django_heroku.settings(locals()) +import app.views +LOGIN_REDIRECT_URL = '/' +LOGOUT_REDIRECT_URL = "/" \ No newline at end of file diff --git a/AppStore/urls.py b/AppStore/urls.py index 5355daa5c..671aae83a 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -14,11 +14,39 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin +#from django.contrib.auth import views as auth_views +#from django.urls import include from django.urls import path import app.views +urlpatterns = [ + path('admin/', admin.site.urls), + path('', app.views.home, name='home'), + path('register/', app.views.register, name='register'), + path('profile/', app.views.profile, name='profile'), + path('login/', app.views.signin, name='login'), + path('view/', app.views.view, name='view') +] +""" +urlpatterns = [ + path('admin/', admin.site.urls), + path('', app.views.index_products, name='products'), + #path("accounts/", include("django.contrib.auth.urls")), + #path("accounts/login/", auth_views.login().as_view, name='login'), + #path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), + #path('', app.views.index, name='index'), + path('add/', app.views.add, name='add'), + #path('buy/', app.views.buy, name='buy'), + path('view/', app.views.view, name='view'), + path('edit/', app.views.edit, name='edit'), + path('login/', app.views.login, name='login'), + path('purchase/', app.views.purchase, name='purchase'), +] +""" + +""" urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index, name='index'), @@ -26,3 +54,4 @@ path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), ] +""" diff --git a/add_sql.sh b/add_sql.sh index 2304183ff..4022f7ca9 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -28,8 +28,9 @@ done < ".env" URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" # Run the scripts to insert data. -psql ${URI} -f sql/AppStoreClean.sql -psql ${URI} -f sql/AppStoreSchema.sql -psql ${URI} -f sql/AppStoreCustomers.sql -psql ${URI} -f sql/AppStoreGames.sql -psql ${URI} -f sql/AppStoreDownloads.sql +psql ${URI} -f sql/clean.sql +psql ${URI} -f sql/appschema.sql +psql ${URI} -f sql/allusersdata.sql +psql ${URI} -f sql/products.sql +psql ${URI} -f sql/transdata.sql + diff --git a/app/admin.py b/app/admin.py index 8c38f3f3d..0b1c4ae31 100644 --- a/app/admin.py +++ b/app/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin +from django.contrib.auth.models import User # Register your models here. + +class PersonAdmin(admin.ModelAdmin): + list_display = ('username', 'phoneno', 'password1') diff --git a/app/forms.py b/app/forms.py new file mode 100644 index 000000000..58135578a --- /dev/null +++ b/app/forms.py @@ -0,0 +1,20 @@ +from django import forms +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.models import User + + +# Create your forms here. + +class NewUserForm(UserCreationForm): + phoneno = forms.IntegerField(required=True) + + class Meta: + model = User + fields = ("username", "phoneno", "password1", "password2") + + def save(self, commit=True): + user = super(NewUserForm, self).save(commit=False) + user.phoneno = self.cleaned_data['phoneno'] + if commit: + user.save() + return user diff --git a/app/models.py b/app/models.py index e69de29bb..8b1378917 100644 --- a/app/models.py +++ b/app/models.py @@ -0,0 +1 @@ + diff --git a/app/static/app/images/images.png b/app/static/app/images/images.png new file mode 100644 index 000000000..c49a0e5fb Binary files /dev/null and b/app/static/app/images/images.png differ diff --git a/app/templates/app/add.html b/app/templates/app/add.html deleted file mode 100644 index 6000dfbf2..000000000 --- a/app/templates/app/add.html +++ /dev/null @@ -1,26 +0,0 @@ - - -

Add New Customer

- Back to home - -

{{ status|safe }}

- -
- - {% csrf_token %} - -
- -
- -
- - - diff --git a/app/templates/app/edit.html b/app/templates/app/edit_admin.html similarity index 100% rename from app/templates/app/edit.html rename to app/templates/app/edit_admin.html diff --git a/app/templates/app/home.html b/app/templates/app/home.html new file mode 100644 index 000000000..4500f0483 --- /dev/null +++ b/app/templates/app/home.html @@ -0,0 +1,35 @@ +{% load static %} + + + +

Product Listing

+ Register + Login +

+ + + + + + + + + {% for product in products %} + + + + + + + + + + {% endfor %} +
Product IDNamePriceMinimum Order Category
{{ product.0 }} {{ product.2 }} {{ product.4 }} {{ product.7 }} {{ product.5 }} + +
+ {% csrf_token %} + +
+ + diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html new file mode 100644 index 000000000..3cd5ab4c8 --- /dev/null +++ b/app/templates/app/index_products.html @@ -0,0 +1,37 @@ +{% load static %} + + + + Products Listing + + + App Logo
+

The Makan Network

+ Register +
+ Login +

+ + + + + + + + + {% for product in products %} + + + + + + + + + + {% endfor %} +
IDProduct NameDescriptionPriceCategory
{{ product.0 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} + +
+ + diff --git a/app/templates/app/index.html b/app/templates/app/index_user_admin.html similarity index 96% rename from app/templates/app/index.html rename to app/templates/app/index_user_admin.html index e32368db1..5130fde8a 100644 --- a/app/templates/app/index.html +++ b/app/templates/app/index_user_admin.html @@ -3,7 +3,7 @@

Customers in the App Store

NUS logo
- New customer + New User

diff --git a/app/templates/app/login.html b/app/templates/app/login.html new file mode 100644 index 000000000..90426980a --- /dev/null +++ b/app/templates/app/login.html @@ -0,0 +1,217 @@ + + + + + + + +

Login

+ + + {% csrf_token %} + +
+ + + + + + + +
+ + + + + +
+ {% for message in messages %} +

{{message}}

+ {% endfor %} +
+ + + + + + + + +{% load static %} + + + + + Login + App Logo
+ + + + + +
+
+

Login

+
+
+ +
+
+
+ +
+
+ + +
+ Back to home +
+ Register + + + + + + diff --git a/app/templates/app/profile.html b/app/templates/app/profile.html new file mode 100644 index 000000000..6dae46988 --- /dev/null +++ b/app/templates/app/profile.html @@ -0,0 +1,14 @@ + + + + + Profile + + + App Logo
+

The Makan Network

+
+ Logout + + + \ No newline at end of file diff --git a/app/templates/app/purchase.html b/app/templates/app/purchase.html new file mode 100644 index 000000000..277ddd1f1 --- /dev/null +++ b/app/templates/app/purchase.html @@ -0,0 +1,45 @@ + + + + Purchase + + +
+ + + + + + + + + + + {% for product in products %} + + + + + + + + + + + + {% endfor %} +
IDSellerProduct NameDescriptionPriceCategoryAllergen NoticeMinimum Order Required
{{ product.0 }} {{ product.1 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} {{ product.6 }} {{ product.7 }} +

{{ status|safe }}

+ +
+ + {% csrf_token %} + +
+
+
+
+ + + diff --git a/app/templates/app/register.html b/app/templates/app/register.html new file mode 100644 index 000000000..8face32b2 --- /dev/null +++ b/app/templates/app/register.html @@ -0,0 +1,72 @@ + + + + + + + +

Registration Form

+ +
+ {% csrf_token %} + +
+ + + + + + + + + + + + + +
+ + +
+
+ {% for message in messages %} +

{{message}}

+ {% endfor %} +
+ + + + + + + + + + + Register + + + +

New User

+ Back to home + +

{{ status|safe }}

+ + + + + + diff --git a/app/templates/app/styleforlogin.css b/app/templates/app/styleforlogin.css new file mode 100644 index 000000000..841424646 --- /dev/null +++ b/app/templates/app/styleforlogin.css @@ -0,0 +1,71 @@ +body +{ + --color-primary: #009579; + --color-primary-dark: #007f67; + --color-secondary: #252c6a; + --color-error: #cc3333; + --color-success: #4bb544; + --border-radius: 4px; + + margin: 0; + height: 100vh; + display: flex; + align-items: center; + justify-items:center; + font-size: 18px; + background: url("https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.lifestyleasia.com%2Fsg%2Fliving%2Fpeople%2Fhome-based-business-singapore-circuit-breaker%2F&psig=AOvVaw1nyiQlqxU5c5Zw28vR7zZA&ust=1648299378967000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCIj0uOun4fYCFQAAAAAdAAAAABAJ"); + background-size: cover; +} + +.login{ + width: 382px; + overflow: hidden; + margin: auto; + margin: 20 0 0 450px; + padding: 80px; + background: #23463f; + border-radius: 15px ; + +} +h2{ + text-align: center; + color: #277582; + padding: 20px; +} +label{ + color: #08ffd1; + font-size: 17px; +} +#Uname{ + width: 300px; + height: 30px; + border: none; + border-radius: 3px; + padding-left: 8px; +} +#Pass{ + width: 300px; + height: 30px; + border: none; + border-radius: 3px; + padding-left: 8px; + +} +#log{ + width: 300px; + height: 30px; + border: none; + border-radius: 17px; + padding-left: 7px; + color: blue; + + +} +span{ + color: white; + font-size: 17px; +} +a{ + float: right; + background-color: grey; +} diff --git a/app/templates/app/view.html b/app/templates/app/view.html index 96a8df2b3..6b265f7d8 100644 --- a/app/templates/app/view.html +++ b/app/templates/app/view.html @@ -1,44 +1,39 @@ -

Details for {{cust.0}} {{cust.1}}

+

Details for {{cust.0}} {{cust.2}}

Back to home

- - - - - - + - + - + - + - + - + - + - + - + - +
ID: {{ cust.5 }}
First nameProduct ID : {{ cust.0 }}
Last nameCategory : {{ cust.1 }} {{ cust.5 }}
EmailPrice : {{ cust.2 }} {{ cust.4 }}
Date of birthDescription : {{ cust.3 }}
SinceAllergens : {{ cust.4 }} {{ cust.6 }}
CountryMinimum Order : {{ cust.6 }} {{ cust.7 }}
- \ No newline at end of file + diff --git a/app/templates/app/view_admin.html b/app/templates/app/view_admin.html new file mode 100644 index 000000000..96a8df2b3 --- /dev/null +++ b/app/templates/app/view_admin.html @@ -0,0 +1,44 @@ + + +

Details for {{cust.0}} {{cust.1}}

+ Back to home +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID: {{ cust.5 }}
First name: {{ cust.0 }}
Last name: {{ cust.1 }}
Email: {{ cust.2 }}
Date of birth: {{ cust.3 }}
Since: {{ cust.4 }}
Country: {{ cust.6 }}
+ + \ No newline at end of file diff --git a/app/views.py b/app/views.py index fba8722bc..1c394714e 100644 --- a/app/views.py +++ b/app/views.py @@ -1,9 +1,108 @@ from django.shortcuts import render, redirect from django.db import connection +from django.contrib.auth import login, authenticate +from django.contrib import messages +from django.contrib.auth.forms import AuthenticationForm +from .forms import NewUserForm + +def home(request): + """Shows the product listing page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM products ORDER BY productid") + products = cursor.fetchall() + + result_dict = {'products': products} + + return render(request, 'app/home.html', result_dict) + + # Create your views here. -def index(request): +def register(request): + """Shows the main page""" + context = {} + status = '' + + if request.POST: + form = NewUserForm(request.POST) + ## Check if userid is already in the table + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM allusers WHERE userid = %s", [request.POST['username']]) + user = cursor.fetchone() + ## No customer with same id + if user == None: + ##TODO: date validation + cursor.execute("INSERT INTO allusers(userid, phoneno, password) VALUES (%s, %s, %s)" + , [request.POST['username'], request.POST['phoneno'], request.POST['password1'] ]) + newuser = form.save() + login(request, newuser) + messages.success(request, 'Registration successful.') + return redirect('/') + else: + status = 'User with ID %s already exists' % (request.POST['username']) + + form = NewUserForm() + context['status'] = status + + return render(request, "app/register.html", context) + +def signin(request): + """Shows the login page""" + context = {} + status = '' + + if request.POST: + form = AuthenticationForm(request, data=request.POST) + if form.is_valid(): + username = form.cleaned_data.get('username') + password = form.cleaned_data.get('password1') + user = authenticate(username=username, password1=password1) + if user is not None: + login(request, user) + messages.info(request, f'You are now logged in as {username}.') + return redirect('app/') + else: + messages.error(request,'Invalid username or password.') + else: + status = 'Invalid username or password.' + form = AuthenticationForm() + context['status'] = status + return render(request, 'app/login.html', context) + + +def profile(request, id): + """Shows the main page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM allusers WHERE userid = %s",[id]) + user = cursor.fetchone() + + result_dict = {'users': users} + + return render(request, 'app/profile.html', result_dict) + + +def view(request, id): """Shows the main page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM products WHERE productid = %s", [id]) + customer = cursor.fetchone() + result_dict = {'cust': customer} + + return render(request,'app/view.html',result_dict) + + + +""" +# Create your views here. +def index(request): + ## Delete customer if request.POST: @@ -18,11 +117,11 @@ def index(request): result_dict = {'records': customers} - return render(request,'app/index.html',result_dict) + return render(request, 'app/index_user_admin.html', result_dict) # Create your views here. def view(request, id): - """Shows the main page""" + ## Use raw query to get a customer with connection.cursor() as cursor: @@ -30,38 +129,38 @@ def view(request, id): customer = cursor.fetchone() result_dict = {'cust': customer} - return render(request,'app/view.html',result_dict) + return render(request, 'app/view_admin.html', result_dict) # Create your views here. def add(request): - """Shows the main page""" + context = {} status = '' + if request.POST: - ## Check if customerid is already in the table + ## Check if phoneno is already in the table with connection.cursor() as cursor: - - cursor.execute("SELECT * FROM customers WHERE customerid = %s", [request.POST['customerid']]) - customer = cursor.fetchone() + + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) + user = cursor.fetchone() ## No customer with same id - if customer == None: + if user == None: ##TODO: date validation - cursor.execute("INSERT INTO customers VALUES (%s, %s, %s, %s, %s, %s, %s)" - , [request.POST['first_name'], request.POST['last_name'], request.POST['email'], - request.POST['dob'] , request.POST['since'], request.POST['customerid'], request.POST['country'] ]) - return redirect('index') + cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" + ,[request.POST['userid'], request.POS['phoneno'], request.POST['password']]) + return redirect('login') else: - status = 'Customer with ID %s already exists' % (request.POST['customerid']) + status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) context['status'] = status - return render(request, "app/add.html", context) + return render(request, "app/register.html", context) # Create your views here. def edit(request, id): - """Shows the main page""" + # dictionary for initial data with # field names as keys @@ -89,4 +188,61 @@ def edit(request, id): context["obj"] = obj context["status"] = status - return render(request, "app/edit.html", context) \ No newline at end of file + return render(request, "app/edit_admin.html", context) + +# Create your views here. +def login(request): + + context = {} + status = '' + + if request.POST: + ## Check if customerid is already in the table + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM customers WHERE customerid = %s", [request.POST['customerid']]) + customer = cursor.fetchone() + ## No customer with same id + if customer == None: + cursor.execute("INSERT INTO customers VALUES (%s, %s)" + , [request.POST['first_name'], request.POST['last_name']]) + return redirect('index') + else: + status = 'Your User Id and Password is incorrect' % (request.POST['customerid']) + + return render(request, 'app/login.html', context) +""" + +# Create your views here. +#def index_products(request): + + + ## Use raw query to get all objects +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM products ORDER BY productid") +# products = cursor.fetchall() + +# result_dict = {'products': products} + +# return render(request, 'app/index_products.html', result_dict) + +#def purchase(request, productid): + + + ## Use raw query to get all objects +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM products WHERE productid = %s",[productid]) +# products = cursor.fetchone() + +# result_dict = {'products': products} + +# return render(request, 'app/purchase.html', result_dict) + +#def profile(request, phoneno): +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM allusers WHERE phoneno = %s",[phoneno]) +# products = cursor.fetchone() + +# result_dict = {'allusers': allusers} + +# return render(request, 'app/profile.html', result_dict) diff --git a/sql/TheMakanNetworkSchema.sql b/sql/TheMakanNetworkSchema.sql new file mode 100644 index 000000000..6a0a23971 --- /dev/null +++ b/sql/TheMakanNetworkSchema.sql @@ -0,0 +1,116 @@ +CREATE TABLE IF NOT EXISTS allusers ( + userid VARCHAR(32) NOT NULL UNIQUE, + phoneno BIGINT PRIMARY KEY, + password VARCHAR(32) NOT NULL +); + +CREATE TABLE IF NOT EXISTS products ( + productid int generated by default as identity + (start with 1 increment by 1) primary key, + sellerid varchar(32) not null, + name varchar(64) not null, + description varchar(256) not null, + price money not null, + category varchar(32) constraint category CHECK(category = 'dessert' OR category='ready meals' OR category = 'pastries' OR category = 'drinks'), + allergen varchar(32) not null, + minorder int not null check(minorder>=0), + foreign key(sellerid) references allusers(userid) +); + +CREATE TABLE IF NOT EXISTS transactions ( + orderid int generated by default as identity + (start with 1 increment by 1), + b_id varchar(32) not null, + s_id varchar(32) not null, + primary key(orderid, b_id, s_id), + p_id int references products(productid) generated by default as identity + (start with 1 increment by 1) unique, + qty int not null check(qty>0), + delivery varchar(12) not null check(delivery='self pickup' OR delivery='delivery'), + status varchar(10) not null check(status='pending' OR status='approved'), + foreign key(b_id) references allusers(userid), + foreign key(s_id) references allusers(userid), + check(not b_id = s_id) +); + +CREATE TABLE IF NOT EXISTS buyers ( + b_id varchar(32) primary key +); + +CREATE OR REPLACE FUNCTION new_buyer() +RETURNS trigger AS $$ +BEGIN + INSERT INTO buyers(b_id) + VALUES(NEW.b_id) ON CONFLICT DO NOTHING; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_buyers +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE new_buyer(); + +CREATE TABLE IF NOT EXISTS sellers ( + s_id varchar(32) primary key +); + +CREATE OR REPLACE FUNCTION new_seller() +RETURNS trigger AS $$ +BEGIN + INSERT INTO sellers(s_id) + VALUES(NEW.sellerid) ON CONFLICT DO NOTHING; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_sellers +AFTER INSERT +ON products +FOR EACH ROW +EXECUTE PROCEDURE new_seller(); + +CREATE OR REPLACE FUNCTION status_check() +RETURNS trigger AS $$ + +DECLARE + total_amount INT; + minorder INT; + +BEGIN + SELECT SUM(qty) FROM transactions WHERE p_id = NEW.p_id INTO total_amount; + SELECT minorder + FROM products + WHERE productid = NEW.p_id; + IF total_amount >= minorder THEN + UPDATE transactions SET status = 'approved' WHERE p_id = NEW.p_id; + RETURN NEW; + END IF; + RETURN NULL; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER check_status +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE status_check(); + +/* +CREATE TABLE IF NOT EXISTS reviews ( + userid VARCHAR(32) REFERENCES transactions(b_id) NOT NULL UNIQUE, + rated_p_id INT REFERENCES transactions(p_id) GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1), + status VARCHAR(10) CONSTRAINT status CHECK (status = 'approved'), + userrating INT CONSTRAINT userrating CHECK (userrating BETWEEN 0 AND 5), + userreview VARCHAR(256), + ratingdate DATE +); +*/ + diff --git a/sql/allusersdata.sql b/sql/allusersdata.sql new file mode 100644 index 000000000..b3b6d7b2a --- /dev/null +++ b/sql/allusersdata.sql @@ -0,0 +1,60 @@ +INSERT INTO allusers(userid,phoneno,password) VALUES ('tcollabine0',6285832565,'PCQxrGeU'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lgaddas1',2253804958,'Xz0rOUUUEl'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('bkaubisch2',7712801575,'nsPynTV6k'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('ckulas3',1558928939,'NCjmH6QIgRmG'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dlawey4',6169476060,'5pM6LrExm96'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('slurcock5',6694624405,'FKUHAZRHav'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rparmeter6',5878515972,'3I8xvw'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mstollard7',7861262615,'Lz5WcLv3Z66'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dantunes8',8844753986,'ZTJGPy'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dwallbridge9',9938377362,'naFqQn2RXOG'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('tbrewetta',8082904722,'NYpqORmP5Ra2'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('aodornanb',6316821408,'9x0eZtJ8u'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mwhysallc',6224005791,'eecBV9rwSbc'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mriseboroughd',5359337509,'GXoGXgrHhmL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rarrowsmithe',1156113166,'WunNnpKaykL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('boscanlanf',7247137333,'9ZsbPBCzYVr'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lfontenotg',4334733116,'OB2MB3IJB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nskalah',8489550491,'zyYDSRxLtEcI'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('gollarenshawi',2246828669,'TsOpVSMHB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nzannollij',1436732744,'hJMlJqoh'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('romullallyk',8411556652,'z9sDzWE71hhA'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dledgerl',1503069846,'BseL6r'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('vcarneckm',9976903369,'DkKEA3'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rdysartn',9428985599,'mY1jG9RPnL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('wratchfordo',6677843909,'8bLy10CfpSw'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('cfiginp',9792286533,'XhYUGXxVO'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mjozsikaq',6292040762,'YbCOWQD'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('ejulyanr',4752728626,'c3YSgVo3'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('wgallys',1572961053,'TzOKYdE'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('jmatisset',1508592599,'UrJpGKMjJfqf'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lmiddletonu',1524260059,'q2nKqf'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('sgallardv',3447670274,'acH36NpsnK'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dgodfrayw',4743171560,'ZOKZje'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('aphysicx',2927408787,'vLop8lxWC8'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mlomaxy',9657782784,'NfopKuQu'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('klinforthz',9977904481,'U8QGtHoE3K'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nhourstan10',3121040783,'lxAdU3kcb'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kpatridge11',3745570419,'ax8QzkC5'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rguice12',3773826039,'cvzH6t'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dmein13',2604513172,'mdE0zrzxCxj'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rcamilleri14',1828651155,'qullFOp08V'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lshreve15',7799267681,'IZdaR7xBBKzJ'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('msodeau16',5247008815,'hrVk9IDoUY'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('eskamal17',4431469231,'eesz9ckLt'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kdaout18',1555993974,'Y2ykGP2d'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mpollock19',7343163085,'PJDAnA'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('pmacgilfoyle1a',8845658668,'wX4aT76yT'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rhillan1b',1345477519,'FjX3BXfo3y'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mchampain1c',6452774714,'9cnhv9Da'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('cwaliszek1d',4709908272,'7oA7OeYSi52'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kpemberton1e',8917122663,'aIaM24sNyFy'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dbodycombe1f',8395936976,'BbO7SumXB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('achellingworth1g',4579015248,'nxbKQIyGxx'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('apavlishchev1h',2271307656,'xdm2qii'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('gsherel1i',9486712033,'LFMoVKM4WTL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mlawrey1j',2072575793,'uG0Bbx87V'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('obrosh1k',9422440139,'JkRxgMRhc65'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nshreeves1l',1811466717,'LUo1MtKl'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rdigginson1m',9087635100,'OLEWn7FEF'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('krannie1n',5709108692,'kmGl9Ov0u'); diff --git a/sql/appschema.sql b/sql/appschema.sql new file mode 100644 index 000000000..a2df2613d --- /dev/null +++ b/sql/appschema.sql @@ -0,0 +1,113 @@ + +CREATE TABLE IF NOT EXISTS allusers ( +userid varchar(16) not null unique, +phoneno bigint primary key, +password varchar(12) not null +); + + +CREATE TABLE IF NOT EXISTS products ( +productid INT GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1) primary key, +sellerid varchar(16) not null, +name varchar(64) not null, +description varchar(256) not null, +price decimal not null check(price>0), +category varchar(32) constraint category CHECK(category = 'dessert' OR category='ready meals' OR category='pastries' OR category='drinks'), +allergen varchar(32) not null, +minorder int not null check(minorder>=0), +foreign key(sellerid) references allusers(userid), +unique(productid, sellerid) +); + +CREATE TABLE IF NOT EXISTS transactions ( +orderid INT GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1) primary key, +b_id varchar(16) not null, +s_id varchar(16) not null, +p_id int references products(productid), +qty int not null check(qty>0), +delivery varchar(12) not null check(delivery='self pickup' OR delivery='delivery'), +status varchar(10) not null check(status='pending' OR status='confirmed'), +foreign key(b_id) references allusers(userid), +foreign key(s_id, p_id) references products(sellerid, productid), +check(not b_id = s_id) +); + +CREATE TABLE IF NOT EXISTS product_ratings ( +b_id references transactions +); + + +CREATE TABLE IF NOT EXISTS buyers ( +b_id varchar(16) primary key +); + + +CREATE OR REPLACE FUNCTION new_buyer() + RETURNS trigger AS +$$ +BEGIN + INSERT INTO buyers(b_id) + VALUES(NEW.b_id) on conflict do nothing; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_buyers + AFTER INSERT + ON transactions + FOR EACH ROW + EXECUTE PROCEDURE new_buyer(); + + +CREATE TABLE IF NOT EXISTS sellers ( +s_id varchar(16) primary key +); + +CREATE OR REPLACE FUNCTION new_seller() + RETURNS trigger AS +$$ +BEGIN + INSERT INTO sellers(s_id) + VALUES(NEW.sellerid) on conflict do nothing; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_sellers + AFTER INSERT + ON products + FOR EACH ROW + EXECUTE PROCEDURE new_seller(); + + +--TRIGGER TO CHANGE STATUS +CREATE OR REPLACE FUNCTION updatestatus() +RETURNS trigger AS +$$ +declare + total INT; + minord INT; + +BEGIN + select sum(qty) from transactions where p_id=new.p_id into total; + select minorder from products where productid=new.p_id into minord; + if total >= minord then + UPDATE transactions SET status = 'confirmed' WHERE p_id = new.p_id; + RETURN new; + end if; + RETURN new; +END; +$$ + LANGUAGE 'plpgsql'; + +CREATE TRIGGER statusupdate +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE updatestatus(); diff --git a/sql/clean.sql b/sql/clean.sql new file mode 100644 index 000000000..88fa494fc --- /dev/null +++ b/sql/clean.sql @@ -0,0 +1,17 @@ + +DROP TABLE IF EXISTS allusers CASCADE; +DROP TABLE IF EXISTS products CASCADE; +DROP TABLE IF EXISTS transactions CASCADE; +DROP TABLE IF EXISTS sellers CASCADE; +DROP TABLE IF EXISTS buyers CASCADE; +DROP TABLE IF EXISTS reviews CASCADE; +DROP TRIGGER IF EXISTS update_sellers on products; +DROP TRIGGER IF EXISTS check_status on transactions; + + +/* +SELECT * FROM allusers; +SELECT * FROM products; +SELECT * FROM transactions; +SELECT * FROM reviews; +*/ \ No newline at end of file diff --git a/sql/products.sql b/sql/products.sql new file mode 100644 index 000000000..bd2d2a4b9 --- /dev/null +++ b/sql/products.sql @@ -0,0 +1,40 @@ +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mchampain1c', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 5.1, 'dessert', 'dairy-free', 4); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rdysartn', 'Indonesian Keropok', 'Keropok are crunchy savoury snacks mostly made from starch and often flavoured with fish, seafood (prawns, squid), onion, chilli', 59.0, 'ready meals', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 43.4, 'dessert', 'gluten-free', 30); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpemberton1e', 'Salted Egg Cookies', 'Soft buttery cookies are infused with the salty umami salted egg yolks to give you sweet, salty, and crumbly cookies.', 50.2, 'dessert', 'egg-free', 20); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 57.8, 'ready meals', 'dairy-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Pasta', 'Angel hair tomato based spaghetti', 6.4, 'ready meals', 'nut-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Tulang', 'In blandit ultrices enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', 10.8, 'ready meals', 'dairy-free', 5); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Crème Brulee Macaron', 'Caramelised bite-size wonders', 47.4, 'dessert', 'egg-free', 1); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nhourstan10', 'Salted Egg Cookies', 'Soft buttery cookies are infused with the salty umami salted egg yolks to give you sweet, salty, and crumbly cookies.', 29.1, 'dessert', 'dairy-free', 21); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mlawrey1j', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 19.6, 'pastries', 'nut-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpatridge11', 'Tulang', 'Delicious Soup Tulang with meaty bones and hot gravy.', 9.7, 'ready meals', 'egg-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Banana Pudding', 'Bringing you the most delicious and authentic South American dessert!', 9.8, 'dessert', 'egg-free', 45); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Laska', 'Best Singapore Laksa', 38.6, 'ready meals', 'egg-free', 37); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Indonesian Keropok', 'Keropok are crunchy savoury snacks mostly made from starch and often flavoured with fish, seafood (prawns, squid), onion, chilli', 19.1, 'pastries', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Nutella Butter Cookies', 'Nutella butter cookies with delicious Nutella filled in the centre', 10.3, 'ready meals', 'gluten-free', 46); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Duo Flavour Cinnamon Roll', 'Get the taste of both world with our vanilla and chocolate cinnamon roll.', 54.6, 'dessert', 'nut-free', 11); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 16.7, 'ready meals', 'dairy-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('romullallyk', 'Durian Chocolate Cakes', 'Taste of 2 Heavens: Mao Shan Wang and Chocolate', 46.9, 'dessert', 'nut-free', 13); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('pmacgilfoyle1a', 'Chili Manis', 'Delicious sweet chili sauce for you to dip anything and everything in', 21.3, 'ready meals', 'gluten-free', 39); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mpollock19', 'Pasta', 'Turkey bacon carbonara', 59.6, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('jmatisset', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 22.5, 'pastries', 'dairy-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lshreve15', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 32.1, 'pastries', 'nut-free', 16); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Tulang', 'Bowl of wonderful meaty mutton bones with red sauce', 20.1, 'ready meals', 'gluten-free', 0); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Ang Ku Kueh', 'Ang Ku Kueh that taste just like your grandma’s handmade ones', 42.7, 'dessert', 'egg-free', 36); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mjozsikaq', 'Chili Manis', 'Sweet Chili sauce to pair with everything', 41.6, 'ready meals', 'dairy-free', 17); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('slurcock5', 'Matcha Speculoos', 'Green tea gelato with speculoos filling.', 58.8, 'dessert', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('gsherel1i', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('cwaliszek1d', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 16.5, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rcamilleri14', 'Durian Chocolate Cakes', 'Chocolate cake filled with durian wonder', 10.2, 'dessert', 'dairy-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('msodeau16', 'Hakka Yong Tau Foo', 'Good ol traditional Yong Tau Foo.', 17.8, 'ready meals', 'nut-free', 2); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dledgerl', 'Durian Chocolate Cakes', 'Mao Shan Wang combined with Chocolate.', 31.8, 'dessert', 'gluten-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'gluten-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('ejulyanr', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 24.2, 'dessert', 'dairy-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('boscanlanf', 'Duo Flavour Cinnamon Roll', 'Matcha and Chocolate Cinnamon Roll together in one', 42.9, 'dessert', 'nut-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Caramelised Onions Sourdough Loaf', 'Perfect bread for a wonderful breakfast.', 43.8, 'pastries', 'gluten-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lfontenotg', 'Durian Chocolate Cakes', 'A little wonderful secret inside the Chocolate Cake.', 45.6, 'dessert', 'egg-free', 50); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lmiddletonu', 'Laska', 'Penang Laksa straight from Malaysia', 26.9, 'ready meals', 'dairy-free', 41); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kdaout18', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 6.9, 'pastries', 'nut-free', 6); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Laska', 'The original Katong Laksa', 18.8, 'pastries', 'gluten-free', 14); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dwallbridge9', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'egg-free', 3); diff --git a/sql/productsdata.sql b/sql/productsdata.sql new file mode 100644 index 000000000..feda1bb0b --- /dev/null +++ b/sql/productsdata.sql @@ -0,0 +1,40 @@ +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mchampain1c', 'Basque Cheesecake', 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vestibulum sagittis sapien.', 5.1, 'dessert', 'dairy-free', 4); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rdysartn', 'Indonesian Keropok', 'Curabitur gravida nisi at nibh.', 59.0, 'dessert', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Basque Cheesecake', 'Nullam porttitor lacus at turpis.', 43.4, 'ready meals', 'gluten-free', 30); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpemberton1e', 'Salted Egg Cookies', 'Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros.', 50.2, 'pastries', 'egg-free', 20); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Curry filled bun', 'Maecenas ut massa quis augue luctus tincidunt.', 57.8, 'dessert', 'dairy-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Pasta', 'Etiam vel augue. Vestibulum rutrum rutrum neque.', 6.4, 'drinks', 'nut-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Tulang', 'In blandit ultrices enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', 10.8, 'dessert', 'dairy-free', 5); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Crème Brulee Macaron', 'Morbi non quam nec dui luctus rutrum.', 47.4, 'pastries', 'egg-free', 1); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nhourstan10', 'Salted Egg Cookies', 'Maecenas tristique, est et tempus semper, est quam pharetra magna, ac consequat metus sapien ut nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris viverra diam vitae quam.', 29.1, 'pastries', 'dairy-free', 21); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mlawrey1j', 'Baklava Rings', 'Donec ut dolor. Morbi vel lectus in quam fringilla rhoncus. Mauris enim leo, rhoncus sed, vestibulum sit amet, cursus id, turpis.', 19.6, 'drinks', 'nut-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpatridge11', 'Tulang', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 9.7, 'pastries', 'egg-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Banana Pudding', 'Vivamus vel nulla eget eros elementum pellentesque.', 9.8, 'dessert', 'egg-free', 45); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Laska', 'Aenean auctor gravida sem. Praesent id massa id nisl venenatis lacinia.', 38.6, 'pastries', 'egg-free', 37); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Indonesian Keropok', 'Sed ante.', 19.1, 'drinks', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Nutella Butter Cookies', 'In hac habitasse platea dictumst.', 10.3, 'drinks', 'gluten-free', 46); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Duo Flavour Cinnamon Roll', 'Vivamus vel nulla eget eros elementum pellentesque.', 54.6, 'dessert', 'nut-free', 11); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Curry filled bun', 'Proin eu mi. Nulla ac enim. In tempor, turpis nec euismod scelerisque, quam turpis adipiscing lorem, vitae mattis nibh ligula nec sem.', 16.7, 'drinks', 'dairy-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('romullallyk', 'Durian Chocolate Cakes', 'Nullam varius.', 46.9, 'ready meals', 'nut-free', 13); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('pmacgilfoyle1a', 'Chili Manis', 'Nulla ut erat id mauris vulputate elementum. Nullam varius. Nulla facilisi.', 21.3, 'dessert', 'gluten-free', 39); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mpollock19', 'Pasta', 'Fusce congue, diam id ornare imperdiet, sapien urna pretium nisl, ut volutpat sapien arcu sed augue.', 59.6, 'dessert', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('jmatisset', 'Curry filled bun', 'In blandit ultrices enim.', 22.5, 'pastries', 'dairy-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lshreve15', 'Baklava Rings', 'Quisque id justo sit amet sapien dignissim vestibulum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla dapibus dolor vel est. Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros.', 32.1, 'ready meals', 'nut-free', 16); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Tulang', 'Donec posuere metus vitae ipsum. Aliquam non mauris. Morbi non lectus.', 20.1, 'dessert', 'gluten-free', 0); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Ang Ku Kueh', 'Integer a nibh. In quis justo.', 42.7, 'dessert', 'egg-free', 36); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mjozsikaq', 'Chili Manis', 'Integer ac leo.', 41.6, 'pastries', 'dairy-free', 17); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('slurcock5', 'Matcha Speculoos', 'Nam congue, risus semper porta volutpat, quam pede lobortis ligula, sit amet eleifend pede libero quis orci. Nullam molestie nibh in lectus. Pellentesque at nulla.', 58.8, 'ready meals', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('gsherel1i', 'Biscoff-filled cookies', 'Morbi non lectus.', 31.5, 'drinks', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('cwaliszek1d', 'Curry filled bun', 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec pharetra, magna vestibulum aliquet ultrices, erat tortor sollicitudin mi, sit amet lobortis sapien sapien non mi. Integer ac neque. Duis bibendum.', 16.5, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rcamilleri14', 'Durian Chocolate Cakes', 'Mauris lacinia sapien quis libero. Nullam sit amet turpis elementum ligula vehicula consequat. Morbi a ipsum.', 10.2, 'drinks', 'dairy-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('msodeau16', 'Hakka Yong Tau Foo', 'Nunc purus. Phasellus in felis.', 17.8, 'drinks', 'nut-free', 2); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dledgerl', 'Durian Chocolate Cakes', 'Integer ac neque. Duis bibendum.', 31.8, 'pastries', 'gluten-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Biscoff-filled cookies', 'Morbi vestibulum, velit id pretium iaculis, diam erat fermentum justo, nec condimentum neque sapien placerat ante. Nulla justo. Aliquam quis turpis eget elit sodales scelerisque.', 3.7, 'dessert', 'egg-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('ejulyanr', 'Basque Cheesecake', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 24.2, 'ready meals', 'dairy-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('boscanlanf', 'Duo Flavour Cinnamon Roll', 'Phasellus in felis. Donec semper sapien a libero. Nam dui.', 42.9, 'drinks', 'nut-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Caramelised Onions Sourdough Loaf', 'Aenean lectus. Pellentesque eget nunc. Donec quis orci eget orci vehicula condimentum.', 43.8, 'pastries', 'gluten-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lfontenotg', 'Durian Chocolate Cakes', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 45.6, 'ready meals', 'egg-free', 50); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lmiddletonu', 'Laska', 'Integer aliquet, massa id lobortis convallis, tortor risus dapibus augue, vel accumsan tellus nisi eu orci. Mauris lacinia sapien quis libero. Nullam sit amet turpis elementum ligula vehicula consequat.', 26.9, 'dessert', 'dairy-free', 41); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kdaout18', 'Baklava Rings', 'Integer pede justo, lacinia eget, tincidunt eget, tempus vel, pede.', 6.9, 'pastries', 'nut-free', 6); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Laska', 'Morbi porttitor lorem id ligula. Suspendisse ornare consequat lectus. In est risus, auctor sed, tristique in, tempus sit amet, sem.', 18.8, 'pastries', 'gluten-free', 14); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dwallbridge9', 'Biscoff-filled cookies', 'Donec quis orci eget orci vehicula condimentum.', 5.5, 'dessert', 'egg-free', 3); \ No newline at end of file diff --git a/sql/transdata.sql b/sql/transdata.sql new file mode 100644 index 000000000..6b4caae1a --- /dev/null +++ b/sql/transdata.sql @@ -0,0 +1,20 @@ +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mstollard7','aphysicx',16,37,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','dmein13',24,89,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('krannie1n','wratchfordo',23,87,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lshreve15',22,27,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rarrowsmithe','aphysicx',39,24,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nzannollij','pmacgilfoyle1a',19,80,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('slurcock5','nhourstan10',9,44,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('kdaout18','lshreve15',22,43,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','eskamal17',32,47,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dantunes8','dledgerl',31,47,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rhillan1b','boscanlanf',34,48,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dgodfrayw','jmatisset',21,98,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','aphysicx',6,7,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('achellingworth1g','eskamal17',17,38,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mpollock19','ejulyanr',33,57,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mstollard7','nhourstan10',9,55,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('msodeau16','mpollock19',20,48,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('kdaout18','nhourstan10',9,79,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('bkaubisch2','lmiddletonu',37,82,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','mlawrey1j',10,28,'delivery','pending');