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 6571801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:55:39+00:00 2026-05-25T14:55:39+00:00

I am relatively new to database design. I have a database which has the

  • 0

I am relatively new to database design. I have a database which has the following design

I have specified the the tables in SQL as follows.

CREATE TABLE Piece
(identifier INT NOT NULL Unique,
 value      INT NOT NULL,
 the date it was acquited DATE,
 the date it was made DATE,
 PRIMARY KEY (identifier));

CREATE TABLE Person
(name VARCHAR(50),
 person_id INT NOT NULL Unique,
 biography VARCHAR (50),
 date of birth DATE,
 date of death DATE,
 PRIMARY KEY (person_id));

CREATE TABLE Jewel
(code INT NOT NULL Unique,
 gem type VARCHAR (50),
 weight INT,
 quality VARCHAR (50),
 color VARCHAR (50),
 description VARCHAR (50),
 PRIMARY KEY (code));

CREATE TABLE Gem
(type VARCHAR (50) NOT NULL,
 hardness INT,
 density  INT,
 FOREIGN KEY (type) references JEWEL(gem type));

CREATE TABLE Ownership
(person VARCHAR (50),
 piece  INT,
 start of ownership DATE,
 end of ownership   DATE,
 FOREIGN KEY (person) references PERSON(person_id),
 FOREIGN KEY (piece) references PIECE(identifier)); 

My question is

1.) How can I specify a primary key to the GEM table as all the 3 attributes are not unique, should I have to create a new attribute like Gem_id, as I would prefer to use the existing attributes and not add a new attribute.

2.) I have used person_id attribute in the person table to make it unique and use it as a primary key, is there another way to create a primary key for the person table without adding the extra attribute and obviously I cant include constraints to the existing attribute and make it UNIQUE

3.) Is all integrity constraints and data types right ? Is my design flawed in any way.

  • 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-05-25T14:55:39+00:00Added an answer on May 25, 2026 at 2:55 pm

    1) Yes you can create a multi column primary key (composite primary key) but it will be unique. Something like this should do it:

    CREATE TABLE Gem
    (type VARCHAR (50) NOT NULL,
     hardness INT,
     density  INT,
     PRIMARY KEY (type , hardness, density ),
     FOREIGN KEY (type) references JEWEL(gem type));
    

    2) There are other ways to create a primary key for the Person table but I would not recommend it. Person_id is what I would use here.

    3) I would make the following changes to your design:

    • Make Person in the ownership table an int rather than a VARCHAR. If it’s a foreign key to person_id, then you don’t want it to be a VARCHAR.
    • Add an int identifier to the Gem table. GemTypeId or something.
    • In the jewel table, replace the gem type column with your new GemTypeId column.

    There might be more, but these were the ones that jumped out at me.

    It seems like you are trying not to use IDs to represent your data. Is there a reason for this? If you continue down this road you may run into data integrity issues.

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

Sidebar

Related Questions

I am relatively new to columnar database, please forgive ignorance. Lets say I have
As this question is sure to reveal, I'm relatively new to database design. Please
I am relatively new to Perl.I have been trying to insert data to database
Being relatively new to the .net game, I was wondering, has anyone had any
I'm relatively new to Nant, what i'd like to do is have a task
I am relatively new to .Net and the database side of it in particular.
I am relatively new to programming with PHP. I have created a simple Javascript
I am relatively new to php and have a feeling that I am going
I am relatively new to SQL Server so I hope you can help. Basically
I am relatively new to MySQL and PHP and I have been trying to

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.