Database Design daily data [closed] - mysql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a question about database design, I'm wondering how do you go about saving daily user data.
For example I have a table called Accounts
structure is accountID, accountName, DailyScore, WinRate
how can I keep track of DailyScore and WinRate for each day. Do I keep creating tables named after a date or is there a better way.

Accounts has info about each "account" -- account_id, name, etc. This table is rather static -- you occasionally add a row, and sometimes change something.
Scores has new rows every day -- account_id, date, score, etc. The PRIMARY KEY would have two columns: account_id and date.
Not knowing how winRate is calculated, it is unclear where, if anywhere, it should be stored. Is it calculated from the scores??

Related

Database table structure for Exam test portal [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed yesterday.
This post was edited and submitted for review yesterday and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I am developing a website for Exams / Test for Students.
We will have student table (student id) , question table (question id, 4 options, correct option)
However for recording the results of students taking an exam, if we create table that has
student id
question id
selected answer
But the challenge is volume. Expecting 1000 students and 200 questions.. If each student does exam once, it will create 200000 records. Assuming they will be practicing exams multiple times, the rows can go to millions very quickly. This may make data retrieval very slow (for showing in each user profile).
Any suggestion how to manage it ? or should we use different type database (nosql rather than mysql).
thanks
the details are provided above
Look into indexing for your tables. This will improve retrieval speed.
Good reference: http://www.tutorialspoint.com/sql/sql-indexes.htm
Two important factors are:
Speed of your server
SELECT statement has minimal conditions and joins. I would spend some time figuring out some good, clean, and optimized SELECT queries your server could use to retrieve the data.

Best Practice for Budgeting MySQL Database Design [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to find the best solution for my needs. I have a budgeting application that each user will have their own budget which will include potentially hundreds or thousands of budget entries. Initially I thought I would have a table for the users and basic info, and then each user would have their own sql table with all of their budget items held within. However, if the user list grows to hundreds or thousands then I would have a large amount of tables since each user would have their own. I also considered a single table to hold everyone's budget entries but I'm not sure that's the correct solution either.
Any advice? Thank you in advance
I think a single table that holds all the budget entries, with a primary key that's referenced by a foreign key in the "users" table, is a good way to go. You can always use something like select * from users u join budgets b on u.userID = b.userID where userID = xxx to get the budget items for a particular user.

How do I track the time a person goes to a place? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm working on creating a database for a gym to track the members info. I want to be able to track the times that people go so you will be able to see when it is busiest. I'm not sure how to go about this. Do I need to make a new table for the information of when a member goes or do I add it into the members or gyms table?
I would add this to a different table. You could make a new table with user_id which is the same as the users ID in the user table. It would then be quite easy to tie the visits to the users, if that’s a point.
Create a visits table with the following columns
visitId
memberId
gymId
entryTime
exitTime
The GymId column may not be required if your member is linked to a gym but it depends on your requirements
Think in terms of "domain" models. From your question it appears you already have Member and Gym models.
I suggest introducing an Attendance model.
Attendance
- UserId
- CheckInDateTime
This would translate to a new database table called "attendance" with the corresponding columns.
In order to see when is the busiest time - I would execute a "select count" statement on the attendance table and "group by" the check_in_date column (truncate the time portion).
A note on persisting datetime values. It is recommended to store the datetime value in UTC timezone. Then you can have your application convert the timezone accordingly when viewing the data.

MySQL user data storage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have two tables that should somehow be associated. Let's call them table_a and
table_b. A row in table_a can be associated with multiple rows in table_b, and the same goes the other way around. How could I achieve this? Should I use a pivot table?
Both tables have an auto-incrementing id-column.
What you're looking for is called a many-to-many relationship (a given user has zero or more games, a given game has zero or more users). This is typically handled with a "mapping table", e.g. USER_GAMES which has a user_id and a game_id, uniqueness is on the combination of these. http://www.joinfu.com/2005/12/managing-many-to-many-relationships-in-mysql-part-1/ has some good details.
As it is a many to many relationship, an intersection table with the user ID & game ID would be the best. Otherwise you would have to parse the list of game ID's stored in the user table and that would cause performance issues.

sql - calendar table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to create a program where a person will be able to save his schedule.
For example a doctor will be able to save an appointment.
I want to save every appointment in a mysql database. So I need to create a calendar/appointments table. In every appointment I want to save these information:
day
month
year
start (hour)
finish (hour)
participant (the patient)
I was thinking of creating a big table with all the possible appointments for some years (ex. 20 years) and leaving the participant column empty, meaning there is no appointment. If an appointment is made the the participant field will be filled.
Is there a better way of doing it? Can someone provide some guidelines and if possible an example? I want to keep it as simple as possible.
table appointments
--------------------
id int (primary key, auto_increment)
participant_id int (foreign key to persons table)
starts datetime
ends datetime
Then only save the real appointments and not empty ones. Storing fakes is never a good idea.