On Tue, Mar 11, 2025 at 6:50 AM Kirk Parker <k...@equatoria.us> wrote:
> On Tue, Mar 11, 2025, 02:37 PG Doc comments form <nore...@postgresql.org> 
> wrote:
>>
>> The following documentation comment has been logged on the website:
>>
>> Page: https://www.postgresql.org/docs/17/tutorial-fk.html
>> Description:
>>
>> While going through the documentation in a sequential manner, attempting to
>> create TABLE cities creates an error as “relation cities” already exists.
>> I am still figuring out how to proceed to create the referential rule.
>> Thanks,
>
>
> If you've been working through the tutorial sequentially in the same database 
> and not "cleaning up" after your previous chapters, then indeed the 'cities' 
> table already exists because you created it in chapter 2.
>

I don't know that there is any reason a user should be expected to
know when they should "clean up after themselves" if they aren't told
explicitly to do so.

> Part of the (implicit or explicit?) style guide of the tutorial is that each 
> chapter should be comprehensible on its own. The reader might have arrived 
> there through a web search rather than linearly, and the opening sentence 
> "Recall the weather and cities tables from Chapter 2..." is meant as a casual 
> hint that the results of those earlier chapters might persist. I'm not sure 
> we want to engage in more detailed or formalistic set of warnings at the 
> expense of readability of the current chapter -- for example by saying "your 
> first need to drop these tables if they still exist from being created in a 
> previous chapter".
>

I think it's hard to argue that we think these lessons should be able
to stand on their own while we are also making references back to
previous lessons. In this case, it does seem like we could satisfy
both use cases by adding:

DROP TABLE cities IF EXISTS;
DROP TABLE weather IF EXISTS;

Before the new create table commands. If you are following
sequentially, these will clean up for you, and if you came here as a
stand-alone these will no-op;


Robert Treat
https://xzilla.net


Reply via email to