Menu

Post image 1
Post image 2
1 / 2
0

Part 08: Designing Tables, Data Types and Constraints

DEV Community: sql·Mohamed Idris·3 days ago
#H8OmWGf5
#dev#fullscreen#table#database#null#article
Reading 0:00
15s threshold

Part of the "SQL: Zero to Ninja" series, for junior web devs who want SQL to finally click. Up to now, the tables already existed. You just queried them. But who decided that price holds numbers and email holds text? Who made sure two users can never share the same email? That was the person who designed the table . Today that person is you. The idea in one line CREATE TABLE builds a table, data types say what kind of thing each column holds, and constraints are rules the database promises to enforce so bad data can never sneak in. The metaphor: a table is a sign-up form Think of a table definition like a good sign-up form on a website. Each field has the right input type . The birthday field is a date picker, not a free text box where someone types "next Tuesday". Some fields are required . You cannot submit without an email. Some fields must be unique . You cannot sign up with an email someone already used. Some fields have a default . If you leave "newsletter" alone, it is set for you.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More