php - Possibilities to mark only one entry in database table -


i working on kind of topiclist. can have multiple topics , each topic can have multiple subtopics. can vote each subtopic if or not, don't think relevant question.

so 2 relevant database tables topics , subtopics.

here simplified versions of them:

create table topics (     id integer primary key auto_increment not null,     name varchar(1000) not null );  create table subtopics (     id integer primary key auto_increment not null,     title varchar(1000) not null,     topic_id integer not null,     foreign key(topic_id)     references topics(id) ); 

i want add possibility mark subtopic, prioritized, there should 1 prioritized subtopic each topic.

do have suggestions how realize that?

my idea add field subtopics timestamp, gets updated current time, when mark prioritized. when select entries, have recent timestamp.

are there other (better) possibilities?

i working php , mysql

you have add 3 field priority,vote,timestamp subtopics table.

priority field 0 or 1 means 1 proritized , 0 not. vote 0 or 1 means 1 liked , 0 not liked. timestamp contain time when mark subtopic prioritized.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -