From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating relationships in SQL Server Management Studio - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
Creating relationships in SQL Server Management Studio
I am going to go ahead and describe a one-to- many relationship between two of my own tables. So I have two very-very simple tables here. I have a product table, which has a few products in it right now. It's got a ProductID as the unique key, the primary key for this. That's automatically incrementing, ranging from roughly 1000 through 1013 right now, and I also have an OrderItem table. This itself has its own primary key, OrderItemID, that I don't really care about, but it's got a place for a ProductID and this is going to become the foreign key. I'd like to be able to create multiple order items for each product so that ProductID 1001 can be used several times if I deem it necessary. That means our many-to-one relationship is one product, many order items. So how do I make it? Well I am going to close down these tables. There are a couple of different ways I can do this. One way would be to go to the Database Diagrams area, add a new satabase diagram, grab the two tables that I'm…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Planning your database9m 39s
-
(Locked)
Creating a SQL Server database4m 7s
-
(Locked)
Creating tables7m 50s
-
Data types in SQL Server12m 25s
-
(Locked)
Defining keys8m 9s
-
(Locked)
Creating default values4m 39s
-
(Locked)
Creating check constraints2m 25s
-
(Locked)
Creating unique constraints4m 34s
-
Introduction to relationships and foreign keys9m 51s
-
(Locked)
Creating relationships in SQL Server Management Studio8m 14s
-
(Locked)
Database normalization11m 47s
-
(Locked)
Creating computed columns3m 10s
-
-
-
-
-
-
-
-
-
-
-
-