0

below, I have create a table using oracle sql.

How can I change so that number of credits for a course is always between 0 and 6. Any idea how can i do this?

CREATE TABLE COURSES
  (COURSE VARCHAR(6),
   DESCRIPTION VARCHAR(60),
   CREDITS INT,
   CONSTRAINT pk PRIMARY KEY (COURSE));

Edited by hwoarang69

2
Contributors
5
Replies
13
Views
2 Years
Discussion Span
Last Post by diafol
0

I would imagine that data validation could be done with server-side code. I don't use Oracle myself, but I'm assuming that the datatype that you need is TT_TINYINT (0 to 255). I've seen some people mention ENUM, but IMO this is not appropriate for simple integers.

Are you using any server-side language?

0

but cant you enter 7 in TT_TINYINT? i need to do it so range is from 0 to 6. I am using oracle mysql.

0

Read my post. I said it accepts 0 to 255. So yes, it can. There is no specific datatype that I know of for what you're asking. Are you able to validate server-side? You don't give any info wrt how you're insering data

Edited by diafol

0

i am just inserting data by using mysql(Oacle) insert statments.

Edited by hwoarang69

0

Ah, ok, in that case, I don't know. You could try to use an IF function maybe (??) but that means you'd have to implement it in the actual SQL query which is probably not what you want. Perhaps you could use a related table using a constraint - make the credits field an FK of a credits table PK:

credits table
PK 0-6
Other fields??

So, beyond this I'm not much help - sorry.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.