database-design

Advice on design relations between tables

大憨熊 提交于 2019-12-30 12:54:09
问题 I have information about music albums that I want to organise in RDBMS tables with relations between them. I have the following info for each album: artist, album name, year, label, genre, style, rating. So far I think to make 4 tables - artists, albums (name, year, label, rating), genre1 and genre2 (each genre with its styles). On the diagram it looks as follows: But don't know yet how can I establish a connection between albums and the other three tables? I.e., when I will run a query

When should a social security number be used as a database primary key?

只愿长相守 提交于 2019-12-30 11:38:20
问题 Our DBA says that because the social security number (SSN) is unique, that we should use it as the primary key in a table. While I do not agree with the DBA (and have already mentioned some of the good parts found in this answer), are there any situations where he could possibly be correct? 回答1: SSN is not a unique identifier for people. Whether it should be the PK in some table depends on what the rows in the table mean. (See also sqlvogel's answer.) 6.1 percent of Americans have at least

PHP Booking timeslot

百般思念 提交于 2019-12-30 07:09:10
问题 Im developing a php booking system based on timeslot for daily basis. Ive set up 4 database tables! Bookslot (which store all the ids - id_bookslot, id_user, id_timeslot) Timeslot (store all the times on 15 minutes gap ex: 09:00, 09:15, 09:30, etc) Therapist (store all therapist details) User (store all the members detail) ID_BOOKSLOT ID_USER ID_THERAPIST ID_TIMESLOT 1 10 1 1 (09:00) 2 11 2 1 (09:00) 3 12 3 2 (09:15) 4 15 3 1 (09:00) Now, my issue is, it keep showing repeation for timeslot

Storing inherited objects in a database

拈花ヽ惹草 提交于 2019-12-30 07:01:06
问题 I'm trying to figure out the best way to map inheritance relationships in an object model into a relational database. For example consider the following class structure. public Class Item { public String Name{get; set;} public int Size {get; set} } public Class Widget:Item { public String Color{get; set;} } public Class Doohicky:Item { public String Smell{get; set;} } Here's are a few options I'm considering for how to save this structure to a database. Options 1: Single Table for all item

SQL to retrieve tree structure nicely

。_饼干妹妹 提交于 2019-12-30 06:28:34
问题 Given the simple data structure: ID | Category_Name | Parent_ID Example: 1 Cars 0 2 Boxes 0 3 Lamborghinis 1 4 VW Camper Vans 1 5 Big Boxes 2 6 Small Boxes 2 7 Cereal Boxes 2 8 Broken Lambos 3 9 Yellow Ones 3 10 Rusty 8 11 Milkshake Stained 8 12 Chocolate Flavour 11 13 Strawberry 11 14 Indiscernible Solution 11 Representing a simple tree navigation structure, what would programatically be the best way to retrieve the tree in a presentable format? Can we create an SQL statement to retrieve

Single Table Inheritance or Class Table Inheritance?

假装没事ソ 提交于 2019-12-30 06:03:30
问题 I'm reading about Class Table Inheritance (CTI) and finding I prefer it overall. The question I have is, is there any specific use case for Single Table Inheritance (STI) where you'd use that over CTI? I read http://rhnh.net/2010/07/02/3-reasons-why-you-should-not-use-single-table-inheritance and as far as I know, it's solid. The use case for STI being a difference in behaviour but not data. 回答1: I would like to point you to a great article I have found that explains with clarity why and when

Relational Data Model for Double-Entry Accounting

北慕城南 提交于 2019-12-30 05:31:28
问题 The bounty expires in 5 hours . Answers to this question are eligible for a +50 reputation bounty. Alex wants to draw more attention to this question. Assume there is a bank, a large shop, etc, that wants the accounting to be done correctly, for both internal accounts, and keeping track of customer accounts. Rather than implementing that which satisfies the current simple and narrow requirement, which would a 'home brew': those turn out to be a temporary crutch for the current simple

Simple but heavy application consuming a lot of resources. How to Optimize?

霸气de小男生 提交于 2019-12-30 05:18:08
问题 Currently I have one monitor application in production. The job of this monitor is to collect specific entries on social networking like facebook, twitter, youtube and so on. Here are one simple example of an API call from Twitter: http://search.twitter.com/search?q=Stackoverflow&format=json Basically, this is what the system does: Select the search term from database given an specific order Call the API Collect all tweets statuses IDs and users IDs from the current search Check on the

Table size with page layout

依然范特西╮ 提交于 2019-12-30 05:14:06
问题 I'm using PostgreSQL 9.2 on Oracle Linux Server release 6.3. According to the storage layout documentation, a page layout holds: PageHeaderData(24 byte) n number of points to item(index item / table item) AKA ItemIdData(4 byte) free space n number of items special space I tested it to make some formula to estimate table size anticipated...(TOAST concept might be ignored.) postgres=# \d t1; Table "public.t1" Column ',' Type ',' Modifiers ---------------+------------------------+---------------

How to store .txt files MySQL database?

会有一股神秘感。 提交于 2019-12-30 04:54:25
问题 Can I store data files (e.g. txt files) to the MySql server? If I can, how to store them? 回答1: You can use LOAD DATA INFILE to read the contents of a file and store it in a table in the database in a structured format. This can be considerably faster than reading and parsing the file on the client and then using multiple INSERT statements. Example: LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table; 回答2: Yes you can, but you would probably be better off storing them on the file system and