Created
August 4, 2022 18:44
-
-
Save thomasthaddeus/85ac2ff4bca346928610743f3945180a to your computer and use it in GitHub Desktop.
Key Validation for DB design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE book ( | |
title varchar(100), | |
isbn varchar(50) PRIMARY KEY, | |
pages integer, | |
price money, | |
description varchar(256), | |
publisher varchar(100) | |
); | |
CREATE TABLE chapter ( | |
id integer PRIMARY KEY, | |
number integer, | |
title varchar(50), | |
content varchar(1024) | |
); | |
CREATE TABLE author ( | |
name varchar(50), | |
bio varchar(100), | |
email varchar(20) PRIMARY KEY | |
); | |
SELECT | |
constraint_name, table_name, column_name | |
FROM | |
information_schema.key_column_usage | |
WHERE | |
table_name = 'book'; | |
SELECT | |
constraint_name, table_name, column_name | |
FROM | |
information_schema.key_column_usage | |
WHERE | |
table_name = 'chapter'; | |
SELECT | |
constraint_name, table_name, column_name | |
FROM | |
information_schema.key_column_usage | |
WHERE | |
table_name = 'author'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment