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

Field, examples of fields in a database

examples of fields in a database

Key to represent relationship between tables is called, Key to represent re...

Key to represent relationship amongs tables is called ? A Key that represent the relationship between tables is called Foreign Key.

Develop motel point of sale software, Project Description: I need a poin...

Project Description: I need a point of sale for motels. It needs to run on windows and requires being network able so that we can have more than one computer using it at once.

Keys, #questiontypes of keys examples..

#questiontypes of keys examples..

Calculate the record size r in bytes, An employee record has the following ...

An employee record has the following structure struct employee { int eno; char name[22]; float salary; char dept[10];}; (i) Calculate the record size R in bytes.

Define cascading rollback, Define Cascading rollback The phenomenon whe...

Define Cascading rollback The phenomenon where a single transaction failure leads to a series of transaction rollbacks is known as Cascading rollback.

Erd, er diagram on cosmetics.

er diagram on cosmetics.

How are tables stored on disk?, How are tables stored on Disk? We reali...

How are tables stored on Disk? We realise that every record of a table can have different amounts of data. This is due to in some records; some attribute values may be "zero".

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

Express the properties of strings, Express the properties of Strings? ...

Express the properties of Strings? Strings can be case sensitive (or not) which can change the outcome of string operations. You can evaluate whole strings \ just part

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