الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مساعدة(خطأ في تكوين جدول في Error 150...phpmyadmin )؟

بدأه nasyia في 4 مايو 2014 · 4 رد · 808 مشاهدة · في قواعد بيانات MySQL
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم


ممكن المساعدة في جدوال قاعدة بيانات حيث يصادفني خطأ (150) في تكوين احد الجدوال ولا اعرف ماهو وهذه هي جدوال القاعدة كالاتي:-


قاعدة لدليل هاتف


Create table city(

City_no  int (5) ,

City_name varchar(100) not null,

Constraint primary key (city_no));

Create table city(

City_no  int (5) ,

City_name varchar(100) not null,

Constraint primary key (city_no));

Create table costumer(

Co_id  int (10),

Co_name varchar(100) not null,

co_city_no int(5),

Constraint foreign key (co_city_no) references city (city_no));

Create table company(

Com_id int (3),

Com_name varchar(50) not null,

Constraint primary key (com_id));

Create table contract(

Con_id int (10),

Con_com_id int(3) not null,

Con_co_id int(10) not null,

Con_phoneNo int(15) not null,

Constraint primary key (con_id),

Constraint foreign key  (con_com_id) references company(com_id),

Constraint foreign key (con_co_id) references costumer (co_id) );

#2

السلام عليكم،

 

قمت بتصحيح الكود وتغيير اسماء الجداول ايضا:

-- create city table 
CREATE TABLE city(
    city_id  int (5) ,
    city_name VARCHAR(100) NOT NULL,
    CONSTRAINT PRIMARY KEY (city_id)
);


-- create customer table 
CREATE TABLE customer(
    customer_id  INT(10),
    customer_name VARCHAR(100) NOT NULL,
    customer_city_id INT(5),
    CONSTRAINT FOREIGN KEY (customer_city_id) REFERENCES city (city_id),
    CONSTRAINT PRIMARY KEY (customer_id)
);


-- create company table 
CREATE TABLE company(
    company_id int(3),
    company_name varchar(50) not null,
    CONSTRAINT PRIMARY KEY (company_id)
);


-- create contract table 
CREATE TABLE contract(
    contract_id INT (10),
    contract_company_id INT(3) NOT NULL,
    contract_customer_id INT(10) NOT NULL,
    contract_phoneNo INT(15) NOT NULL,
    CONSTRAINT PRIMARY KEY (contract_id),
    CONSTRAINT FOREIGN KEY (contract_company_id) REFERENCES company (company_id),
    CONSTRAINT FOREIGN KEY (contract_customer_id) REFERENCES customer (customer_id)
);

post-49504-0-75510300-1399311995_thumb.p

#3

مشكور اخي الكريم وبارك الله فيك اشتغلت القاعدة بس ممكن ان تدلني علي موضع الخطأ حتي لا اقع فيه مرة اخرى


#4

السلام عليكم،

 

الخطأ اﻷول: تكرار عملية بناء نفس الجدول في:

Create table city(
City_no  int (5) ,
City_name varchar(100) not null,
Constraint primary key (city_no));
Create table city(
City_no  int (5) ,
City_name varchar(100) not null,
Constraint primary key (city_no));

الخطأ الثاني: خلط استعمال الحروف الكبيرة الصغيرة والكبيرة

Co_nameco_name

انصح استعمال الحروف الصغيرة في كل الاسماء الجداول والحقول

 

الخطأ الثالث: عدم اضافة مفتاح اساسي Primary key للجدول costumer

تم تعديل هذه المشاركة بواسطة choclatboy في 6 مايو 2014 في 02:53

#5
choclatboy كتب:

السلام عليكم،

 

الخطأ اﻷول: تكرار عملية بناء نفس الجدول في:

Create table city(
City_no  int (5) ,
City_name varchar(100) not null,
Constraint primary key (city_no));
Create table city(
City_no  int (5) ,
City_name varchar(100) not null,
Constraint primary key (city_no));

الخطأ الثاني: خلط استعمال الحروف الكبيرة الصغيرة والكبيرة

Co_nameco_name

انصح استعمال الحروف الصغيرة في كل الاسماء الجداول والحقول

 

الخطأ الثالث: عدم اضافة مفتاح اساسي Primary key للجدول costumer

مشكور اخي الكريم وبارك الله فيك

مواضيع مشابهة