Sunday, December 10, 2006

Consider the following base tables, with the usual meaning as given in the textbook. Keys are capitalized, and all non-key attributes are permitted to be NULL.
MovieStar(NAME, address, gender, birthdate)
MovieExec(name, address, CERT#, netWorth)
Studio(NAME, address, presCert#)
Each of the choices describes a view that could be constructed using these tables. Write each of the views in SQL, then determine which one of the views among the choices is updatable, according to the restrictions given in the textbook under Modifying Views.

A view "RichExec" giving the name, address, and certificate number of all executives with a net worth of at least IENvbnNpZGVyIHRoZSBmb2xsb3dpbmcgYmFzZSB0YWJsZXMsIHdpdGggdGhlIHVzdWFsIG1lYW5pbmcgYXMgZ2l2ZW4gaW4gdGhlIHRleHRib29rLiBLZXlzIGFyZSBjYXBpdGFsaXplZCwgYW5kIGFsbCBub24ta2V5IGF0dHJpYnV0ZXMgYXJlIHBlcm1pdHRlZCB0byBiZSBOVUxMLiA8Y29kZT48L2NvZGU+PHByZT5Nb3ZpZVN0YXIoTkFNRSwgYWRkcmVzcywgZ2VuZGVyLCBiaXJ0aGRhdGUpPGJyPk1vdmllRXhlYyhuYW1lLCBhZGRyZXNzLCBDRVJUIywgbmV0V29ydGgpPGJyPlN0dWRpbyhOQU1FLCBhZGRyZXNzLCBwcmVzQ2VydCMpPGJyPjwvcHJlPiAgRWFjaCBvZiB0aGUgY2hvaWNlcyBkZXNjcmliZXMgYSB2aWV3IHRoYXQgY291bGQgYmUgY29uc3RydWN0ZWQgdXNpbmcgdGhlc2UgdGFibGVzLiBXcml0ZSBlYWNoIG9mIHRoZSB2aWV3cyBpbiBTUUwsIHRoZW4gZGV0ZXJtaW5lIHdoaWNoIG9uZSBvZiB0aGUgdmlld3MgYW1vbmcgdGhlIGNob2ljZXMgaXMgdXBkYXRhYmxlLCBhY2NvcmRpbmcgdG8gdGhlIHJlc3RyaWN0aW9ucyBnaXZlbiBpbiB0aGUgdGV4dGJvb2sgdW5kZXIgTW9kaWZ5aW5nIFZpZXdzLiAgICAgIDxicj48YnI+QSB2aWV3ICJSaWNoRXhlYyIgZ2l2a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ucy4gIHdvbid0IGJlIHNob3duIGluIHRoZSB2aWV3Ljxicj48YnI+QSB2aWV3ICJCaXJ0aGRheXMiIGNvbnRhaW5pbmcgYSBsaXN0IG9mIG1vdmllIHN0YXIgYmlydGhkYXRlcyAobm8gZHVwbGljYXRlcyk8YnI+U0VMRUNUIERJU1RJTkNUIGJpcnRoZGF0ZSBGUk9NIE1vdmllU3Rhcjs8YnI+RG9lcyBub3QgbWVldCBjb25kaXRpb25zLjxicj4g0,000,000.
SELECT name, address, CERT# FROM MovieExec WHERE netWorth>10000000;
Meets conditions. Won't be shown in the view.

A view "StudioPres" giving the name, address, and certificate number of all executives who are studio presidents.
SELECT E.name, E.addres, E.CERT# FROM MovieExec AS E, Studio WHERE presCert# = CERT#;
SELECT name, address, CERT# FROM MovieExec WHERE CERT# IN (SELECT presCert# FROM Studio);
Also meets conditions. May or may not show up in the view.

A view "NewYorkStudios" giving the names of all the studios with addresses containing "New York".
SELECT NAME FROM Studio WHERE address LIKE '%New York%';
Meets conditions. won't be shown in the view.

A view "Birthdays" containing a list of movie star birthdates (no duplicates)
SELECT DISTINCT birthdate FROM MovieStar;
Does not meet conditions.

No comments: