asp.net mvc - SQL: Create new table check with if else in view -


sql: create new table keep definition of status in other table or check if else in view.

i'm doing reservation database programming.

i have table reservation contain [status](char=> 0,1,2,3)

0 mean reserved,1 check in,2 check out,3 cancelled

which better between create new table keeping definition of status or use if case in view show definition such as

if(status=="0") print reserved if(status=="1") pring ...... ..... ... 

thx,for advice

if these statuses unlikely expanded in future, , used 1 table, might want keep definition within single table.

if did this, might want create table following:

create table t (     /* various columns */     status tinyint not null,     constraint t_status_valid check (status between 0 , 3),     statustext case status        when 0 'reserved'        when 1 'check in'        when 2 'check out'        when 3 'cancelled'     end ) 

this saves having create other objects in database, whilst automatically providing text (if required), , avoiding invalid status values.

if, otoh, expect range of statuses change in future, or need use statuses in multiple tables, or feel above "messy" (opinions can vary here), create separate table , use foreign key.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -