•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,662 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,838 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 457 | Replies: 2 | Solved
![]() |
•
•
Join Date: Apr 2006
Posts: 62
Reputation:
Rep Power: 3
Solved Threads: 0
Hi,
I can create all tables but order table. What is wrong, is it foreign key?
Thanks
I can create all tables but order table. What is wrong, is it foreign key?
sql Syntax (Toggle Plain Text)
CREATE TABLE customer( customerId INT(10) NOT NULL AUTO_INCREMENT, customerName VARCHAR(10), customerSurname VARCHAR(10), customerAddress VARCHAR(10), PRIMARY KEY (customerId)); CREATE TABLE ORDER( orderId INT(10) NOT NULL AUTO_INCREMENT, customerId INT(10), PRIMARY KEY (orderId), FOREIGN KEY (customerId) REFERENCES customer(customerId)); CREATE TABLE orderDetail( orderDate DATE, orderId INT(10), productId INT(10), FOREIGN KEY (orderId) REFERENCES ORDER(orderId), FOREIGN KEY (productId) REFERENCES product(productId)); CREATE TABLE product( productId INT(10) NOT NULL AUTO_INCREMENT, productName VARCHAR(10), PRIMARY KEY (productId)); CREATE TABLE stock( stock INT(10), productId INT(10), FOREIGN KEY (productId) REFERENCES product(productId));
Thanks
Last edited by peter_budo : Apr 1st, 2008 at 7:06 am. Reason: Keep It Organized - please use [code] tags
"order" is a reserved word so you need to quote it if you're going to use it for a table name. See here for details.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- Foreign Keys (MySQL)
- DB Design, trying to keep in sync without foreign-keys (Database Design)
- Varchar field as foreign reference (MySQL)
- Multiple Tables in a Database (Visual Basic 4 / 5 / 6)
- Multi-threading with C++.NET (C++)
- Assigning Foreign Keys (Database Design)
- mySQL foreign keys (MySQL)
- Primary Key Issue (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: ip blocker db problem
- Next Thread: Table aready exists


Linear Mode