concatenated keys in Sybase SQLANYwhere

Posted on 1998-03-17
Last Modified: 2008-03-10
CREATE TABLE emp_skill(
"skill level" INTEGER NOT NULL,
PRIMARY KEY( emp_id, skill_id ),
how does a "concatenated" key work in the above example? if you want to link to it from another table -- u have gotta have a 'concatenated' key there too? u obviously can't join to the above table if u got only emp-id..

if i use SQLCentral i can't get to see/define if the combination of both is unique or not.

if this concatenated key is a foreign key somewhere else - how is it implemented?
Question by:hunchback
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

jbiswas earned 50 total points
ID: 1098366
The proper term for a primary key consisting of two or more fields is a composite key. I assume we are talking about the same thing. When you set something as a primary key it has to be unique. So by default it will not allow any duplicate values. In isql you can do a duplicate check(which you will not find in case of a primary key) with a queruy of the following format:
select count(*), field_name1, field_name2 from table_name group by field_name1, field_name2 having count(*)>1
To make this a foreign key for some table, that table should have these two fields and under that table , go to foreign key, add foreign key and when it asks for the talename and column_names, give the appropriate table name and the name of the two columns. That should make this composite key a foreign key.

Author Comment

ID: 1098367
thanks very much ,Jbiswas, if u can made a comment:
when we have 2 fields like above example: is it normal/necessary in the sybaseDB realm or from your experience to create an additional/new  field call EmpSkillID (size=both fields added up)
and call a trigger to add both fields (empID, skillID) in order to define the value. Also making EmpSkillID the primary key.

Expert Comment

ID: 1098368
Nope you do not have to do that. A composite key works just fine. The data is stored as per the composite key, so it doesn't make any sense to concatenate the two fields.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle Global Constant Without A Package 2 722
Sybase SQL Syntax 2 289
Reading ASE Optimizer trace flag / switch output 4 602
SQL Query Syntax 12 103
Read the original post on Monitis Blog. Believe it or not, the most important thing about the website of your business is not what’s on it but how fast it loads. Yes, that’s right!    As you can see on this infographic (an oldie but goodie!), …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question