CS157a
Chris Pollett
Sep 4, 2019
The two most important data models in use for database systems are:
title | year | length | genre |
---|---|---|---|
Gone with the Wind | 1939 | 231 | Drama |
Star Wars | 1977 | 124 | Sci-Fi |
Wayne's World | 1992 | 95 | Comedy |
<Movies> <Movie title="Gone With the Wind"> <Year>1939</Year> <Length>231</Length> <Genre>drama</Genre> </Movie> <Movie title="Star Wars"> <Year>1977</Year> <Length>124</Length> <Genre>sciFi</Genre> </Movie> <Movie title="Wayne's World"> <Year>1992</Year> <Length>95</Length> <Genre>comedy</Genre> </Movie> </Movies>
{ "MyFavoriteString" : "The quick brown fox jumped over the lazy dog", "MyFavoriteArray" : [1, 2, 3] }
title | year | length | genre |
---|---|---|---|
Gone with the Wind | 1939 | 231 | Drama |
Star Wars | 1977 | 124 | Sci-Fi |
Wayne's World | 1992 | 95 | Comedy |
Movies(title, year, length, genre)The attributes in a relation are a set, not a list, so order doesn't matter. The physical model is allowed to store the data in whatever order is most efficient.
(Gone With the Wind, 1939, 231, drama)The SQL command used to insert a tuple into a relation is INSERT. For example,
INSERT INTO MOVIES VALUES ("Gone With the Wind", 1939, 231, "drama");
Movies(title:string, year:integer, length:integer, genre:string)The SQL command used to define a relation is called CREATE TABLE. For example,
CREATE TABLE Movies( title VARCHAR(50), year INT, length INT, genre VARCHAR(10) );
Come up with a relation to describe pages in a wiki system. Annotate the attributes with appropriate domains. Write down some example tuples. Give an example key.
Post your solution to the Sep 4 In-Class Exercise Thread.
Movies( title:string, year:integer, length:integer, genre:string, studioName:string, producerC#:integer ) MovieStar( name:string, address:string, gender:char, birthdate:date ) StarsIn( movieTitle:string, movieYear:integer, starName:string ) MovieExec( name:string, address:string, cert#:integer, netWorth:integer ) Studio( name:string, address:string, presC#:integer )