Create the physical database from your design

Assignment Help PL-SQL Programming
Reference no: EM133394527

Relational Database Concepts and Applications

Project: In this assignment you will create the physical database from your design created in Project 2. Project 2 was a logical model of the Acme Video Store database. We need to transition the logical model into a physical implementation. As noted in the course content, a physical implementation (or sometimes known as a physical model) is the database created on a system that we (or the users) will use. To this end, we use SQL to create the database.

SQL is standard between many relational database types and is a part of Oracle, as noted in our readings this week. Also, SQL had a few different ‘subsets' of language commands, which includes Data Definition Language (DDL) and Data Manipulation Language (DML), as two of the primary SQL language subsets (there are a few other language subsets).

To create the database in a database tool like Oracle, we use SQL's Data Definition Language (DDL), which allows us to tell the database how the tables (entities) and the associated fields within the tables (attributes) are described.

Step One: CREATE THE SQL DDL FOR YOUR DATABASE

For your logical database model created in Project 2, create the SQL DDL commands that will be submitted to Oracle. Oracle will create the data structures to hold your data.

EXAMPLE:

• From our reading - Creating a table
• Describe in detail the layout of each table in the database
• Use CREATE TABLE statement
• The word ‘TABLE' in that statement is followed by the table name
• Follow this with the names and data types of the attribute in the table
• Data types define type and size of data
o Make sure that we do not use deprecated data types
• Table and column name restrictions
o Names cannot exceed 30 characters

o Must start with a letter
o Can contain letters, numbers, and underscores (_)
o Cannot contain spaces
o Identifying attribute names must be meaningful

1450_Relational Database Concepts.jpg

Figure 1: Create table REP using DDL

In addition to reviewing the course material in this week's content area this resource might be helpful:

• Introduction to Oracle CREATE TABLE:
If an error is encountered or you wish to re-create the table, you will first need to DROP the existing table. Dropping a table is done when:
• Correcting errors by dropping (deleting) a table and starting over
• Useful when table is created before errors are discovered
• Command is followed by the table to be dropped and a semicolon
• Any data in table also deleted

Be sure to SAVE your work. Saving your work with a .sql extension will:

• Allow you to use commands again without retyping
• Save commands in a script file or script
o This will be a text file with an .sql extension

Step Two: LOAD DATA INTO YOUR DATABASE

Following the creation of the database structure (the tables and fields) using DDL, we'll need to load data into the structures (e.g., populate data into the tables). Populating the Acme Video Store database is done by Data Manipulation Language (DML) SQL commands.
As an example, let's create a table not related to our project. We will use INSERT to add the first few records to it. The example code below will create a table named users that has 5 columns. We'll have an userid column that will be the PRIMARY KEY (the column that will always have unique values and allow us to uniquely identify a row), and then the name, age, state, and email columns. The SQL DDL is:
CREATE TABLE users (
USERID INTEGER PRIMARY KEY,
NAME VARCHAR2(100),
AGE NUMBER,
STATE CHAR(2),
EMAIL VARCHAR2(100)
);
Load data into the ‘users' table by using the SQL DML INSERT command. We will add the user Paul with a userid of 1 , an age of 24, from the state of Michigan, and with an email address of [email protected] using the query below:
INSERT INTO users VALUES (1, "Paul", 24, "Michigan", "[email protected]"); Let's add a couple more records into that table:
INSERT INTO users (userid,name, state) VALUES (2, "Molly", "New Jersey"); INSERT INTO users (userid,name, state, age) VALUES (3,"Robert", "New York", 19);
In this case the first value is assigned to the first mentioned column, so "Molly" is assigned to the name column, and "New Jersey" to the state column. Then for the other record, the column name is given the value of "Robert", the column state gets "New York", the column age is assigned 19.

As noted above, the process of creating the database structure by using DDL followed by using the DML Insert command will be similar to creating the database structure and loading data from Project 2.
In addition, this resource may be helpful:

Step Three: WRITE SQL QUERIES TO RETRIEVE DATA FROM THE DATABASE

Using SQL, we can interact with the database by writing queries. Queries are a part of SQL. Here's what

an example query looks like, using the SELECT statement:

SELECT *
FROM users;
Using this SELECT statement, the query selects all the data from all the columns in the customer's table and returns data like so:
Figure 2: SELECT statement results from the users table

1247_Relational Database Concepts1.jpg

Figure 2: SELECT statement results from the users table

The asterisk wildcard character (*) refers to "all" and selects all the rows and columns. We can replace it with specific column names instead?-?here only those columns will be returned by the query
SELECT name, state, email FROM users;

494_Relational Database Concepts2.jpg

 

Adding a WHERE clause allows you to filter what gets returned:

SELECT name, state, age, email FROM users
WHERE age >= 60;

140_Relational Database Concepts3.jpg

This query only shows those users with an age value greater than or equal to 60. This query returns all data from the products table with an age value of greater than 30. The use of ORDER BY keyword just means the results will be ordered using the age column from the lowest value to the highest. Of course, this brief (and limited) example is explained in greater detail in the course content.

Assignment Requirements:

1. Step One: Write the first SQL script to create Oracle database tables using SQL Data Definition Language (DDL) for each table listed in the metadata of Project 2.
a. Include DROP TABLE statements for each table at the script.
b. Ensure that referential integrity is established between related tables. Every table must have a Primary Key. Related tables must have Foreign Keys defined. These can be defined in ALTER TABLE statements later in the script.
c. At least one ALTER TABLE statement must be included in the first script.
d. Ensure all table constraints are properly defined such as PRIMARY KEYS, FOREIGN KEYS, etc.
e. Be sure to save your first SQL script that creates all of your tables with a .sql extension.

2. Step Two: Write the second SQL script to populate all of the previously defined tables with at least five records per table.
a. Include DELETE TABLE statements for each table at the top of the script.
b. Ensure the syntax is correct for numerical or character-based values being inserted.
c. Ensure that the related Primary Keys exist prior to inserting them into the related tables as Foreign Keys.
d. Be sure to save your second SQL script that populates all of your tables with a .sql extension.

3. Step Three: Write a third SQL script that performs queries against your database:

a. After composing your queries, run the SQL script until no errors are encountered:

1. Retrieve all of your customers' names, account numbers, and addresses (street and zip code only), sorted by account number.
2. Retrieve all of the videos rented in the last 30 days and sort in chronological rental date order.
3. Produce a list of your distributors and all their information sorted in order by company name.
4. Update a customer name to change their maiden name to a married name. You can choose which row to update. Make sure that you use the primary key column in your WHERE clause to affect only a specific row. You may want to include a ROLLBACK statement to undo your data update.

5. Delete a customer from the database. You can choose which row to delete. Make sure that you use the primary key column in your WHERE clause to affect only a specific row. You may want to include a ROLLBACK statement to undo your data deletion.
b. Be sure to save your third SQL script that populates all of your tables with a .sql extension.

Reference no: EM133394527

Questions Cloud

Analyze the associations of risk factors : If investigators wished to analyze the associations of risk factors with a given outcome using only data on exposure and outcome at baseline,
How different can the core product be : how different can the core product be? Yet some people will spend incredible amounts on shoes, socks, shorts or shirts that are really no different to other
What are compound authorizations : What are "compound authorizations"? How did the 2013 amendments to the HIPAA Privacy Rule facilitate their use? Why were these changes welcomed by the research
Discuss how the company uses these strategies : find a company that uses these strategies and we will discuss how the company uses these strategies select an article from the popular press such as newspaper
Create the physical database from your design : CMIS 320 Relational Database Concepts and Applications, University of Maryland Global Campus - Relational Database Concepts and Applications
What would you suggest dakotah and amal do and why : Dakotah and Amal are at a point in their lives where their children will be going to college soon and they had also purchased a summer home and didn't have
What are barriers jesse might face to getting the job : Jesse is a person with a learning disability who is trying to get a job at a manufacturing plant. What are the barriers Jesse might face to getting the job?
Health records and practice management software in field : How comfortable are you with using electronic health records and practice management software in the field.
Discuss the environment will be widely promoted : In order to improve the company's public image, the CEO comes up with the following strategy: Some land that is not profitable for the company will be donated

Reviews

len3394527

4/19/2023 10:10:12 PM

Relational Database Concepts and Applications (2232) 1. You should have three .sql scripts that must be submitted. 2. Use the proper naming conventions defined in the submission requirements. username from previous order.

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd