You are here: Re: Learning php Sql - « PHP SQL « IT news, forums, messages
Re: Learning php Sql -

Posted by J.O. Aho on 10/14/22 11:50

Frankly wrote:

> I have been looking at other database relationships trying to figure out how
> I can use it to create my relations. I don't know if this is right at all.

> Buildings Table - for the yes/no fields I would like to create a default
> that isn't yes or no.

DEFAULT NULL


> BuildingID - Key - INT - Auto
>
> Name - Varchar (20)
>
> Address - varchar ( 45 )
>
> Cross streetA - Varchar 50
>
> Cross StreetB - Varchar 50
>
> WebSite - Varchar 255
>
> Picture - Varchar 25
>
> Elevator- varchar 1 default 2
>
> Laundry - varchar 1 default 2

Don't use VARCHAR(1) here, use INT(1) and all other where you are using values
1 or 0 (NULL if unknown).

> Dogs - varchar 1
>
> Cats - varchar 1.
>
> pets comments if pets = 1 - if empty dont show.
>
> Gym -varchar 1
>
> video intercome varchar 1
>
> contact varchar 45
>
> contact phone varchar 45
>
> Area varchar 20
>
> Zip Code Varchar 10


> Apartments Table
>
>
>
> ApartmentID - PK auto - int to image table?
>
> BuildingID - int
>
> Rent - dec
>
> AptNumber - varchar 6
>
> Bedroom - dec 3
>
> bathroom - dec 3
>
> WebSite varchar 255
>
> Picture varchar 25

This allows you to only have one image per apartment, not that good, I would
skip this one completely.

> Notes - text - there will be 4 picture fields and 1 note field for each
> picture.

You could skip this too.


> MoveInDate - Date 0000-00-00
>
> Still Available Varchar 2


> RelationPictureApartmentBuilding Table\
>
> ImageID Auto
>
> ApartmentID F, int to apartments table
>
> BuildingID int

This don't make any sense, here is what I would have done:

Picture Table

ImageID VARCHAR(25) ;The name of the image.
ApartmentID INT ;from the Apartments Table
BuildingID INT ;from the Buildings Table
Notes TEXT ;Description of the image


This way you aren't limited to how many pictures an apartment can have, you
could have one from each room, even if the apartment would have 12 rooms, 4
bathrooms, a kitchen and a big living room which you have 3 photos of.
As the camera ID plus your description on the filename makes each image name
to be unique, you can use it as the ImageID, this way you save a bit of space
and you don't need as many columns.


> I have been looking at other database relationships trying to figure out how
> I can use it to create my relations. I don't know if this is right at all.

Your RelationPictureApartmentBuilding table is lacking completely a relation
to the image, it's quite useless, the only relations it has is
building-apartment, the same relation is hold in the picture table I done and
data about the images.



//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация