Question

In: Computer Science

Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...

  1. Using your downloaded DBMS (MS SQL Server), create a new database.
  2. Create the database tables based on your entities defining
    1. The attributes within each table
    2. The primary and foreign keys within each table

*****Show your database tables, tables attributes, primary and foreign keys*****

Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.

Solutions

Expert Solution

QUERY

/*==============================================================*/
/* Table: Customer */
/*==============================================================*/
create table Customer (
Id int identity,
FirstName nvarchar(40) not null,
LastName nvarchar(40) not null,
City nvarchar(40) null,
Country nvarchar(40) null,
Phone nvarchar(20) null,
constraint PK_CUSTOMER primary key (Id)
)
go

/*==============================================================*/
/* Table: "Order" */
/*==============================================================*/
create table "Order" (
Id int identity,
OrderDate datetime not null default getdate(),
OrderNumber nvarchar(10) null,
CustomerId int not null,
TotalAmount decimal(12,2) null default 0,
constraint PK_ORDER primary key (Id)
)
go

/*==============================================================*/
/* Table: OrderItem */
/*==============================================================*/
create table OrderItem (
Id int identity,
OrderId int not null,
ProductId int not null,
UnitPrice decimal(12,2) not null default 0,
Quantity int not null default 1,
constraint PK_ORDERITEM primary key (Id)
)
go

/*==============================================================*/
/* Table: Product */
/*==============================================================*/
create table Product (
Id int identity,
ProductName nvarchar(50) not null,
SupplierId int not null,
UnitPrice decimal(12,2) null default 0,
Package nvarchar(30) null,
IsDiscontinued bit not null default 0,
constraint PK_PRODUCT primary key (Id)
)
go

/*==============================================================*/
/* Table: Supplier */
/*==============================================================*/
create table Supplier (
Id int identity,
CompanyName nvarchar(40) not null,
ContactName nvarchar(50) null,
ContactTitle nvarchar(40) null,
City nvarchar(40) null,
Country nvarchar(40) null,
Phone nvarchar(30) null,
Fax nvarchar(30) null,
constraint PK_SUPPLIER primary key (Id)
)
go

alter table "Order"
add constraint FK_ORDER_REFERENCE_CUSTOMER foreign key (CustomerId)
references Customer (Id)
go

alter table OrderItem
add constraint FK_ORDERITE_REFERENCE_ORDER foreign key (OrderId)
references "Order" (Id)
go

alter table OrderItem
add constraint FK_ORDERITE_REFERENCE_PRODUCT foreign key (ProductId)
references Product (Id)
go

alter table Product
add constraint FK_PRODUCT_REFERENCE_SUPPLIER foreign key (SupplierId)
references Supplier (Id)
go


Related Solutions

Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table. For the On-Demand Streaming System, First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database. Then insert at least three user subscriptions. Execute the queries and make sure they run correctly
a) What are the most important differences between MS Access and as Server database like SQL...
a) What are the most important differences between MS Access and as Server database like SQL Server? b) Does Access have any advantages over SQL Server? c) Describe one or more scenarios where you would recommend upgrading an existing MS Access application to SQL Server. Not the use of SQL Server Express edition.
Using SQL create a new database called school_app. Create a student table with fields id (auto...
Using SQL create a new database called school_app. Create a student table with fields id (auto increment), first_name, last_name. Create a course table with fields id (auto increment), course code (such as ITC or MTH), and course number (such as 100 or 295). Note that the relationship between student and course is many-to-many (n:m). Create a join table called student_course that implements the n:m relationship with fields id (auto increment), student_id, course_id, and grade (which has values 0, 1, 2,...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
The following tables form part of a database (Flights Database) held in a relational DBMS: employee...
The following tables form part of a database (Flights Database) held in a relational DBMS: employee (empNo, empName, empSalary, empPosition) aircraft (aircraftNo, acName, acModel, acFlyingRange) flight (flightNo, aircraftNo, fromAirport, toAirport, flightDistance, departTime, arriveTime) certified (empNo, aircraftNo) Where:  employee contains details of all employees (pilots and non-pilots) and empNo is the primary key;  aircraft contains details of aircraft and C is the primary key.  flight contains details of flights and (flightNo, aircraftNo) form the primary key.  certified...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as if it were being added to MySQL (please give explanations for each line of SQL code and a copy of the code as it would be entered into the query by itself: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient,...
Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient, fullName, biologicalMother, birthdate, address) doctor(idDr, fullName, specialization, consulRates) inpatient(idPatient, entryTime, outTime, idDr, idRoom). Please make entryTime as column that is going to be filled automatically when care record is being add room(idRoom, roomName, cost) fill the data above to each table Create sql query and relational algebra expressions for the query Please give me detailed answer so I could learn from it. Thank you...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT