Last active
July 22, 2019 08:14
-
-
Save cmh114933/6538e30d618fb932903fdbe63023ee1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO community VALUES ('Sports Hobbyist'),('Table Top Gaming'),('Cooks Delight') | |
INSERT INTO tag VALUES ('Allow Smoking'),('Allow Pets'),('Allow Cooking') | |
INSERT INTO properties_tags VALUES (1,1),(1,2),(2,1),(2,3),(1,3),(3,2),(2,4),(1,4) | |
INSERT INTO communities_users VALUES (1,1),(1,2),(2,1),(2,3),(1,3),(3,2) | |
INSERT INTO booking | |
VALUES | |
('2019/07/07','2019/07/07',2000, 'Nice place', 5,6,1), | |
('2019/07/07','2019/07/07',3000, 'Interesting', 5,1,1), | |
('2018/01/07','2018/02/07',4000, 'So So', 5,2,2), | |
('2019/06/07','2019/06/07',5000, 'Comfortable', 5,3,3), | |
('2019/05/07','2019/05/07',6000, 'Cool', 5,4,4), | |
('2019/04/07','2019/04/07',7000, 'Awesome', 5,5,4) | |
INSERT INTO review | |
VALUES | |
(5,'Nice',1), | |
(3,'Could be better',2), | |
(2,'Bad smell',3), | |
(4,'Good service',4), | |
(2,'Do not come here',1), | |
(1,'Atrocious service and food',3), | |
(3,'Average',4), | |
(5,'Awesome',4) | |
INSERT INTO payment | |
VALUES | |
(2000, 'PENDING', 'Credit Card', 7), | |
(3000, 'PENDING', 'Cash', 8), | |
(4000, 'PROCESSING', 'Online Transfer', 9), | |
(5000, 'FAILED', 'Crypto', 4), | |
(6000, 'PAID', 'Credit Card', 5), | |
(7000, 'FAILED', 'Installments', 6) | |
Persistence | |
============ | |
Create | |
------------- | |
Create new user | |
POST /users/<userId>/bookings | |
Create a booking for a user | |
POST /users/<userId>/reviews?propertyId=<propertyId> | |
Create a review for a user for a property | |
POST /bookings | |
Annonymous creation of bookings with no user | |
Update | |
------------- | |
Change User info | |
POST /bookings/<bookingId> | |
Update booking information | |
POST /reviews/<reviewId> | |
Update review rating | |
POST /users?bookingId=<bookingId> | |
On user creation, update provided booking that has no user with new user | |
Delete | |
------------- | |
Delete a Booking | |
Delete a list of payments | |
DELETE /users/<userId> | |
Delete a user and it's associated bookings, reviews, payments, communities | |
Associations | |
============ | |
One To Many | |
------------- | |
User < Bookings | |
Booking < Payments | |
Property < Bookings | |
Property < Reviews | |
Many To Many | |
------------- | |
Properties >-< Tags | |
User >-< Communities | |
Displaying JSON without Infinte loops | |
------------- | |
@JsonManagedReference & @JsonBackReference | |
@JsonIdentityInfo | |
Custom serializer | |
Set relationship null | |
Saving Associations (CASCADE) | |
------------------- | |
Delete Property, and delete all the reviews for that property | |
Delete a user and it's associated bookings, reviews, payments, communities |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment