From the course: Database Foundations: Data Structures
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Alter a table's design
From the course: Database Foundations: Data Structures
Solution: Alter a table's design
(upbeat bright music) - [Instructor] In this challenge, we're given a table that maintains a record of creative projects at a graphic design agency. But this table has a fatal flaw and it's that it doesn't have a primary key. And so our task is to add a surrogate key to this table that'll automatically add a value for every record that's added into the table. So we can get started just by running the select statement. We're just going to select all of the original columns that we have from the design projects table. I'll test my code here to see what we're starting with. So we have a column called PROJECTNAME, CLIENTNAME. We have a CONTACTEMAIL, PROJECTSTARTDATE, PROJECTENDDATE, and the BUDGET. And so you can see there is no primary key for this table. It's a potential that we could have two projects with the same client name, and in fact we actually do, we could also have two projects with the same name if they're the same type of activity, like they have two different rebranding…
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
-
-
-
-
-
(Locked)
Purpose of a primary key3m 55s
-
Establish the table's primary key6m 59s
-
Natural keys2m 42s
-
(Locked)
Composite keys5m 33s
-
(Locked)
Surrogate keys4m 40s
-
(Locked)
Challenge: Add a primary key to a table53s
-
(Locked)
Solution: Add a primary key to a table5m 51s
-
(Locked)
Solution: Alter a table's design6m 39s
-
(Locked)
-
-
-
-
-