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

  • SEARCH
  • Home
  • 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 8996871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:48:44+00:00 2026-06-15T23:48:44+00:00

I’m having a problem in an oracle SQL project I’m working on: I have

  • 0

I’m having a problem in an oracle SQL project I’m working on:

I have a (weak) entity ‘Ticket’ that has as primary key: (Customer_id,packet_id,project_id,ticket_id). Customer_id, packet_id and project_id are also foreign keys.

But, a ticket can only be for a packet OR a project, and because they are both in the primary key, they can’t be null, while one of them actually will always be null. But I need both because a ticket always belongs to a one of them.

I thought of a possible solution and I thought I could make 1 ID for all products, but then there is another problem, because if I want to implement this product_id as a foreign key, I don’t know to which entity I should let it reference to.

Is there a way to make ‘optional primary keys’ or work with if-statements when creating tables? Or a way to make an optional reference? I’ve tried if-statements and a case but it didn’t work.

  • 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-15T23:48:45+00:00Added an answer on June 15, 2026 at 11:48 pm

    A lot will depend on exactly what these entities represent. Since a ticket can be for either a packet or a project, that implies that there is some higher-level entity that combines both packets and projects. That could either be modeled as a new table that is the parent to both PACKET and PROJECT or it could be modeled by combining the PACKET and PROJECT table and adding a TYPE column that differentiates between packets and projects. The TICKET table would then reference either the new parent table or the combined table.

    Taking a step back, though, if the TICKET entity has a TICKET_ID, it seems likely that the TICKET_ID alone should be the primary key. It seems unusual that you would have a composite primary key if you have a TICKET_ID column– do you really want to allow multiple rows in the TICKET table with the same TICKET_ID that are related to different customers, packets, and projects? If TICKET_ID alone is the primary key, then both PACKET_ID and PROJECT_ID can be nullable foreign keys and you can create a CHECK constraint that ensures that exactly one of the two is non-NULL.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I have an array which has BIG numbers and small numbers in it. I
I have been unable to fix a problem with Java Unicode and encoding. The
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.