Script started on Wed Sep 27 15:04:53 1995 cujo% rdb welcome to rdb, an interactive relational db system copyright (c) 1984, rishiyur nikhil, university of pennsylvania type help for help rdb> help; briefly, rdb recognises the following syntax (for more details, please see user manual) : toplevelinput ::= "help" ";" expr ";" "let" id [argstruc] "=" expr ";" "bindings" ";" "use" filename ";" "save" [idlist] "in" filename ";" "exit" ";" argstruc ::= "(" [idlist] ")" expr ::= "if" expr "then" expr "else" expr "lambda" "(" [idlist] ")" "." expr simpleexpr {comparisonop simpleexpr} simpleexpr ::= [prefixop] term {addop term} term ::= factor {multop factor} comparisonop ::= "<" | "<=" | "=" | "<>" | ">=" | ">" prefixop ::= "+" | "-" | "not" addop ::= "+" | "-" | "or" multop ::= "*" | "/" | "div" | "mod" | "and" factor ::= booleanvalue | unsignedinteger charstring | literalrelation id ["(" [arglist] ")"] "(" expr ")" "reduce" "(" expr "," expr "," expr ")" "project" expr "over" attriblist "restrict" expr "with" expr "join" expr "with" expr ["on" attriblist] "rename" attriblist "to" idlist "in" expr "insert" expr arglist ::= expr {"," expr} literalrelation ::= "{" idlist {tuplelist} "}" tuplelist ::= tuple {tuple} tuple ::= "[" atomicvalue {atomicvalue} "]" idlist ::= id {"," id} attriblist ::= attrib {"," attrib} attrib ::= id [":" unsignedinteger] charstring ::= quote anynoncontrolchars quote booleanvalue ::= "true" | "false" filename ::= charstring rdb> use 'spj.rdb'; relation S bound relation P bound relation J bound relation SPJ bound rdb> s; -------------------------- |snum|sname|status|city | |----|-----|------|------| |s5 |Adams| 30|Athens| |s4 |Clark| 20|London| |s3 |Blake| 30|Paris | |s2 |Jones| 10|Paris | |s1 |Smith| 20|London| -------------------------- rdb> p; -------------------------------- |pnum|pname|color|weight|city | |----|-----|-----|------|------| |p6 |Cog |Red | 19|London| |p5 |Cam |Blue | 12|Paris | |p4 |Screw|Red | 14|London| |p3 |Screw|Blue | 17|Rome | |p2 |Bolt |Green| 17|Paris | |p1 |Nut |Red | 12|London| -------------------------------- rdb> project s over snum, sname; ------------ |snum|sname| |----|-----| |s1 |Smith| |s2 |Jones| |s3 |Blake| |s4 |Clark| |s5 |Adams| ------------ rdb> restrict p with psname = screw; psname ?identifier not bound rdb> restrict p with pname=screw; screw ?identifier not bound rdb> restrice p with pname='screw'; ?error in parsing "restrice p " expecting ";" rdb> restrict p with pname = 'screw'; -------------------------------- |pnum|pname|color|weight|city | |----|-----|-----|------|------| |p3 |Screw|Blue | 17|Rome | |p4 |Screw|Red | 14|London| -------------------------------- rdb> restrict p with (pname='screw') and (color='red'); -------------------------------- |pnum|pname|color|weight|city | |----|-----|-----|------|------| |p4 |Screw|Red | 14|London| -------------------------------- rdb> project (restrict s with snum='s1') over sname, city; -------------- |sname|city | |-----|------| |Smith|London| -------------- rdb> s+p; ?incompatible relations for union, intersect, diff or comparison rdb> (project s over snum) - (project (restrict s with city='london') over snum); ------ |snum| |----| |s5 | |s3 | |s2 | ------ rdb> join s with p; --------------------------------------------------------- |snum|sname|status|city |pnum|pname|color|weight|city | |----|-----|------|------|----|-----|-----|------|------| |s1 |Smith| 20|London|p1 |Nut |Red | 12|London| |s1 |Smith| 20|London|p2 |Bolt |Green| 17|Paris | |s1 |Smith| 20|London|p3 |Screw|Blue | 17|Rome | |s1 |Smith| 20|London|p4 |Screw|Red | 14|London| |s1 |Smith| 20|London|p5 |Cam |Blue | 12|Paris | |s1 |Smith| 20|London|p6 |Cog |Red | 19|London| |s2 |Jones| 10|Paris |p1 |Nut |Red | 12|London| |s2 |Jones| 10|Paris |p2 |Bolt |Green| 17|Paris | |s2 |Jones| 10|Paris |p3 |Screw|Blue | 17|Rome | |s2 |Jones| 10|Paris |p4 |Screw|Red | 14|London| |s2 |Jones| 10|Paris |p5 |Cam |Blue | 12|Paris | |s2 |Jones| 10|Paris |p6 |Cog |Red | 19|London| |s3 |Blake| 30|Paris |p1 |Nut |Red | 12|London| |s3 |Blake| 30|Paris |p2 |Bolt |Green| 17|Paris | |s3 |Blake| 30|Paris |p3 |Screw|Blue | 17|Rome | |s3 |Blake| 30|Paris |p4 |Screw|Red | 14|London| |s3 |Blake| 30|Paris |p5 |Cam |Blue | 12|Paris | |s3 |Blake| 30|Paris |p6 |Cog |Red | 19|London| |s4 |Clark| 20|London|p1 |Nut |Red | 12|London| |s4 |Clark| 20|London|p2 |Bolt |Green| 17|Paris | |s4 |Clark| 20|London|p3 |Screw|Blue | 17|Rome | |s4 |Clark| 20|London|p4 |Screw|Red | 14|London| |s4 |Clark| 20|London|p5 |Cam |Blue | 12|Paris | |s4 |Clark| 20|London|p6 |Cog |Red | 19|London| |s5 |Adams| 30|Athens|p1 |Nut |Red | 12|London| |s5 |Adams| 30|Athens|p2 |Bolt |Green| 17|Paris | |s5 |Adams| 30|Athens|p3 |Screw|Blue | 17|Rome | |s5 |Adams| 30|Athens|p4 |Screw|Red | 14|London| |s5 |Adams| 30|Athens|p5 |Cam |Blue | 12|Paris | |s5 |Adams| 30|Athens|p6 |Cog |Red | 19|London| --------------------------------------------------------- rdb> join s with p on city; -------------------------------------------------- |snum|sname|status|city |pnum|pname|color|weight| |----|-----|------|------|----|-----|-----|------| |s1 |Smith| 20|London|p1 |Nut |Red | 12| |s1 |Smith| 20|London|p4 |Screw|Red | 14| |s1 |Smith| 20|London|p6 |Cog |Red | 19| |s2 |Jones| 10|Paris |p2 |Bolt |Green| 17| |s2 |Jones| 10|Paris |p5 |Cam |Blue | 12| |s3 |Blake| 30|Paris |p2 |Bolt |Green| 17| |s3 |Blake| 30|Paris |p5 |Cam |Blue | 12| |s4 |Clark| 20|London|p1 |Nut |Red | 12| |s4 |Clark| 20|London|p4 |Screw|Red | 14| |s4 |Clark| 20|London|p6 |Cog |Red | 19| -------------------------------------------------- rdb> let sc = project s over city; relation sc bound rdb> sc; -------- |city | |------| |Paris | |London| |Athens| -------- rdb> let scview () = project s over city; function scview bound rdb> scview; lambda (). project s over city rdb> scview(); -------- |city | |------| |Paris | |London| |Athens| -------- rdb> insert s; enter data in response to attribute-name prompts when done, type in response to "snum" prompt snum (string):...> s6 sname (string):...> star status (int):...> 50 city (string):...> Baltimore snum (string):...> ----------------------------- |snum|sname|status|city | |----|-----|------|---------| |s6 |star | 50|Baltimore| |s5 |Adams| 30|Athens | |s4 |Clark| 20|London | |s3 |Blake| 30|Paris | |s2 |Jones| 10|Paris | |s1 |Smith| 20|London | ----------------------------- rdb> s; -------------------------- |snum|sname|status|city | |----|-----|------|------| |s5 |Adams| 30|Athens| |s4 |Clark| 20|London| |s3 |Blake| 30|Paris | |s2 |Jones| 10|Paris | |s1 |Smith| 20|London| -------------------------- rdb> let s = insert s; enter data in response to attribute-name prompts when done, type in response to "snum" prompt snum (string):...> s6 sname (string):...> star status (int):...> 50 city (string):...> Baltimore snum (string):...> s7 sname (string):...> globe status (int):...> 40 city (string):...> Philadelphia snum (string):...> relation s bound rdb> s; -------------------------------- |snum|sname|status|city | |----|-----|------|------------| |s7 |globe| 40|Philadelphia| |s6 |star | 50|Baltimore |s5 |Adams| 30|Athens | |s4 |Clark| 20|London | |s3 |Blake| 30|Paris | |s2 |Jones| 10|Paris | |s1 |Smith| 20|London | -------------------------------- rdb> sc; -------- |city | |------| |Paris | |London| |Athens| -------- rdb> scview(); -------------- |city | |------------| |Paris | |London | |Athens | |Baltimore | |Philadelphia| -------------- rdb> exit; bye... cujo% exit script done on Wed Sep 27 15:21:37 1995