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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:33:41+00:00 2026-05-10T19:33:41+00:00

I have been slowly learning SQL the last few weeks. I’ve picked up all

  • 0

I have been slowly learning SQL the last few weeks. I’ve picked up all of the relational algebra and the basics of how relational databases work. What I’m trying to do now is learn how it’s implemented.

A stumbling block I’ve come across in this, is foreign keys in MySQL. I can’t seem to find much about the other than that they exist in the InnoDB storage schema that MySQL has.

What is a simple example of foreign keys implemented in MySQL?

Here’s part of a schema I wrote that doesn’t seem to be working if you would rather point out my flaw than show me a working example.

CREATE TABLE `posts` ( `pID` bigint(20) NOT NULL auto_increment, `content` text NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `uID` bigint(20) NOT NULL, `wikiptr` bigint(20) default NULL, `cID` bigint(20) NOT NULL, PRIMARY KEY  (`pID`), Foreign Key(`cID`) references categories, Foreign Key(`uID`) references users ) ENGINE=InnoDB; 
  • 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. 2026-05-10T19:33:41+00:00Added an answer on May 10, 2026 at 7:33 pm

    Assuming your categories and users table already exist and contain cID and uID respectively as primary keys, this should work:

    CREATE TABLE `posts` ( `pID` bigint(20) NOT NULL auto_increment, `content` text NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `uID` bigint(20) NOT NULL, `wikiptr` bigint(20) default NULL, `cID` bigint(20) NOT NULL, PRIMARY KEY  (`pID`), Foreign Key(`cID`) references categories(`cID`), Foreign Key(`uID`) references users(`uID`) ) ENGINE=InnoDB; 

    The column name is required in the references clause.

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

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See http://books.google.com/books?id=ns1WMyLVnRMC&pg=PA232&lpg=PA232&dq=win32com+%22python.interpreter%22&source=bl&ots=NVpe-E8eGg&sig=imGi73WQyOmP4rJC6-jpz4stb9M&hl=en&ei=xrAYSsTHBZH0tAORqeCSDw&sa=X&oi=book_result&ct=result&resnum=6#PPA232,M1 for excellent docs on python.interpreter -- as for… May 11, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer This can be done using the PIVOT function. I'll try… May 11, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer Actually you can do it using CallByName CallByName Me, Me.Controls(varV).Name… May 11, 2026 at 6:30 pm

Related Questions

I have been slowly learning SQL the last few weeks. I've picked up all
I'm slowly learning SQL and how to use form builder 6. The situation is
In the past I've worked with -Wall and other switches for gcc to eliminate
I've been working in Silverlight recently and I've slowly been discovering that as simple
I've been slowly working on a personnel project to run a webmud like game

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.