table-structure

How to store a store opening hours in an SQL database?

戏子无情 提交于 2020-12-08 05:11:58
问题 I am developing an app for stores (in fact, restaurants) and need to design the PostgreSQL data structure for it. For instance, the restaurant might have opening hours Mon-Fri from 7:30 to 17:00 and from 20:30 to 1:00 the following day. The data to be stored for each weekday would be something like ['Monday', true, 450, 1050, 1230, 1500 ] , being true === "it does open on Mondays", 450, opening time is 450 minutes past midnight (see here), i.e. at 7:30h, closes at 17:30h, reopens at 20:30h,

How should I setup my mySQL tables for this simple php points system?

本小妞迷上赌 提交于 2020-01-05 08:08:33
问题 Hello I am trying to figure out the best way to setup my two mysql tables for a simple points system? What I have: 1 - users table with id (unique),name,email,etc 1 - points table with id (auto incrementing),user_id (corresponds with id field in user table), points Currently I am just writing to the points table and letting the id field auto increment... and setting the user_id field and points fields with php in the query. Is this the "proper" way to set this up? Where the id from the user

How do I implement threaded comments?

和自甴很熟 提交于 2019-12-20 08:27:50
问题 I am developing a web application that can support threaded comments. I need the ability to rearrange the comments based on the number of votes received. (Identical to how threaded comments work in reddit) I would love to hear the inputs from the SO community on how to do it. How should I design the comments table? Here is the structure I am using now: Comment id parent_post parent_comment author points What changes should be done to this structure? How should I get the details from this

How to set a calculated column using a subquery

情到浓时终转凉″ 提交于 2019-12-20 06:27:09
问题 I have a table to which I would like to add a calculated column. The query I want to set it to is more complex than a standard arithmetic operation and I am unsure how to set up the calculated column using the query. I attempted to use an ALTER TABLE statement: ALTER TABLE shareholder.Amount ADD CalculatedAmount As (SELECT sum(Amount) FROM shareholder.TransactionInput T WHERE T.ShareClassLabel = Amount.ShareClassLabel AND T.ValuationDate < Amount.NAVDate GROUP BY T.ShareClassLabel) But this

MySQL - Best method to handle this hierarchical data?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 07:14:05
问题 This is a followup to: MySQL - Is it possible to get all sub-items in a hierarchy? I have an arbitrary-depth adjacency list model table (I am at the point that I can convert it into a nested set model . I read the MySQL data on how to use a nested set model, though it seemed to get increasingly complex and very complex to do basic functions such as inserting, updating and deleting. Another blog showing how to use a trigger system with the adjacency list model to keep a table of ancestors that

What changes do I need for my tables to work on AppEngine's BigTable?

人走茶凉 提交于 2019-12-04 13:42:42
问题 Let's say I have a booking database consisting of users : user_id fname lname and their tickets ticket_id user_id flight_no and associated flights flight_no airline departure_time arrival_time What would I need to change to move this Google AppEngine? I understand AppEngine doesn't allow joins . Does that mean my table should become one big schmudge of fields all lumped together? bookings : user_id fname lname ticket_id flight_no airline departure_time arrival_time In other words, all of my

How to model Friendship relationships

房东的猫 提交于 2019-12-03 21:51:17
问题 I have been trying to figure out how to do this, and even with looking at other examples, I can't get it figured out, so maybe I can get some personalized help. I've got two tables, users_status and friendships . In the users_status table I have a field userid , and several others. In the friendships table, I have the fields request_to , request_from , and friendship_status . Basically what I want to do is get all of the status posts by the current user AND those who are friends of the

What changes do I need for my tables to work on AppEngine's BigTable?

核能气质少年 提交于 2019-12-03 08:43:22
Let's say I have a booking database consisting of users : user_id fname lname and their tickets ticket_id user_id flight_no and associated flights flight_no airline departure_time arrival_time What would I need to change to move this Google AppEngine? I understand AppEngine doesn't allow joins . Does that mean my table should become one big schmudge of fields all lumped together? bookings : user_id fname lname ticket_id flight_no airline departure_time arrival_time In other words, all of my queries now run against the same table? What changes you need depends mostly on what queries you need to

How do I implement threaded comments?

耗尽温柔 提交于 2019-12-02 14:18:42
I am developing a web application that can support threaded comments. I need the ability to rearrange the comments based on the number of votes received. (Identical to how threaded comments work in reddit ) I would love to hear the inputs from the SO community on how to do it. How should I design the comments table? Here is the structure I am using now: Comment id parent_post parent_comment author points What changes should be done to this structure? How should I get the details from this table to display them in the correct manner? (Implementation in any language is welcome. I just want to

How to model Friendship relationships

时间秒杀一切 提交于 2019-11-30 23:54:37
I have been trying to figure out how to do this, and even with looking at other examples, I can't get it figured out, so maybe I can get some personalized help. I've got two tables, users_status and friendships . In the users_status table I have a field userid , and several others. In the friendships table, I have the fields request_to , request_from , and friendship_status . Basically what I want to do is get all of the status posts by the current user AND those who are friends of the current user (which I can specify in my PHP using a $userid variable). Here's an example of the friendships