Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
create database clothingstore;
create table customer(
CMobile_no       int ,
Customer_id       int,
Customer_Address  varchar(20),

constraint customer_pk
primary key (Customer_id),

);
create table customer_Name(

Fname        varchar(20),
Minit        varchar(20),
Lname        varchar(20),
Customer_id    int,
constraint customer_name_pk
primary key (Customer_id),

);
create table Branch(
Branch_id   int,     
Branch_Name  varchar(20),
Branch_Location  varchar(20),
Branch_Address   varchar(20),

constraint Branch_pk
primary key (Branch_id),

);

create table Buysfrom(
Cid int
  
  Bid int

 Hrs  int
 CONSTRAINT buys_pk
 primary key (Cid,Bid)

 Constraint customer_Buys_pk
 foreign key (Cid) references customer(Customer_id)
 constraint Branch_Buys_fk
 foreign key (Bid)references Branch(Branch_id)


);


What I have tried:

tried to change the word speeling
Posted
Updated 1-Dec-22 11:48am
Comments
Dave Kreskowiak 30-Nov-22 19:42pm    
What's the SQL server you're using and the error message?
Noran Azab 1-Dec-22 17:17pm    
microsoft sql server managment studio 18 ..........syntax error
Dave Kreskowiak 1-Dec-22 17:38pm    
First, it's SQL Server.

As fo the error message, for future reference, ALWAYS copy and paste the entire error message in your questions.

Commas separate items:
SQL
create table Buysfrom(
Cid int
  
  Bid int

 Hrs  int
 CONSTRAINT buys_pk
 primary key (Cid,Bid)

 Constraint customer_Buys_pk
 foreign key (Cid) references customer(Customer_id)
 constraint Branch_Buys_fk
 foreign key (Bid)references Branch(Branch_id)


);
You don't have any in the final table definition.
 
Share this answer
 
Like Griff said, you're missing commas seperating field definitions. It also helps to indent your code properly and capitalize SQL keywords to make it easier to read:
SQL
CREATE TABLE Buysfrom (
    Cid int,
    Bid int,
    Hrs int,

 CONSTRAINT buys_PK PRIMARY KEY (Cid, Bid),

 CONSTRAINT customer_Buys_PK FOREIGN KEY (Cid) REFERENCES customer (Customer_id),

 CONSTRAINT Branch_Buys_FK FOREIGN KEY (Bid) REFERENCES Branch (Branch_id)
);
 
Share this answer
 
Comments
Noran Azab 2-Dec-22 5:48am    
it works .Thanks in advance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900