titleauthor table

titleauthor is defined as follows:

create table titleauthor
(au_id id not null,
title_id tid not null,
au_ord tinyint null,
royaltyper int null)

Its primary keys are au_id and title_id:

sp_primarykey titleauthor, au_id, title_id

Its title_id and au_id columns are foreign keys to titles and authors:

sp_foreignkey titleauthor, titles, title_id
sp_foreignkey titleauthor, authors, au_id

Its nonclustered index for the au_id column is defined as:

create nonclustered index auidind
on titleauthor(au_id)

Its nonclustered index for the title_id column is defined as:

create nonclustered index titleidind
on titleauthor(title_id)

The following view uses titleauthor:

create view titleview
as
select title, au_ord, au_lname,
price, total_sales, pub_id
from authors, titles, titleauthor
where authors.au_id = titleauthor.au_id
and titles.title_id = titleauthor.title_id

The following procedure uses titleauthor:

create procedure byroyalty @percentage int
as
select au_id from titleauthor
where titleauthor.royaltyper = @percentage

Table A-4 lists the contents of titleauthor:

Table A-4: titleauthor table

au_id

title_id

au_ord

royaltyper

172-32-1176

PS3333

1

100

213-46-8915

BU1032

2

40

213-46-8915

BU2075

1

100

238-95-7766

PC1035

1

100

267-41-2394

BU1111

2

40

267-41-2394

TC7777

2

30

274-80-9391

BU7832

1

100

409-56-7008

BU1032

1

60

427-17-2319

PC8888

1

50

472-27-2349

TC7777

3

30

486-29-1786

PC9999

1

100

486-29-1786

PS7777

1

100

648-92-1872

TC4203

1

100

672-71-3249

TC7777

1

40

712-45-1867

MC2222

1

100

722-51-5454

MC3021

1

75

724-80-9391

BU1111

1

60

724-80-9391

PS1372

2

25

756-30-7391

PS1372

1

75

807-91-6654

TC3218

1

100

846-92-7186

PC8888

2

50

899-46-2035

MC3021

2

25

899-46-2035

PS2091

2

50

998-72-3567

PS2091

1

50

998-72-3567

PS2106

1

100