This action might not be possible to undo. Are you sure you want to continue?
What are the relational algebra operations and how are they different from SQL commands? 2. How does SQL implement the relational algebra operations product, select, and project? 3. How does SQL implement the natural, equi and theta joins? Practical: Operations on a single table Objective: this tutorial lets you learn how to create your own tables using SQL. Start up the Command Centre and make sure that it is set up to use semicolon as the statement termination character (just like Tutorial 2) and create a new script that does the following: 1. Create a new database named tut3. 2. Create the PERSON table the attributes are P_IC BIGINT, P_NAME VARCHAR (50), P_HOMETOWN VARCHAR (50), P_STATE VARCHAR (50), P_RELIGION VARCHAR (50), P_BIRTHDAY DATE and the primary key is P_IC. create table person ( p_ic bigint not null, p_name varchar(50), p_hometown varchar(50), p_state varchar(50), p_religion varchar(50), p_birthday date, primary key (p_ic) ); 3. Enter yourself and 10 other people into the database. If you can't find out information about 10 other real people it's OK to make up imaginary people. Give yourself the P_IC 0 and the other people P_IC 1 to 10. Remember that P_IC should be NOT NULL. The default year format is YYYY-MM-DD.
4. Make sure that there are some people in your database who have the same state as you and have the same religion as you and are younger than you. (This is so that question 7 will have some visible results.) Example of data: p_ic p_name p_hometown p_state p_religion p_birthday 0 Jessie Shah Alam Selangor Christian 1980-0602 1 Bala Krishnan Ipoh Perak Hindu 1982-0101 2 Munir Mohd Amin Taiping Perak Muslim 1981-09-07 3 Chua Ah Kow Sungai Petani Kedah Buddhist 1980-01-02 4 P. Pandian Dengkil Selangor Hindu 1979-12-25 5 Dadala Ratnam Petaling Jaya Selangor Christian 1982-0105 6 Faruq Tariq Simpang Tiga Kedah Muslim 1981-09-30 7 Marina Matthew Kelang Selangor Christian 1982-0722 8 Phua Chu Kang Katong Singapore Christian 1966-0820 9 Gurmit Singh Sepang Selangor Sikh 1980-0820 10 Ng Faye Faye Cheras Selangor Buddhist 1982-0203 Write the SQL scripts to do the following queries: 5. Type in the command to show the birthdays, names, and hometowns of all the people in your database who are were born before 1 January 1981. 6. Type in the command to show all the people in your database who are the same religion as you. (Clue: this is a nested query. “You” are the entity with P_IC=0.) 7. Type in the command to show all the people in your database who are from the same state as you and have the same religion but is younger than you. 8. Save your resulting script on your pen drive. 9. Email the saved file to the tutor. (The tutor will tell you his/her email address for this purpose.) The tutor will email you back an acknowledgement before the end of this week so that you will have some sort of proof that you had turned in your tutorial in case of disputes about missing tutorial marks in the future. If you don’t get an email acknowledgement from the tutor by the end of this week please see him/her to sort it out immediately and don’t wait till the end of trimester. 10. Disconnect from the database and DROP DATABASE TUT3 so that the next person to try this tutorial on the same computer won’t crash into your work.