What is an ER diagram used for?+
ER diagrams model the entities (tables) in a database, their attributes (columns), and the relationships between them. They're used to plan database schemas before writing any SQL, communicate data models to stakeholders, and document existing databases.
What is cardinality in ER diagrams?+
Cardinality describes how many instances of one entity relate to instances of another. One-to-one (1:1): a person has one passport. One-to-many (1:N): a customer places many orders. Many-to-many (M:N): students enrol in many courses, courses have many students.
What is the difference between a primary key and a foreign key?+
A primary key uniquely identifies each row in a table. A foreign key is a column that references the primary key of another table, creating the link between tables.
How do I convert an ER diagram to SQL?+
Click 'Generate SQL'. Each entity becomes a CREATE TABLE statement. Primary keys get PRIMARY KEY constraints. Foreign key relationships become FOREIGN KEY...REFERENCES constraints. Many-to-many relationships create a junction table.