Mostafa_
جمعه 18 دی 1394, 20:04 عصر
سلام به همه دوستان
من برای یه وب سایت این این دیتابیس رو درست کردم حالا میخوام ارتباط بین جدول ها رو درست کنم
میشه راهنمایی کنین باید چکار کنم و چه دستوری رو استفاده کنم
میخوام جدول های users و user info باهم اتباط داشته باشن
و User_info با User_Address ارتباط داشته باشن
ممنون
create table Users
(
ID int not null,
Username nvarchar(30) primary key not null,
password nvarchar(30),
User_type int,
)
create table user_info
(
ID int not null,
F_Name nvarchar(25),
L_Name nvarchar(25),
Sex int,
Email_address nvarchar(40) primary key not null,
)
create table User_address
(
id int not null,
address nvarchar(max),
postal_code int,
Sity nvarchar(40),
sttyTown nvarchar(45),
username nvarchar(30) FOREIGN KEY REFERENCES Users(Username)
)
create table options
(
id int,
)
create table library
(
id int not null,
Lib_book_title nvarchar(max),
lib_Book_owner nvarchar(50),
Lib_Book_text nvarchar(max),
lib_boox_address nvarchar(max)
)
create table shop
(
ID int,
)
create table Advertising
(
ID int,
)
create table about
(
ID int,
about_title nvarchar(50),
about_text nvarchar(max)
)
create table comment
(
ID int,
)
من برای یه وب سایت این این دیتابیس رو درست کردم حالا میخوام ارتباط بین جدول ها رو درست کنم
میشه راهنمایی کنین باید چکار کنم و چه دستوری رو استفاده کنم
میخوام جدول های users و user info باهم اتباط داشته باشن
و User_info با User_Address ارتباط داشته باشن
ممنون
create table Users
(
ID int not null,
Username nvarchar(30) primary key not null,
password nvarchar(30),
User_type int,
)
create table user_info
(
ID int not null,
F_Name nvarchar(25),
L_Name nvarchar(25),
Sex int,
Email_address nvarchar(40) primary key not null,
)
create table User_address
(
id int not null,
address nvarchar(max),
postal_code int,
Sity nvarchar(40),
sttyTown nvarchar(45),
username nvarchar(30) FOREIGN KEY REFERENCES Users(Username)
)
create table options
(
id int,
)
create table library
(
id int not null,
Lib_book_title nvarchar(max),
lib_Book_owner nvarchar(50),
Lib_Book_text nvarchar(max),
lib_boox_address nvarchar(max)
)
create table shop
(
ID int,
)
create table Advertising
(
ID int,
)
create table about
(
ID int,
about_title nvarchar(50),
about_text nvarchar(max)
)
create table comment
(
ID int,
)