Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:53:37+00:00 2026-06-18T04:53:37+00:00

I am trying to make a table in Oracle which is governed by several

  • 0

I am trying to make a table in Oracle which is governed by several integrity constraints. The table consists of a hypothetical student database. One of the rules of the database is that for a student to be classified as a junior, they must have completed between 55 and 84 credit hours (inclusive).

I need to create an integrity constraint to enforce this rule but am not entirely sure how to go about doing it. I have a feeling that a CHECK constraint would be useful in this situation.

So far I have…

CONSTRAINT IC4 CHECK (hours >=55 AND hours <= 84), 

This code is valid, however it does not determine if the student record is a junior.

The set up of my table is…

    CREATE TABLE  Students ( id                INTEGER, 
                             name              CHAR(10)    NOT NULL,  
                             classification    CHAR(10)    NOT NULL, 
                             hours             INTEGER, 
                             gpa               NUMBER(3,2) NOT NULL, 
                             mentor            INTEGER); 

So if we try to insert…

INSERT INTO Students VALUES (50, 'Kim', 'junior', 34, 3.5, 40);  

…the integrity constraint would be violated because the record is trying to be stored as a ‘junior’ but the student has only completed 34 hours.

How would I go about writing a constraint which would enforce these rules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:53:38+00:00Added an answer on June 18, 2026 at 4:53 am

    You need to use the magic word and again:

    CREATE TABLE students (
    ....
     , CONSTRAINT IC4 CHECK ( classification = 'junior' AND hours >=55 AND hours <= 84 ) 
    

    I suspect you’ll want to have other classifications too, and validate their ranges. Use parentheses and OR to do this. (And use BETWEEN to define the ranges for clarity)….

    , CONSTRAINT IC4 CHECK ( ( classification = 'junior' AND hours BETWEEN 55 AND 84 ) 
                           OR ( classification = 'sophomore' AND hours BETWEEN 85 AND 124 )  
                           OR ( classification = 'senior' AND hours > 124 )  
                           OR ( classification = 'fresher' )
                           )                                 
    

    Make sure you have a complete set of ranges.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a table containing several rows, each with a button
I am trying to make some changes to an oracle database and have a
<table> <tr> <td>One</td> <td>Two</td> <td class=skinny>$$</td> <td>Four</td> </tr> </table> I'm trying to make all
I'm trying to make table rows collapse if they contain no data. The rows
I am trying to make a table cell that when tapped calls a phone
I am trying to make a schedule table that would delete certain rows according
I'm trying to make a truth-table generator for a digital electronics course because that's
I am currently trying to make a sectioned table like this: Section 1: Entry
I am trying to make a contacts table in SQLite. When i commit the
I am trying to make a pivot table with rollup and a case statement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.