Write the sql code, Database Management System

Assignment Help:

Express the following queries in SQL:

(a) Write the SQL code that will create ALL the four tables given in the appendix. Your answer should not contain the primary key and foreign key constraint declaration. The data type for each attribute should be for the SQL Server 2005 convention.

(b) Having created the table structure in question (a) above, write SQL code to make the following change in the structure of the tables:

(i) Make the PubId the Primary Key in the Publisher table

(ii) Make the ISBN the primary key and the Pub_Id the foreign key in the Book table.

(iii) Make the AU_ID and the ISBN the Primary Key of the Book_Author table.

(iv) Make the AU_ID and the ISBN the foreign key of the Book_Author table.

(v) Make the AU_ID the Primary key of the Author table

(c) After creating the table structure above, you write the following SQL code to insert the first row in the Book table:

Insert into Book

Values(‘0-0038307-6-4', ‘dBASE III : A Practical Guide', 1985, 469);

When you run the above code SQL Server shows an error message. Explain the reason for the error. How will you correct the error? Explain your answer fully.

(d) If you wanted the au_id column to be automatically incremented when inserting new record in the author table, how would you modify the create statement in question(a) above so that it starts with the number 100 and increment by one every time you create a new record in that table.

(e) Write the SQL code to change the year born value from 1970 to 1971 for the author whose ID is 1.

(f) Write the SQL code required to list all book details whose title's name contains the word "Information".


Related Discussions:- Write the sql code

Develop and evaluate partial systems, Part 1: Security Plan Consider th...

Part 1: Security Plan Consider the Case study and identify 3 security requirements. For each of these security requirements: • Discuss the necessity for the feature and how

Explain the disadvantages of file oriented approach, Explain the disadvanta...

Explain the disadvantages of file oriented approach? In the oriented approach Applications are designed in isolation. Design of application is optimized for one application. In

Managing database, 10A.53 Code an Oracle Database trigger to enforce the ...

10A.53 Code an Oracle Database trigger to enforce the constraint that an employee can never change his or her department. 10A.54 Code an Oracle Database trigger to allow the

What is trigger, What is Trigger? Trigger: A database trigger is proced...

What is Trigger? Trigger: A database trigger is procedural code which is automatically executed in response to specific events on a particular table in a database. Triggers can

Define boyce codd normal form, Define Boyce codd normal form A relation...

Define Boyce codd normal form A relation schema R is in BCNF with respect to a set F of functional dependencies if, for all functional dependencies in F + of the form.α ->β.

Data analysis and design, give some example real-life situations where DBMS...

give some example real-life situations where DBMS are most suiitabe

List and describe the different types of indexes, Question 1 Indexes are o...

Question 1 Indexes are ocasionally defines on a single field of a file called an indexing field. List and describe the different types of indexes Question 2 Consider a book i

Explain the five levels of capability maturity models, Question 1 What is ...

Question 1 What is data mining? Write Data Mining applications Question 2 What is OLAP? Write the benefits of OLAP Question 3 What is Business Intelligence? Explai

What is recovery?, What Is Recovery?  During the life of a transaction, ...

What Is Recovery?  During the life of a transaction, i.e., a after the start of a transaction but before the transaction commits, various changes may be made in a database state

With the help of a diagram defines typical element modules, With the help o...

With the help of a diagram defines the typical element modules of a DBMS? The functional elements of a database system can be widely divided into: 1) Storage manager and 2) q

Write Your Message!

Captcha
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