DBCOMP - Relational Databases Most DBMSs more or less use...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Relational Databases Most DBMSs more or less use the relational model, where a user can think of data as stored in tables. SQL To make a table: CREATE TABLE PhdStudents (sid INTEGER, name CHAR(30), officenum INTEGER) Look up Insert, Delete, Update… Here is the resulting relation in our DB. PHDStudents(sid : integer, name: string, officenum: integer) SID is the key. This means that no two records (tuples) can have the same sid. We also say that SID Æ NAME, or SID “functionally determines” NAME (Andrea will talk about this). SID Name OfficeNum 12345 Ron 268 67890 Andrea 268 62672 Billy 264 88122 Doantam 270 Basic SQL SELECT [DISTINCT] … FROM … WHERE … Example SELECT P.sid, P.name FROM PHDStudents P WHERE P.OFFICENUM=268 How to think about it… 1) Look at relation specified in the FROM list 2) Keep only those records satisfying the WHERE conditions 3) Keep only those columns named in the SELECT list Intermediate SQL Join – a join is when you combine two relations on some condition. Suppose in addition to PHDStudents, we have a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/18/2011 for the course CS 242 at Stanford.

Page1 / 2

DBCOMP - Relational Databases Most DBMSs more or less use...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online