DESIGN OF TABLE OF MEMBERED SITE

Asked 1 years ago, Updated 1 years ago, 83 views

I'd like to create a membership-based learning support site with cakephp 2.7, but I don't know exactly what kind of table I should design.

First of all, since it is a membership system, the username and password columns are prepared in the membership table (users table).

Next is the question statement table for the question exercise.
Column is problem ID column, q_body column.
Assume that this questionnaire contains 10 questions (10 lines) of data.

What I want to do is manage the progress of each registered user.

What I'm thinking about now is how to create and manage a progress table for each user.
In the progress table, the problem ID column, and the try1 column to write the first result.I'm going to prepare a try2 column to write the second result.
After the user solves the problem 1 for the first time, the result is written in the try1 column of the row of the problem 1 in the progress table.
After the user solves the problem 1 again, the result is written in the try2 column of the row of the problem 1 in the progress table.
I'd like to make this happen.

In this case, I think each member will have to prepare a progress table, but I don't know exactly what to do.

I thought about this, but in any case, I need a way to connect my membership number with the progress table for that person.
In other words, it is necessary to have a mechanism that allows member A to write in the progress table for member A, but not in the progress table for other members.
In order to do this, it is necessary to display a form (page) for writing in the progress table for A when the member A logs in.
I think this corresponds to the so-called My Page on the membership site, but how can I achieve this?

For the time being, is there no problem with the above policy regarding table design? (Is it possible to achieve what you want to do with this?)
I would appreciate it if you could do something like this because the above method is impossible or extremely inefficient.

cakephp database-design

2022-09-30 19:26

2 Answers

I think it's not a cake problem, but it doesn't have an image of how to use the relational database (RDB).
What you expect is the following image, right?

UserA Results Table
  Problem ID 1st result 2nd result 3rd result...
  1ng ok
  2ok
  3ng ok
UserB Result Table
  Problem ID 1st result 2nd result 3rd result...
  1 ok
  2ok

First,
·It is unrealistic to create a table for each user.
·It is also unrealistic to prepare columns that may change the number of times as shown in the nth result.

RDB requires normalization to store data efficiently.
*If you google DB normalization, it will appear a lot.

The following is just one example, so please take it as a reference.

The result table is defined as follows:

Results table
  User ID Problem ID Resolved Count Result Date and Time
  A12ok 2015-10-29 12:59
  A 11ng 2015-10-29 12:41
  B10 1ng 2015-10-29 12:01
  C21ok 2015-10-29 12:33
  A21ok 2015-10-29 13:15
  C11ok 2015-10-29 12:11
  C31ok 2015-10-29 12:41

If you have these tables and want to know the results of User A, narrow down the records with User ID AA 』<where user ID='A' yields the following results:

Results table
  User ID Problem ID Resolved Count Result Date and Time
  A12ok 2015-10-29 12:59
  A 11ng 2015-10-29 12:41
  A21ok 2015-10-29 13:15

Furthermore, if you want to know the result of problem 1 for user A, narrow down only the record with user ID 'A' and problem ID '1'.<where user ID = 'A' and problem ID = '1' results similar to the following:

Results table
  User ID Problem ID Resolved Count Result Date and Time
  A12ok 2015-10-29 12:59
  A 11ng 2015-10-29 12:41

Using the above results is how to use RDB.
Try using keywords like Select RDB, Project RDB, and Combine RDB.

If you don't study cakePHP after understanding how to use RDB like this, you won't be able to make progress in both studies.
Try your best.


2022-09-30 19:26

I think it's enough to make one progress table.I would.

You just need to have a column in the progress table containing the user id (username).
(I think user id is the main key in the membership table, so from the progress table, it's a foreign key, but some database engines don't necessarily implement foreign keys, so it might not be too particular.)

The following 4 types of column structure

Year, month, date, minute, second, user id, problem number, result

Since it is unlikely that the same user will be able to solve more than one question in the same year, time, minute, and second, the user id will act as a unique primary key.

The relational database allows you to retrieve a table map (subset) when querying (searching), so

In other words, it is necessary to have a mechanism that allows member A to write in the progress table for member A, but not in the progress table for other members.

This can also be achieved with a single progress table.Typically on DBMS

SELECT* FROM progress table WHERE username='username';

You can use SQL or something like that.This results in a set of entries with a specific username.

SQL's WHERE clause is equivalent to setting conditions in the find method for CakePHP.

The number of times you solve a problem is sufficient by querying how many entries for the same problem for the same user, so you don't need to "prepare" items from Try1 to TryN in particular.Column design is rather inflexible.

Although CakePHP itself provides the UI part of the web as a framework, I think understanding of the database is a prerequisite.As suzukis has already mentioned in the comments, it is recommended that you at least study the relational database separately before dealing with specific framework implementations such as CakePHP.


2022-09-30 19:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.