DBMS abstracts programmer (application programs) from physical files
MEMBERS( MemberId, GivenName, FamilyName, BandName ) BANDS( BandName, AgentId) Agents( AgentId, Name, ContactName, Telephone)
*(refer to p.162 for example)
ER Symbols
Entity
Cardinality
zero
one
many
Cardinality with minimum
One and only one
Many (at least one)
Many (can be zero)
Many (must be 2 or more)
At most one
Following slides extracted from: https://www.1keydata.com/database-normalization
1NF
Unnormalised
1NF only
2NF
2NF only
3NF
CREATE DATABASE BandBooking;
CREATE TABLE Members ( MemberID VARCHAR(10), Name VARCHAR(50), BandName VARCHAR(30) );
ALTER TABLE Members ADD Age INTEGER;
-- This is comment -- primary key ALTER TABLE Members ADD PRIMARY KEY (MemberID); -- Foreign key, Note Band table must be created ALTER TABLE Members ADD FOREIGN KEY (BandName REFERENCES Band(BandName);
ALTER TABLE Members DELETE Age;
INSERT INTO Members(MemberId, Name, BandName) VALUES ( '123456', 'John Lennon', 'Beatles');
SELECT * FROM Members WHERE BandName = 'Beatles' ORDER BY Name
-- Note about the use of WHERE UPDATE Members SET MemberId='jl1234' WHERE Name='John Lennon'; DELETE FROM Members WHERE Name='Justin Bieber';