SlideShare a Scribd company logo
Introduction to Database Systems
Lecture 2: Data Models & SQL
(Ch. 2.1-2.3)
1
2
Data Models
• language / notation for talking about data
• models we will use:
– relational: data is a collection of tables
– semi-structured: data is a tree
• other models:
– key-value pairs: used by NoSQL systems
– graph data model: used by RDF (semi-structured can also do)
– object oriented: often layered on relational, J2EE
Relational Model
• Data is a collection of relations / tables:
• mathematically, relation is a set of tuples
– each tuple appears 0 or 1 times in the table
– order of the rows is unspecified
Name Country Employees For_Profit
GizmoWorks USA 20000 True
Canon Japan 50000 True
Hitachi Japan 30000 True
HappyCam Canada 500 False
columns /
attributes /
fields
rows /
tuples /
records
3
4
Relational Schema
• Each column has a “domain” (or type)
– SQL has Java-like types for numbers, strings, etc.
– domain is a constraint on the data allowed in the table
• Names and types part of the “schema” of the table:
Company(Name: string, Country: string,
Employees: int, For_Profit: boolean)
• Particular data is an “instance” of that relation
– data changes over time
– DBMS usually just stores the current instance
5
Keys
• Key = subset of columns that uniquely identifies tuple
• Another constraint on the table
– no two tuples can have the same values for those columns
• Examples:
– Movie(title, year, length, genre): key is (title, year)
– what is a good key for Company?
• Part of the schema (book notation is underline):
Company(Name: string, Country: string,
Employees: int, For_Profit: boolean)
6
Keys (cont.)
• Can have multiple keys for a table
• Only one of those keys may be “primary”
– DBMS often makes searches by primary key fastest
– other keys are called “secondary”
• “Foreign key” is a column (or columns) whose value
is a key of another table
– i.e., a reference to another row in another table
7
SQL (“sequel”)
• Standard query language for relational data
– used for databases in many different contexts
– inspires query languages for non-relational (e.g. SQL++)
• Everything not in quotes (‘…’) is case insensitive
• Provides standard types. Examples:
– numbers: INT, FLOAT, DECIMAL(p,s)
• DECIMAL(p,s): Exact numerical, precision p, scale s. Example:
decimal(5,2) is a number that has 3 digits before the decimal
and 2 digits after the decimal
– strings: CHAR(n), VARCHAR(n)
• CHAR(n): Fixed-length n
• VARCHAR(n): Variable length. Maximum length n
8
SQL (“sequel”) – Cont.
• Provides standard types. Examples:
– BOOLEAN
– DATE, TIME, TIMESTAMP
• DATE: Stores year, month, and day values
• TIME: Stores hour, minute, and second values
• TIMESTAMP: Stores year, month, day, hour, minute, and
second values
• Additional types differ by vendor:
– SQLite: http://www.sqlite.org/datatype3.html
9
SQL statements
• create table …
• drop table ...
• alter table ... add/remove ...
• insert into ... values ...
• delete from ... where ...
• update ... set ... where ...
• select … from … where
10
create table …
CREATE TABLE Company(
name VARCHAR(20) PRIMARY KEY,
country VARCHAR(20),
employees INT,
for_profit CHAR(1));
11
Multi-column Keys
• This makes name a key:
CREATE TABLE Company(
name VARCHAR(20) PRIMARY KEY,
country VARCHAR(20),
employees INT,
for_profit BOOLEAN);
• How can we make a key on name & country?
Multi-column Keys
• Syntax change if a primary key has multiple columns:
CREATE TABLE Company(
name VARCHAR(20) PRIMARY KEY,
country VARCHAR(20),
employees INT,
for_profit BOOLEAN,
PRIMARY KEY (name, country));
goes away
added
12
Multi-column Keys (2)
• Likewise for secondary keys:
CREATE TABLE Company( name VARCHAR(20)
UNIQUE,
country VARCHAR(20),
employees INT,
for_profit BOOLEAN,
UNIQUE (name, country));
goes away
added
13
Multi-column Keys (3)
• This makes manufacturer a foreign key:
CREATE TABLE Product(
name VARCHAR(20),
price DECIMAL(10,2),
manufacturer VARCHAR(20)
REFERENCES Company(name));
good idea to include
target column name
14
Multi-column Keys (3)
• Similar syntax for foreign keys:
CREATE TABLE Product(
name VARCHAR(20),
price DECIMAL(10,2),
manu_name VARCHAR(20),
manu_co VARCHAR(20),
FOREIGN KEY (manu_name, manu_co)
REFERENCES Company(name, country));
now need both
name & country
added
15
16
UNIQUE
• PRIMARY KEY adds implicit “NOT NULL” constraint
while UNIQUE does not
– you would have to add this explicitly for UNIQUE:
CREATE TABLE Company(
name VARCHAR(20) NOT NULL, …
UNIQUE (name));
• You almost always want to do this (in real schemas)
– SQL Server behaves strangely with NULL & UNIQUE
– otherwise, think through NULL for every query
– you can remove the NOT NULL constraint later
17
drop table ...
DROP TABLE Company;
18
alter table ... add/remove ...
ALTER TABLE Company
ADD CEO VARCHAR(20);
19
insert into ... values ...
INSERT INTO Company VALUES
('GizmoWorks', 'USA', 20000, 'y');
20
One Way to Input Data
• Write a program that outputs SQL statements:
for (int a = 1; a <= 50; a++)
for (int b = 1; b <= 50; b++)
System.out.format(
“INSERT INTO T VALUES (%d,%d);n“,
a, b);
• Feed those into SQLite:
sqlite3 foo.db < inputs.sql
21
Demo: MakeTriples.java
Warning
• Be very careful when doing this with strings:
System.out.format(
”INSERT INTO T2 VALUES (%d, ‘%s’);”,
3, ”O’Shaughnessy”);
Becomes:
INSERT INTO T2 VALUES (3, ‘O’Shaughnessy’);
which is a syntax error in this case
22
https://xkcd.com/327/
23
24
Warning (cont)
• Be very careful when doing this with strings:
System.out.format(
”INSERT INTO T VALUES (%d, ‘%s’);”,
3, ”O’Shaughnessy”);
• This allows a SQL injection attack!
– Must check for quotes and escape (or disallow) them.
– We’ll see safer ways to do this using JDBC
• DBMSs usually have faster ways to input data
– SQLite has .import (try with .mode csv)
25
delete from ... where ...
DELETE FROM Company
where name = 'GizmoWorks';
26
update ... set ... where ...
UPDATE Company
SET employees = employees + 120
where name = 'GizmoWorks';
27
select ... from ... where ...
SELECT * FROM Company
where name = 'GizmoWorks';
28
DISTINCT and ORDER BY
• Query results do not have to be relations
– i.e., they can have duplicate rows
– remove them using DISTINCT
• Result order is normally unspecified
– choose an order using ORDER BY
– e.g., ORDER BY country, cname
– e.g., ORDER BY price ASC, pname DESC
• Examples in lec03-sql-basics.sql
29
Demo on Sqlite
• E.g., type sqlite3 in Cygwin
• .exit - exit from sqlite3
30
SQLite Uses
• SQLite is just a library
• Can be used as part of any C/C++/Java program
– ex: could be used in an iPhone app
• Can be used in Chrome & Safari
– no support in Firefox or IE
31
Physical Data Independence
• SQL doesn’t specify how data is stored on disk
• No need to think about encodings of data types
– ex: DECIMAL(10,2)
– ex: VARCHAR(255)
• does this need to use 255 bytes to store ‘hello’?
• No need to think about how tuples are arranged
– ex: could be row- or column-major ordered
– (Most DBMSs are row-ordered, but Google’s BigQuery is
column-oriented.)
32
SQLite Gotchas
• Allows NULL keys
– At most one tuple can have NULL in the key
– According to the SQL standard, PRIMARY KEY should
always imply NOT NULL, but this is not the case in SQLite
• Does not support boolean or date/time columns
• Doesn’t always enforce domain constraints!
– will let you insert a string where an INT is expected
• Doesn’t enforce foreign key constraints by default
• Etc…

More Related Content

PPT
Unit4_Lecture-sql.ppt and data science relate
umang2782love
 
PDF
Relational database management system
Praveen Soni
 
PPTX
Advanced_SQL_Presentation_Template.pptx
SARASCHANDRA MAVALLAPALLI
 
PPTX
Tk2323 lecture 7 sql
MengChun Lam
 
PPTX
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
NathRam2
 
PPTX
MS SQL - Database Programming Concepts by RSolutions
RSolutions
 
PPTX
Unit 10 - Realtional Databases.pptxxxxxxxxx
vinothkumarg29
 
DOCX
DBMS LAB M.docx
SuhaniSinha9
 
Unit4_Lecture-sql.ppt and data science relate
umang2782love
 
Relational database management system
Praveen Soni
 
Advanced_SQL_Presentation_Template.pptx
SARASCHANDRA MAVALLAPALLI
 
Tk2323 lecture 7 sql
MengChun Lam
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
NathRam2
 
MS SQL - Database Programming Concepts by RSolutions
RSolutions
 
Unit 10 - Realtional Databases.pptxxxxxxxxx
vinothkumarg29
 
DBMS LAB M.docx
SuhaniSinha9
 

Similar to lec02-data-models-sql-basics.pptx (20)

PPTX
Sql
Mahfuz1061
 
PPTX
Relational Database Management System
Mian Abdul Raheem
 
PDF
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
zmulani8
 
PDF
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
rohithlingineni1
 
PPT
Database Technology Teaching Material For Learn
hermawatyrahma21
 
PPT
MY SQL
sundar
 
PPTX
SQL POWERPOINT PRESENTATION ON SQL .pptx
alakeshbarua2
 
PPT
CSE311_IAH_Slide07_SQL Advanced Quries.ppt
noshinnawar31
 
PDF
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
NeetuPrasad16
 
PPTX
Introduction to database
Pradnya Saval
 
PPTX
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
PDF
Introduction to SQL..pdf
mayurisonawane29
 
PPTX
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
PPT
Introduction to structured query language (sql)
Sabana Maharjan
 
PDF
database1.pdf
prashanna13
 
PDF
sql_data.pdf
VandanaGoyal21
 
PPTX
DBMS Relational Data Model .pptx
RajSurase1
 
PDF
Session 1 - Databases-JUNE 2023.pdf
SwapnilSaurav7
 
PPTX
IP-Lesson_Planning(Unit4 - Database concepts and SQL).pptx
ssuser61d324
 
PPTX
Database Basics
Abdel Moneim Emad
 
Relational Database Management System
Mian Abdul Raheem
 
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
zmulani8
 
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
rohithlingineni1
 
Database Technology Teaching Material For Learn
hermawatyrahma21
 
MY SQL
sundar
 
SQL POWERPOINT PRESENTATION ON SQL .pptx
alakeshbarua2
 
CSE311_IAH_Slide07_SQL Advanced Quries.ppt
noshinnawar31
 
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
NeetuPrasad16
 
Introduction to database
Pradnya Saval
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
Introduction to SQL..pdf
mayurisonawane29
 
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
Introduction to structured query language (sql)
Sabana Maharjan
 
database1.pdf
prashanna13
 
sql_data.pdf
VandanaGoyal21
 
DBMS Relational Data Model .pptx
RajSurase1
 
Session 1 - Databases-JUNE 2023.pdf
SwapnilSaurav7
 
IP-Lesson_Planning(Unit4 - Database concepts and SQL).pptx
ssuser61d324
 
Database Basics
Abdel Moneim Emad
 
Ad

More from cAnhTrn53 (7)

PDF
Synchonization in Distributed Systems.pdf
cAnhTrn53
 
PDF
Several Naming Convention for Distributed Systems.pdf
cAnhTrn53
 
PDF
Communication in Distributed Systems.pdf
cAnhTrn53
 
PDF
Architectures of Distributed Systems.pdf
cAnhTrn53
 
PDF
Some processes of Distributed Systems.pdf
cAnhTrn53
 
PPTX
An Introduction to Android Development for Students
cAnhTrn53
 
PPTX
Báo Cáo Cuối Kỳ Cá Nhân.pptx
cAnhTrn53
 
Synchonization in Distributed Systems.pdf
cAnhTrn53
 
Several Naming Convention for Distributed Systems.pdf
cAnhTrn53
 
Communication in Distributed Systems.pdf
cAnhTrn53
 
Architectures of Distributed Systems.pdf
cAnhTrn53
 
Some processes of Distributed Systems.pdf
cAnhTrn53
 
An Introduction to Android Development for Students
cAnhTrn53
 
Báo Cáo Cuối Kỳ Cá Nhân.pptx
cAnhTrn53
 
Ad

Recently uploaded (20)

PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 

lec02-data-models-sql-basics.pptx

  • 1. Introduction to Database Systems Lecture 2: Data Models & SQL (Ch. 2.1-2.3) 1
  • 2. 2 Data Models • language / notation for talking about data • models we will use: – relational: data is a collection of tables – semi-structured: data is a tree • other models: – key-value pairs: used by NoSQL systems – graph data model: used by RDF (semi-structured can also do) – object oriented: often layered on relational, J2EE
  • 3. Relational Model • Data is a collection of relations / tables: • mathematically, relation is a set of tuples – each tuple appears 0 or 1 times in the table – order of the rows is unspecified Name Country Employees For_Profit GizmoWorks USA 20000 True Canon Japan 50000 True Hitachi Japan 30000 True HappyCam Canada 500 False columns / attributes / fields rows / tuples / records 3
  • 4. 4 Relational Schema • Each column has a “domain” (or type) – SQL has Java-like types for numbers, strings, etc. – domain is a constraint on the data allowed in the table • Names and types part of the “schema” of the table: Company(Name: string, Country: string, Employees: int, For_Profit: boolean) • Particular data is an “instance” of that relation – data changes over time – DBMS usually just stores the current instance
  • 5. 5 Keys • Key = subset of columns that uniquely identifies tuple • Another constraint on the table – no two tuples can have the same values for those columns • Examples: – Movie(title, year, length, genre): key is (title, year) – what is a good key for Company? • Part of the schema (book notation is underline): Company(Name: string, Country: string, Employees: int, For_Profit: boolean)
  • 6. 6 Keys (cont.) • Can have multiple keys for a table • Only one of those keys may be “primary” – DBMS often makes searches by primary key fastest – other keys are called “secondary” • “Foreign key” is a column (or columns) whose value is a key of another table – i.e., a reference to another row in another table
  • 7. 7 SQL (“sequel”) • Standard query language for relational data – used for databases in many different contexts – inspires query languages for non-relational (e.g. SQL++) • Everything not in quotes (‘…’) is case insensitive • Provides standard types. Examples: – numbers: INT, FLOAT, DECIMAL(p,s) • DECIMAL(p,s): Exact numerical, precision p, scale s. Example: decimal(5,2) is a number that has 3 digits before the decimal and 2 digits after the decimal – strings: CHAR(n), VARCHAR(n) • CHAR(n): Fixed-length n • VARCHAR(n): Variable length. Maximum length n
  • 8. 8 SQL (“sequel”) – Cont. • Provides standard types. Examples: – BOOLEAN – DATE, TIME, TIMESTAMP • DATE: Stores year, month, and day values • TIME: Stores hour, minute, and second values • TIMESTAMP: Stores year, month, day, hour, minute, and second values • Additional types differ by vendor: – SQLite: http://www.sqlite.org/datatype3.html
  • 9. 9 SQL statements • create table … • drop table ... • alter table ... add/remove ... • insert into ... values ... • delete from ... where ... • update ... set ... where ... • select … from … where
  • 10. 10 create table … CREATE TABLE Company( name VARCHAR(20) PRIMARY KEY, country VARCHAR(20), employees INT, for_profit CHAR(1));
  • 11. 11 Multi-column Keys • This makes name a key: CREATE TABLE Company( name VARCHAR(20) PRIMARY KEY, country VARCHAR(20), employees INT, for_profit BOOLEAN); • How can we make a key on name & country?
  • 12. Multi-column Keys • Syntax change if a primary key has multiple columns: CREATE TABLE Company( name VARCHAR(20) PRIMARY KEY, country VARCHAR(20), employees INT, for_profit BOOLEAN, PRIMARY KEY (name, country)); goes away added 12
  • 13. Multi-column Keys (2) • Likewise for secondary keys: CREATE TABLE Company( name VARCHAR(20) UNIQUE, country VARCHAR(20), employees INT, for_profit BOOLEAN, UNIQUE (name, country)); goes away added 13
  • 14. Multi-column Keys (3) • This makes manufacturer a foreign key: CREATE TABLE Product( name VARCHAR(20), price DECIMAL(10,2), manufacturer VARCHAR(20) REFERENCES Company(name)); good idea to include target column name 14
  • 15. Multi-column Keys (3) • Similar syntax for foreign keys: CREATE TABLE Product( name VARCHAR(20), price DECIMAL(10,2), manu_name VARCHAR(20), manu_co VARCHAR(20), FOREIGN KEY (manu_name, manu_co) REFERENCES Company(name, country)); now need both name & country added 15
  • 16. 16 UNIQUE • PRIMARY KEY adds implicit “NOT NULL” constraint while UNIQUE does not – you would have to add this explicitly for UNIQUE: CREATE TABLE Company( name VARCHAR(20) NOT NULL, … UNIQUE (name)); • You almost always want to do this (in real schemas) – SQL Server behaves strangely with NULL & UNIQUE – otherwise, think through NULL for every query – you can remove the NOT NULL constraint later
  • 17. 17 drop table ... DROP TABLE Company;
  • 18. 18 alter table ... add/remove ... ALTER TABLE Company ADD CEO VARCHAR(20);
  • 19. 19 insert into ... values ... INSERT INTO Company VALUES ('GizmoWorks', 'USA', 20000, 'y');
  • 20. 20 One Way to Input Data • Write a program that outputs SQL statements: for (int a = 1; a <= 50; a++) for (int b = 1; b <= 50; b++) System.out.format( “INSERT INTO T VALUES (%d,%d);n“, a, b); • Feed those into SQLite: sqlite3 foo.db < inputs.sql
  • 22. Warning • Be very careful when doing this with strings: System.out.format( ”INSERT INTO T2 VALUES (%d, ‘%s’);”, 3, ”O’Shaughnessy”); Becomes: INSERT INTO T2 VALUES (3, ‘O’Shaughnessy’); which is a syntax error in this case 22
  • 24. 24 Warning (cont) • Be very careful when doing this with strings: System.out.format( ”INSERT INTO T VALUES (%d, ‘%s’);”, 3, ”O’Shaughnessy”); • This allows a SQL injection attack! – Must check for quotes and escape (or disallow) them. – We’ll see safer ways to do this using JDBC • DBMSs usually have faster ways to input data – SQLite has .import (try with .mode csv)
  • 25. 25 delete from ... where ... DELETE FROM Company where name = 'GizmoWorks';
  • 26. 26 update ... set ... where ... UPDATE Company SET employees = employees + 120 where name = 'GizmoWorks';
  • 27. 27 select ... from ... where ... SELECT * FROM Company where name = 'GizmoWorks';
  • 28. 28 DISTINCT and ORDER BY • Query results do not have to be relations – i.e., they can have duplicate rows – remove them using DISTINCT • Result order is normally unspecified – choose an order using ORDER BY – e.g., ORDER BY country, cname – e.g., ORDER BY price ASC, pname DESC • Examples in lec03-sql-basics.sql
  • 29. 29 Demo on Sqlite • E.g., type sqlite3 in Cygwin • .exit - exit from sqlite3
  • 30. 30 SQLite Uses • SQLite is just a library • Can be used as part of any C/C++/Java program – ex: could be used in an iPhone app • Can be used in Chrome & Safari – no support in Firefox or IE
  • 31. 31 Physical Data Independence • SQL doesn’t specify how data is stored on disk • No need to think about encodings of data types – ex: DECIMAL(10,2) – ex: VARCHAR(255) • does this need to use 255 bytes to store ‘hello’? • No need to think about how tuples are arranged – ex: could be row- or column-major ordered – (Most DBMSs are row-ordered, but Google’s BigQuery is column-oriented.)
  • 32. 32 SQLite Gotchas • Allows NULL keys – At most one tuple can have NULL in the key – According to the SQL standard, PRIMARY KEY should always imply NOT NULL, but this is not the case in SQLite • Does not support boolean or date/time columns • Doesn’t always enforce domain constraints! – will let you insert a string where an INT is expected • Doesn’t enforce foreign key constraints by default • Etc…