Question 1 Consider the following relations with key underlined: Lives (person name, street, city) Works (person name, company_name, salary) Located (company name, city) Manages (person name, manager_name) Answer the following using SQL: a) Define the schema for relation Works in SQL, note that company name is foreign key. Specify constraint that salary should not be less than 10,000cedis. Find the names and city of persons who work for manager John. Find the names of persons who earn more than the average salary. John's manager has changed. The new manager is Anna. Remove all people whose name start with the letter 'S' from the database. List the number of companies in each city, in descending order by number. Who are the managers and for which company do they work? Add a new text column called Country to the Located table. b) c) d) f) g) h) i) j) Find how many people in each company earn more than GHC20,000 Create a view CapeWork (person_name, company_name) of all people who work in Cape Coast in ascending order of person name.
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
1
Trending now
This is a popular solution!
Step by step
Solved in 3 steps