CSE581: Introduction to DBMS ORACLE Assignment No.1 DUE: March 18, 2009 Points: 15 THIS ASSIGNMENT MUST BE DONE INDIVIDUALLY Please submit the printout that contains SQL expressions and the results (see details later in the assignment). You may discuss this assignment with others, however the submission should be your own work. Description of relations and data There are four tables in this assignment. Table names, attributes, and their descriptions are given below. A. PLAYERS table Attributes Description PLAYERNO Unique number of the player assigned by the club NAME Surname of the player INIT Initials of the players (no full stops or spaces are used after each separate letter) YEAR_OF_BIRTH Year in which the player was born YEAR_JOINED Year in which the player joined the club STREET Name of the street in which the player lives TOWN Town or city in which the player lives LEAGUENO Unique league number assigned by the league or blank for recreational players B. TEAMS table Attributes Description TEAMNO Unique number of the team PLAYERNO Player number of the player who captains the team; players may captain multiple teams DIVISION Division in which the league has placed the team C. MATCHES table Attributes Description MATCHNO Unique number of the match TEAMNO Number of the team PLAYERNO Number of the player WON Number of sets that the player won in the match LOST Number of sets that the player lost in the match D. PENALTIES table Attributes Description PAYMENTNO Unique number for each penalty the club has received and paid PLAYERNO Number of the player who has incurred the penalty PENDATE Date on which the penalty was paid AMOUNT Amount of the penalty; Unit is dollar Part I Creating tables and inserting data Write SQL expressions to create the above four relations and insert the following sample data to each relation accordingly. After creating tables and inserting data to each relation, show the column definitions and all information for each table. When you create the tables, you should decide the data type for each column in each table and constraints for each relation. A. PLAYERS table PLAYER NO NAME INIT YEAR OF BIRTH YEAR JOINED STREET TOWN LEAGUE NO 6 Parmenter R 1964 1977 Haseltine Lane Stratford 8467 44 Baker E 1963 1980 Lewis Street Inglewood 1124 83 Hope PK 1956 1982 Magdalene Road Stratford 1608 2 Everett R 1948 1975 Stoney Road Stratford 2411 27 Collins DD 1964 1983 Long Drive Eltham 2513 104 Moorman D 1970 1984 Stout Street Eltham 7060 GWS 1963 1981 Edgecombe Way Stratford 7 Wise 57 Brown M 1971 1985 Edgecombe Way Stratford 39 Bishop D 1956 1980 Eaton Square Stratford 112 Bailey IP 1963 1984 Vixen Road Plymouth 1319 8 Newcastle B 1962 1980 Station Road Inglewood 2983 100 Parmenter P 1963 1979 Haseltine Lane Stratford 6524 28 Collins C 1963 1983 Old Main Road Midhurst 95 Miller P 1963 1972 High Street Douglas B. TEAMS table TEAMNO PLAYERNO DIVISION 1 6 first 2 27 second 6409 C. MATCHES table MATCHNO TEAMNO PLAYERNO WON LOST 1 1 6 3 1 2 1 6 2 3 3 1 6 3 0 4 1 44 3 2 5 1 83 0 3 6 1 2 1 3 7 1 57 3 0 8 1 8 0 3 9 2 27 3 2 10 2 104 3 2 11 2 112 2 3 12 2 112 1 3 13 2 8 0 3 D. PENALTIES table PAYMENTNO PLAYERNO PENDATE AMOUNT 1 6 08-DEC-80 100.00 2 44 05-MAY-81 75.00 3 27 10-SEP-83 100.00 4 104 08-DEC-84 50.00 5 44 08-DEC-80 25.00 6 8 08-DEC-80 25.00 7 44 30-DEC-82 30.00 8 27 12-NOV-84 75.00 Part II Write SQL expressions for the following queries. Write SQL expressions and print output results for the following queries. You should try to do all but must do at least 15 of the following. 1. Get the player number and the league number of each player resident in Inglewood; order by league number Multiple Tables: 2. Find the team number and the name of the captain of each team 3. Get the numbers and names of the players who are younger than C. Collins Multiple Conditions with AND, OR, and NOT 4. Give the numbers and names of the players who joined the club after they had become 16 and before their 20s (Use BETWEEN) 5. Give the numbers and names of the players who live at Haseltine Lane or Edgecombe Way in Stratford (Use IN) 6. Find the number and name of each player whose name has an B as the first letter. (Use LIKE) 7. Get the number and name of each player who has no league number (Use NULL) Functions: 8. How many players live in Inglewood 9. What is the difference between the highest and lowest penalty in cents 10. Which players have incurred a penalty greater than the average penalty Group By: 11. For each town, find the number of players 12. For each team, give the team number, the number of matches that has been played for that team and the total number of sets lost. Having Clause: 13. Get the number of each player who has incurred more than one penalty 14. For each player who has incurred more than $99 worth of penalties in total, find the player number and the total amount of penalties Order By Clause: 15. Find the payment number and the player number of each penalty, sort the result by player number 16. Give the payment number and the player number of each penalty, sort the result by player number in descending order and within that by payment number in ascending order Subquery: 17. Get the three highest league numbers 18. Give the number of each player who has played for at least one of the teams in which player 104 has ever player Updating Tables: 19. The Parmenter family has moved house to Palmer Street in Inglewood 20. The number of sets won and lost for match 2 has to equal those of match 1 21. Delete all penalties incurred by player 44 Views: 22. Create a view with player number, the name, the initials, and the year of birth of each player who lives in Stratford What to submit: For Part I: You should submit the SQL statements you are using to create and populate tables. Show the column definition and all information for each table. For Part II: you should submit the SQL statements you are using to query the database and the database output.
© Copyright 2026 Paperzz