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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:32:12+00:00 2026-06-07T22:32:12+00:00

I create different tables in a database system .. now I need to make

  • 0

I create different tables in a database system .. now I need to make a relationship between them I mean the primary key in one table should be connected to a foreign key in another table.. Should I do that when I create the table itself or it they will be connected together when I insert the data and they they are identical?

For example I do the following when I create two tables:

CREATE TABLE employee (
  fname    varchar(15),
  minit    varchar(1),
  lname    varchar(15),
  ssn      char(9),
  bdate    date,
  address  varchar(50),
  sex      char,
  salary   decimal(10,2),
  superssn char(9),
  dno      number(4)
);

CREATE TABLE department (
  dname        varchar(25),
  dnumber      number(4),
  mgrssn       char(9), 
  mgrstartdate date
);

Here the dno should be connected to the dnumber while the ssn should be connected to the mgrssn.

  • 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-07T22:32:14+00:00Added an answer on June 7, 2026 at 10:32 pm

    Adding the data doesn’t do anything special to the constraints on the tables, how is your db going to know that the values are identical? They might look the same but have different meanings in different places.

    If your table declaration includes a foreign key reference to your other table then that’s all that there is to it.

    If not (and I don’t see one in your example) then you should add one in order to maintain referential integrity.

    You could add constraints after you’ve added data, but if any data is not valid (like nulls in your foreign key field) then you won’t be able to add the constraint.

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

Sidebar

Related Questions

I'm trying to create a database with 12 different tables which has been working
I have many tables with identical schemas but different names. Can I create a
I need to create a table in MySQL which stores the different currency symbols
I want to store the distance between different locations in a table. CREATE TABLE
I have a really ugly legacy database system that I need to integrate with.
I'm creating a tag system for website with PHP. I created 3 tables: one
I'm trying to create a system in Python in which one can select a
How do I backup a MySQL database using just queries? I mean, PHP's system()
Hi i'm trying to create a league table in which i have several different
My application has multiple SQLite tables(around 20 with different fields). This I have created

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.