sql - Creating an attribute that can store the same value as another attribute -


just quick question!

i implementing database using oracle sql developer school , i've come across requirement i'm not quite sure how implement.

basically database student management system , i'm working on assessment table currently. here requirement

"the maximum_mark attribute stores maximum possible raw mark assessment(e.g., 30), while weight attribute stores percentage weight of assessment paper whole (e.g., 10%). if maximum_mark not specified,then front-end applications should use weight both."

does mean should set default value maximum mark whatever entered weight? if so, how go this? far have isn't working.

create table assessment (   assessment_id   number(10),   ...   ...   weight          number(3)    constraint assessment_weight_null not null    constraint assessment_weight_invalid check(weight between 0 , 100),   maximum_mark    number(3)    default (weight),     constraint assessment_pk primary key (assessment_id) ); 

any appreciated!

you can't use column default value, default (weight) won't work.

default values must constants. can use oracle functions but can't involve column, functions sysdate, current_timestamp , systimestamp allowed. can default trim('abc ') (because doesn't involve column) doesn't much.

that said, don't think need define default @ database level. check wording of requirement (emphasis added):

if maximum_mark not specified,then front-end applications should use weight both.

the "front-end applications" here key: professor expects substitution of weight maximum_mark done front-end apps, not database. in opinion, don't need default value @ database level.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -